Skip to content

Copy Id

An ID or token in a mono well with a copy button; "Copied" confirms in place, never as a toast.

1.1 kB gzipSource Registry JSON

CopyId playground

3f9a1c7

Props

Installation

npx shadcn@latest add https://sproutboat.com/ikada/r/copy-id.json

The CLI writes components/ikada/copy-id.tsx and merges the ikada theme into your CSS. It also installs the components it is built from: Icon Button and Inline Confirm. Or take it from the package: import { CopyId } from "@sproutboat/ikada";

Usage

import { CopyId } from "@/components/ikada/copy-id";

<CopyId value="3f9a1c7e5b2d4a80c6e1f7d93b5a2c48e0d1f6a7" display="3f9a1c7" label="Copy commit hash" />

Examples

Default

The copy icon turns into a check, and “Copied” appears above it. Nothing is added to the toasts.
dpl_8f3a91c2

Shortened hash

`display` shortens what is shown; the full value is what gets copied and shown on hover.
3f9a1c7

Truncates in a narrow space

https://robin.sproutboat.app/hooks/deploy-finished

Props

CopyIdProps
PropTypeDescription
valuerequiredstringThe full value written to the clipboard.
displaystringWhat is shown; defaults to the value. Use it to shorten hashes.
labelstringAccessible name of the button, e.g. "Copy deployment ID". Default `Copy ID`.
onCopied((value: string) => void)Called after a successful copy.

Also takes every prop of Omit<ComponentProps<"span">, "children">.

Source: src/components/copy-id.tsx