nook
Browse the docs

Components

Copy field

Native

A read-only value with a clipboard action and live success or failure feedback.

See the prompt

Anyone with this link can request to join Studio North.

Installation

npx nook-ui@latest add copy-field

Prompt

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.

Plain text
Add the Nook "Copy field" component to this project, exactly as Nook ships it.

A read-only value with a clipboard action and live success or failure feedback.

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 copy-field`. It writes `components/ui/copy-field.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/copy-field.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
import { CopyField } from "@/components/ui/copy-field";
import { Label } from "@/components/ui/label";
export default function Example() {
  return (
    <div className="grid w-full max-w-md gap-2">
      <Label htmlFor="invite-url">Team invite link</Label>
      <CopyField
        id="invite-url"
        value="https://app.example.com/join/studio-north"
        copyLabel="Copy invite"
      />
      <p className="text-xs text-muted-foreground">
        Anyone with this link can request to join Studio North.
      </p>
    </div>
  );
}
```

API
- `CopyField`: A read-only value with a clipboard action and live success or failure feedback.
  - `value` (`string`): Plain text shown and copied.
  - `copyLabel` (`string`, default Copy value): Action label.

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: Names the input separately from the copy action; clipboard feedback is announced.

Done when the component renders like the example in light and dark mode and the project type-checks.

Usage

import { CopyField } from "@/components/ui/copy-field";
import { Label } from "@/components/ui/label";
export default function Example() {
  return (
    <div className="grid w-full max-w-md gap-2">
      <Label htmlFor="invite-url">Team invite link</Label>
      <CopyField
        id="invite-url"
        value="https://app.example.com/join/studio-north"
        copyLabel="Copy invite"
      />
      <p className="text-xs text-muted-foreground">
        Anyone with this link can request to join Studio North.
      </p>
    </div>
  );
}

Examples

API key

Use this key in test mode only.

Long link

Props

CopyField

A read-only value with a clipboard action and live success or failure feedback.

PropTypeDefaultDescription
valuestring–Plain text shown and copied.
copyLabelstringCopy valueAction label.

Accessibility

Names the input separately from the copy action; clipboard feedback is announced.

Checked against WCAG 2.1 AA with automated axe tests and keyboard tests on every release.