CopyToken
One click copies a high-value identifier and confirms it with a Copied! tooltip.
Quick usage
Import the shared component; never copy its markup into a feature. The Web TSX tab beside the live stage has a complete, working example.
import CopyToken from '@/shared/components/CopyToken';Live stage and code
The live component and its controls on the left, the code on the right; change a control and the code follows: Web TSX (the component in a working example), Tailwind and HTML (the markup it renders, with its data attributes), React Native, SwiftUI and Jetpack Compose. The header theme switch drives every stage.
Props
Read from the component's source when the docs build: names and defaults from its signature, types and descriptions from its JSDoc. A blank type means the prop has no JSDoc yet.
| Prop | Type | Default | Description |
|---|---|---|---|
value | - | - | - |
children | - | - | - |
label | - | 'value' | - |
size | - | 'sm' | - |
variant | - | 'text' | - |
chipSize | - | 'sm' | - |
leading | - | null | - |
className | - | '' | - |
Source: frontend/src/shared/components/CopyToken/CopyToken.js
DOM contract
What the rendered element carries: the data attributes its styles key on, its roles and ARIA, its focus style, and whether its stylesheet draws the 44px hit boundary. Also read from the source.
| Data attributes | data-state |
| Roles | role="status" |
| ARIA | aria-label |
| Focus | Styles :focus-visible in its own stylesheet |
| 44px hit boundary | Yes: a ::after in CopyToken.module.css |
Accessibility and touch
Every variant carries a 44 by 44 target; the visible box stays its own size.
Visible height 28px. The ::after boundary adds 8px above and below, so a gloved finger lands on a 44px target while the row keeps its density.
Do and avoid
Rules and constraints
Use it for
- Quote, project and PO numbers; a contact email or phone.
- chip where the ID is already a pill, plain in a line of text, text in a bare table cell.
Avoid
- Never on every value: a copy affordance on each cell turns a table into buttons.
- Never truncated: an ID cut short cannot be read or trusted.
Constraints
- A click copies and does not open the row; double-click still reaches the cell.
- A clipping parent gives the hover room with matching padding and negative margin.