CopyLinkField
The mock's read-only pill input with its link and an ink "Copy link" button. Copies to the clipboard itself and says so in a live region ("Invite link copied"); onCopied lets the app toast or log it.
import { CopyLinkField } from '@ergasti/bricks';Examples
Copy a link
A read-only field and a Copy button that says "Copied" (or tells you to copy by hand when the clipboard is blocked); onCopied is called after a copy.
Code
import { CopyLinkField } from '@ergasti/bricks';
function Join() {
return <div style={{ maxWidth: 420 }}><CopyLinkField value="trndr.app/join/hushup" onCopied={() => {}} /></div>;
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key copyLinkField, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
field | Invite link | لينك الدعوة |
copy | Copy link | انسخ اللينك |
copied | Invite link copied | اتنسخ لينك الدعوة |
failed | Couldn't copy. Select the link and copy it. | معرفناش ننسخ. علّم على اللينك وانسخه. |
Design guidance
How the BRICKS design system uses CopyLinkField. Written in docs/content/components/CopyLinkField.md; the props above are read from the code, which wins where the two disagree.
A read-only pill field holding a link, with an ink "Copy link" button that copies it and says so; use it wherever a brand shares its invite link.
It is the mocks' invite-link field: inside Brand Home's "Grow your program" callout and the Creators › Invitations tab's "Invite link" callout. It writes to the clipboard itself and announces the result in a polite live region ("Invite link copied", or how to copy by hand when the browser refuses); onCopied lets the app add a toast or analytics.
Anatomy
- Wrapper (
.kit-blk-copylink): flex, gap 8, wrapping. - Field: a read-only
<input>(pill, 42px,--softfill,--ink-2text, LTR), selecting all on focus, named "Invite link". - Button: kit
Button variant="ink""Copy link". - Said line (
.kit-blk-copylink-said, 12px, 600, full width): the live result, hidden while empty; clears after 2.2s.
Variants
| Context | Look |
|---|---|
| Default | Field grows (flex: 1 1 200px), button beside it. |
Inside CalloutCard layout="row" | Field fixed at 220px so the callout's actions line up. |
labels | Rename the field, button or messages (e.g. a "Copy" button in a tight card). |
States
| State | How | Look |
|---|---|---|
| Default | — | Link and "Copy link". |
| Focus (field) | focus/click | Raspberry border + field focus ring; the whole link is selected. |
| Copied | Clipboard write succeeded | "Invite link copied" under the field for 2.2s; onCopied() called. |
| Failed | Clipboard refused (permissions, insecure origin) | "Couldn't copy. Select the link and copy it." for 2.2s. |
| Long link | long value | Field scrolls its text horizontally; nothing wraps (story LongLink). |
Types
CopyLinkCopy (labels): field (input name, "Invite link"), copy (button, "Copy link"), copied, failed.
Usage
<CopyLinkField value="trndr.app/join/hushup" onCopied={() => track('invite_link_copied')} />// Inside the Invitations tab callout
<CalloutCard tone="lime" title="Invite link" sub="Share anywhere. Creators land on your brand page in TRNDR and apply.">
<CopyLinkField value="trndr.app/join/hushup" labels={{ copy: 'Copy' }} />
</CalloutCard>// Another kind of link: rename the field and messages
<CopyLinkField
value="trndr.app/c/winter-glow"
labels={{ field: 'Challenge link', copied: 'Challenge link copied' }}
/>Where it appears
- Brand › Home › "Grow your program" callout (beside "Find creators"). Screen: Home.
- Brand › Creators › Invitations tab › "Invite link" callout. Screen: Creators · Invitations.
Guidelines
Do
- Show the link without the protocol, as the mock does ("trndr.app/join/hushup").
- Rename
fieldandcopiedwhen the link is not an invite. - Use
onCopiedfor a toast only if the page has no other feedback; the live line already confirms.
Don't
- Don't make the field editable or add a second copy icon.
- Don't put it in a table row; use a
RowActions"Copy link" action there.
RTL and Arabic
- The input stays
dir="ltr"(a URL); the button sits on the left in Arabic. - Arabic copy: "لينك الدعوة", "انسخ اللينك", "اتنسخ لينك الدعوة", "معرفناش ننسخ. علّم على اللينك وانسخه.".
Tokens
--line, --soft, --ink-2 (field), --rasp (focus border), --focus-ring-field, --min-touch-target; ink button tokens.
Accessibility
- The input is named by
aria-label("Invite link") and is read-only; focusing selects the whole link for manual copy. - The result is announced in an
aria-live="polite"span, so screen-reader users hear "Invite link copied" without focus moving. - The failure message tells keyboard users how to copy by hand.
- The input is 42px tall on desktop and grows to
--min-touch-target(44px) on touch tiers (≤1024px).
Found in the source
- ARIA attributes set:
aria-label,aria-live.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
CalloutCard: the tinted card it usually sits in.RowActions(copyLinkpreset): copy a link from a table row.Toast: app-level confirmation viaonCopied.
See also: Button · useLanguage · CheckList · DrawerHead · ProgressRow
Source
src/blocks/shared/CopyLinkField.tsx (line 26) on GitHub.