Components
Code block controls
Built on Base UIClient companion for CodeBlock: clipboard feedback, wrapping and tab state.
lib/deploy.ts
// Ship only after checks pass.
export async function deploy(project: string) {
const checks = await verify(project);
Highlighted: if (!checks.passed) return false;
Highlighted: return publish({ project, region: "fra1" });
}Installation
npx nook-ui@latest add code-block-controlsPrompt
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 "Code block controls" component to this project, exactly as Nook ships it.
Client companion for CodeBlock: clipboard feedback, wrapping and tab state.
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 code-block-controls`. It writes `components/ui/code-block-controls.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/code-block-controls.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
export { default } from "../code-block/default";
```
API
- `CodeBlockControls`: Client shell around server-rendered code children.
- `code` (`string`): Text copied without line numbers.
- `label` (`string`): Header text.
- `defaultWrap` (`boolean`): Initial wrapping.
- `CopyButton`: Shared clipboard control used by developer and AI components.
- `text` (`string`): Exact text to copy.
- `label` (`string`): Action label, default Copy.
- `CodeTabsController`: Client tab state; CodeTabs supplies pre-rendered panels.
- `files` (`{value, label, code, content}[]`): Files with rendered panel content.
- `value / defaultValue` (`string`): Selected file.
- `onValueChange` (`(value: string) => void`): Selection callback.
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: Copy failures are announced and can be retried. Wrapping uses an aria-pressed toggle. Tabs retain Base UI keyboard behavior.
Done when the component renders like the example in light and dark mode and the project type-checks.Usage
export { default } from "../code-block/default";Props
CodeBlockControls
Client shell around server-rendered code children.
| Prop | Type | Default | Description |
|---|---|---|---|
| code | string | – | Text copied without line numbers. |
| label | string | – | Header text. |
| defaultWrap | boolean | – | Initial wrapping. |
CopyButton
Shared clipboard control used by developer and AI components.
| Prop | Type | Default | Description |
|---|---|---|---|
| text | string | – | Exact text to copy. |
| label | string | – | Action label, default Copy. |
CodeTabsController
Client tab state; CodeTabs supplies pre-rendered panels.
| Prop | Type | Default | Description |
|---|---|---|---|
| files | {value, label, code, content}[] | – | Files with rendered panel content. |
| value / defaultValue | string | – | Selected file. |
| onValueChange | (value: string) => void | – | Selection callback. |
Accessibility
Copy failures are announced and can be retried. Wrapping uses an aria-pressed toggle. Tabs retain Base UI keyboard behavior.
Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.