CopyableCode
A command or code row with a built-in copy action.
Use CopyableCode for machine setup commands and other copy-first code rows. Use InlineCode for prose tokens and markdown code blocks for rich multi-line code.
npx @botiverse/raft-daemon@latest --server-url https://api.raft.build --api-key sk_machine_0000000000000000000000000000000000000000000000000000000000000000 # ZolplayA copy can fail — the browser may deny the write, or expose no clipboard API at all. The action only reports success for a write that actually landed: onCopy fires with the text on success, while onError receives an Error once every strategy failed. Handle it by telling the user and offering the manual fallback instead of leaving them with a silent no-op (the third composition above renders exactly that message).
import { CopyableCode, CopyableCodeAction, CopyableCodeRoot } from "raft-ui";
<CopyableCodeRoot>
<CopyableCode />
<CopyableCodeAction />
</CopyableCodeRoot>copiedboolean
Optional controlled copied state. Omit it to let the component manage feedback.
sizedefault: "md""sm" | "md"
Density for dialog setup rows versus tighter detail-panel rows.
onCopy(value: string) => void | Promise<void>
Called with the copied text after a write that actually landed.
onError(error: Error) => void
Called when every copy strategy failed, so the consumer can tell the user instead of claiming success.
...propsComponentPropsWithRef<"div">
Owns copied state, size, and copy behavior for composed parts.
| Prop | Type | Default | Description |
|---|---|---|---|
copied | boolean | — | Optional controlled copied state. Omit it to let the component manage feedback. |
size | "sm" | "md" | "md" | Density for dialog setup rows versus tighter detail-panel rows. |
onCopy | (value: string) => void | Promise<void> | — | Called with the copied text after a write that actually landed. |
onError | (error: Error) => void | — | Called when every copy strategy failed, so the consumer can tell the user instead of claiming success. |
...props | ComponentPropsWithRef<"div"> | — | Owns copied state, size, and copy behavior for composed parts. |
truncatedefault: falseboolean
Single-line horizontally scrollable treatment for the code text.
...propsComponentPropsWithRef<"code">
Code text slot. Its rendered text is the default value copied by Action.
| Prop | Type | Default | Description |
|---|---|---|---|
truncate | boolean | false | Single-line horizontally scrollable treatment for the code text. |
...props | ComponentPropsWithRef<"code"> | — | Code text slot. Its rendered text is the default value copied by Action. |
aria-labeldefault: "Copy code"string
Accessible name for the icon-only action. When omitted, the label swaps to "Copied code" while the copy state is active. It is not rendered as visible text.
childrendefault: Copy / Check iconReactNode | ({ copied }) => ReactNode
Optional visible content for the copy trigger.
...propsButtonProps
Copy trigger slot with default Copy/Check feedback icon.
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label | string | "Copy code" | Accessible name for the icon-only action. When omitted, the label swaps to "Copied code" while the copy state is active. It is not rendered as visible text. |
children | ReactNode | ({ copied }) => ReactNode | Copy / Check icon | Optional visible content for the copy trigger. |
...props | ButtonProps | — | Copy trigger slot with default Copy/Check feedback icon. |