Attachment
A file attached to a message, with its name, type and size.
Left out of Content first Readers need sections, navigation and little else. Files attach to messages, and Content first carries no conversations: people read from start to end. Use instead: Button
See it live
npm run storybookWhen to use it
- Use it when: A conversation that shares files people may open or download.
- Not when: Uploading files in a form (a file input), or images meant to be seen inline.
Instead:
- Message: The message the file belongs to.
Words
- Write to one person: "you", not "users".
- Short sentences with room to breathe.
- Explain why before asking for anything.
- Use: Read, Save for later, You, Next issue. Avoid: Click here, Submit, Users, Content.
The labels components use, from the voice tokens:
content.action.commit: Savecontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Browse guides
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- The link names the file and its type and size, not just Download. undefined
Use it in code
npx open-ds add attachment
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Attachment reads 17 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Attachment's tokens to change Attachment alone.
Content first decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Attachment | ||
| Gap | component.attachment.gapcomponent-spacing-map.x3var(--attachment-gap) | space.20:1.25rem |
| Corner | component.attachment.radiusradius.controlvar(--attachment-radius) | radius.8:0.5rem |
| Fill Changes with theme | component.attachment.backgroundcolor.surface.canvasvar(--attachment-background) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Padding, left and right | component.attachment.padding-xcomponent-spacing-map.x3var(--attachment-padding-x) | space.20:1.25rem |
| Padding, top and bottom | component.attachment.padding-ycomponent-spacing-map.x2var(--attachment-padding-y) | space.8:0.5rem |
| Text size | component.attachment.font-sizetype.body.font-sizevar(--attachment-font-size) | font.size.18:1.125rem |
| Background hover Changes with theme on hover | component.attachment.background-hovercolor.surface.sunkenvar(--attachment-background-hover) | Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24 |
| Focus on focus | component.attachment.focusborder-width.focusvar(--attachment-focus) | border-width.2:2px |
| Focus ring focus Changes with theme on focus | component.attachment.focus-ring-focuscolor.border.focusvar(--attachment-focus-ring-focus) | Lightnavy.light.600:#1E3A5FDarknavy.dark.600:#8FA6C4 |
| Focus ring offset focus Changes with theme on focus | component.attachment.focus-ring-offset-focuscolor.surface.canvasvar(--attachment-focus-ring-offset-focus) | Lightstone.light.50:#FFFDF8Darkstone.dark.0:#14110D |
| Size | component.attachment.sizesize.control.defaultvar(--attachment-size) | size.48:3rem |
| Radius 2 | component.attachment.radius-2radius.badgevar(--attachment-radius-2) | radius.999:9999px |
| Background 2 Changes with theme | component.attachment.background-2color.surface.sunkenvar(--attachment-background-2) | Lightstone.light.100:#F6F2EADarkstone.dark.100:#2E2A24 |
| Icon size | component.attachment.icon-sizesize.iconvar(--attachment-icon-size) | size.16:1rem |
| Text Changes with theme | component.attachment.labelcolor.text.mutedvar(--attachment-label) | Lightstone.light.600:#61594DDarkstone.dark.400:#A39A8B |
| Weight | component.attachment.font-weighttype.label.font-weightvar(--attachment-font-weight) | font.weight.600:600 |
| Font size 2 | component.attachment.font-size-2type.caption.font-sizevar(--attachment-font-size-2) | font.size.14:0.875rem |
| From the system | ||
| Edge Changes with theme | color.border.default straight from the system, through --border | Lightstone.light.200 · #E4DDD0Darkstone.dark.100 · #2E2A24 |