Knit UI
GitHub

Playground

Loading playground…

Playground
<CopyButton
  value="https://example.com"
  timeout={1000}
/>

Examples

Basic Toggle

Render-prop child shows a simple text toggle between "Copy" and "Copied!".

Loading example…

Basic ToggleSourceStorybook

Shadows

The shadow elevation ladder applied to the render-prop Button trigger, from xs to xl.

Loading example…

ShadowsSourceStorybook

Icon Button

Uses an icon-only action button to demonstrate a compact copy trigger.

Loading example…

Icon ButtonSourceStorybook

Multiple

Multiple independent CopyButtons on a single page — each manages its own state.

Loading example…

MultipleSourceStorybook

Short Timeout

Short timeout (500 ms) — the "Copied" feedback disappears faster than the default.

Loading example…

Short TimeoutSourceStorybook

Long Timeout

Long timeout (5 000 ms) — the "Copied" feedback persists for 5 seconds.

Loading example…

Long TimeoutSourceStorybook

Inline Code

Demonstrates full render-prop flexibility — child renders a styled code snippet with an embedded copy action.

Loading example…

Inline CodeSourceStorybook

Props

PropTypeDefaultDescription
children required(payload: { copied: boolean; copy: () => void; }) => ReactNodeRender callback — receives the current `copied` flag and a `copy` action.
value requiredstringhttps://example.comThe string that will be written to the clipboard.
timeoutnumber | undefined1000Duration in ms the `copied` flag stays true after a copy.