- Docs
- Components
- Actions
Copy button
Copies a value. The icon turns to a check, "Copied" is announced, and focus stays.
- Import
- @qeetrix/react/experimental
- Status
- ExperimentalSince 0.0.4
- Renders
<button>Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
Variant
Tone
Size
import { CopyButton } from "@qeetrix/react/experimental";
<CopyButton value="qid_app_01J9ZK4T7B2R" label="Copy client ID" />02
Icon or label
An icon alone, named by label; or a label, which makes it a Button. Ghost and neutral by default.
<Inline gap="md">
<CopyButton value="usr_01J8K2M4PQ" label="Copy user ID" />
<CopyButton value="org_acme_01HZX3" label="Copy organisation ID" variant="soft" />
<CopyButton value="usr_01J8K2M4PQ" label="Copy user ID">Copy ID</CopyButton>
<CopyButton value="sk_live_51Hx…" label="Copy the secret" variant="soft">Copy secret</CopyButton>
</Inline>03
Beside its value
Each value with its own button, named for it.
Client IDqid_app_01J9ZK4T7B2R
Redirect URIhttps://console.acme.in/auth/callback
Tenanttnt_acme_01HZX3
<Stack gap="md">
{CREDENTIALS.map(([term, label, value]) => (
<Inline key={term} justify="between" wrap={false}>
<Stack gap="none">
<Text size="sm" tone="subtle">{term}</Text>
<Text mono truncate>{value}</Text>
</Stack>
<CopyButton value={value} label={label} />
</Inline>
))}
</Stack>04
Made when it's copied
value can be a function, even an async one: a fresh link on every copy.
<CopyButton value={() => createInviteLink()} label="Copy an invite link">
Copy invite link
</CopyButton>05
Sizes
Square, at a control's height; with a label, a Button's.
<Inline gap="sm" align="center">
<CopyButton value="usr_01J8K2M4PQ" label="Copy user ID, small" size="sm" />
<CopyButton value="usr_01J8K2M4PQ" label="Copy user ID, medium" size="md" />
<CopyButton value="usr_01J8K2M4PQ" label="Copy user ID, large" size="lg" />
</Inline>06
In Hindi
Its words come from QeetrixProvider: "कॉपी करें", then "कॉपी हो गया".
import { hi } from "@qeetrix/react/locales/hi";
<QeetrixProvider locale="hi-IN" messages={hi}>
<CopyButton value="usr_01J8K2M4PQ" />
</QeetrixProvider>