Copy Field
A value people need to copy exactly, such as an IBAN, a reference or a promo code, with a button that confirms the copy.
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
PreviewCode
EnglishMirroredArabic
LTR →
Installation
Add the component
npx ritla add copy-fieldAlso works with shadcn:
npx shadcn@latest add @ritla/copy-fieldDependencies it brings
@phosphor-icons/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { CopyField } from "@/components/ui/copy-field";<CopyField label="IBAN" value="JO94CBJO0010000000000131000" />API reference
CopyField
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | None | The value exactly as copied. |
display | ReactNode | None | How it is shown, if not as copied, such as an IBAN in groups of four. |
variant | "field" | "inline" | "field" | Figma's Style. |
label / aria-label | ReactNode / string | None | Figma's Show label, or a name for screen readers when it is off. |
showButtonLabel | boolean | true | Figma's Show button label. |
onCopy | (value) => void | None | After a successful copy. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| TabEnter | Reaches the button and copies. |
ARIA
- Copied is announced in a polite live region, and nothing is announced when the copy fails.
- The button is described by the value it copies.
Arabic and RTL notes
Mirrors
- The label and button follow the page: the button ends the row, on the left.
Does not mirror
- The value is Latin and left to right, even in Arabic.
- Numerals
- The value's digits are as given; never converted, because they are copied.
- Arabic typography
body-16for the value,body-14Medium for the label and button.- Mixed-direction text
- The value sits in a
<bdi dir="ltr">so an IBAN never reorders, while its block keeps the page direction so it starts at the page's start.