Components
Streaming text
NativeProgressive text with accessible full content and a compact row of message actions.
Deployment assistant
The deployment is healthy. All 12 checks passed, and the new version is serving traffic from Frankfurt. I recommend keeping the previous build available for a quick rollback during the next hour.
Installation
npx nook-ui@latest add streaming-textPrompt
Paste this into your AI coding assistant. It adds this exact component, the same way the CLI does, and tells the assistant how to use it.
Short. For assistants that can run commands in your project.
Add the Nook "Streaming text" component to this project, exactly as Nook ships it.
Progressive text with accessible full content and a compact row of message actions.
Steps
1. Check for `nook.json` in the project root. If it is missing, run `npx nook-ui@latest init` first (React or Next.js with Tailwind CSS v4). It adds the Nook tokens, the theme and `cn()`.
2. Run `npx nook-ui@latest add streaming-text`. It writes `components/ui/streaming-text.tsx` together with everything the component needs. Do not write the component from memory.
3. If you cannot run commands, fetch http://localhost:3000/r/streaming-text.json, write every entry of `files` to the path it names, install the packages in `dependencies`, and repeat for each name in `registryDependencies`.
4. Use it where I ask. Start from this example:
```tsx
"use client";
import * as React from "react";
import { MessageActions, StreamingText } from "@/components/ui/streaming-text";
const text =
"The deployment is healthy. All 12 checks passed, and the new version is serving traffic from Frankfurt. I recommend keeping the previous build available for a quick rollback during the next hour.";
export default function StreamingDefault() {
const [key, setKey] = React.useState(0);
const [shared, setShared] = React.useState(false);
return (
<article className="grid w-full max-w-xl gap-4">
<div className="flex items-center gap-2 text-sm font-medium">
<span aria-hidden="true" className="size-2 bg-brand" />
Deployment assistant
</div>
<StreamingText key={key} text={text} speed={80} />
<MessageActions
text={text}
onRegenerate={() => setKey(key + 1)}
onShare={() => setShared(true)}
/>
{shared ? (
<p role="status" className="text-xs text-muted-foreground">
Answer ready to share. Use Copy answer to include it in your update.
</p>
) : null}
</article>
);
}
```
API
- `StreamingText`: Animation starts only after mount.
- `text` (`string`): Full message; changing it restarts playback.
- `step` (`word | character`): Progress unit; default word.
- `speed` (`number`): Milliseconds per step, default 45.
- `onComplete` (`() => void`): Called once when the current text completes.
- `paused / defaultPaused / onPausedChange` (`boolean / boolean / (paused) => void`): Controlled or uncontrolled pause.
- `MessageActions`: Copy, regenerate, feedback and share.
- `text` (`string`): Answer copied to clipboard.
- `onRegenerate / onShare` (`() => void`): Action callbacks; absent actions are disabled.
- `feedback / defaultFeedback` (`up | down | null`): Controlled or initial feedback.
- `onFeedbackChange` (`(feedback) => void`): Toggle feedback, including clearing it.
Rules
- Colors, radii, shadows and motion come from Nook tokens and classes such as `bg-primary`, `text-muted-foreground`, `border-border`, `rounded-lg` and `h-control`. Never hard-code them.
- Do not restyle or simplify the file. Change how it looks through `className`, its props and the theme.
- It must keep working with the keyboard, in light and dark mode, and in the sharp, soft and bold styles.
- Accessibility: Screen readers receive the full text immediately; the visual copy is aria-hidden. Reduced motion completes instantly. Pause and skip are keyboard controls. Feedback buttons expose aria-pressed.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
"use client";
import * as React from "react";
import { MessageActions, StreamingText } from "@/components/ui/streaming-text";
const text =
"The deployment is healthy. All 12 checks passed, and the new version is serving traffic from Frankfurt. I recommend keeping the previous build available for a quick rollback during the next hour.";
export default function StreamingDefault() {
const [key, setKey] = React.useState(0);
const [shared, setShared] = React.useState(false);
return (
<article className="grid w-full max-w-xl gap-4">
<div className="flex items-center gap-2 text-sm font-medium">
<span aria-hidden="true" className="size-2 bg-brand" />
Deployment assistant
</div>
<StreamingText key={key} text={text} speed={80} />
<MessageActions
text={text}
onRegenerate={() => setKey(key + 1)}
onShare={() => setShared(true)}
/>
{shared ? (
<p role="status" className="text-xs text-muted-foreground">
Answer ready to share. Use Copy answer to include it in your update.
</p>
) : null}
</article>
);
}Examples
By character
Build finished. 214 modules compiled, 0 warnings, 1 skipped test.
Paused
You asked to pause the answer. Press play to keep reading from where it stopped, or leave it here if you have what you need.
Answer with feedback
Restart the router, wait one minute, then reconnect to the 5 GHz network.
Props
StreamingText
Animation starts only after mount.
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | – | Full message; changing it restarts playback. |
| step | word | character | – | Progress unit; default word. |
| speed | number | – | Milliseconds per step, default 45. |
| onComplete | () => void | – | Called once when the current text completes. |
| paused / defaultPaused / onPausedChange | boolean / boolean / (paused) => void | – | Controlled or uncontrolled pause. |
MessageActions
Copy, regenerate, feedback and share.
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | – | Answer copied to clipboard. |
| onRegenerate / onShare | () => void | – | Action callbacks; absent actions are disabled. |
| feedback / defaultFeedback | up | down | null | – | Controlled or initial feedback. |
| onFeedbackChange | (feedback) => void | – | Toggle feedback, including clearing it. |
Accessibility
Screen readers receive the full text immediately; the visual copy is aria-hidden. Reduced motion completes instantly. Pause and skip are keyboard controls. Feedback buttons expose aria-pressed.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.