Skip to main content

Attachment

A file attached to a message, with its name, type and size.

In Dense data

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Dense data: A file added to a note on an alert, with its name, type and size. Not for file uploads in forms.

  • 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​

  • Lead with the object, then the state: "Alert 2041 contained."
  • Use numbers, not words for numbers.
  • One verb per button. No "please", no exclamation marks.
  • Use: Investigate, Filter, Assign, Escalated, Resolved. Avoid: Oops, Awesome, Please, Simply.

The labels components use, from the voice tokens:

  • content.action.commit: Save
  • content.action.cancel: Cancel
  • content.action.destroy: Delete
  • content.action.retry: Retry
  • content.action.empty-action: Change filters

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.

Changes with theme

Dense data 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.

PartIts token and the semantic it aliasesValue
Attachment
Gapcomponent.attachment.gapcomponent-spacing-map.x3var(--attachment-gap)space.12:0.75rem
Cornercomponent.attachment.radiusradius.controlvar(--attachment-radius)radius.2:0.125rem
Fill
Changes with theme
component.attachment.backgroundcolor.surface.canvasvar(--attachment-background)Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117
Padding, left and rightcomponent.attachment.padding-xcomponent-spacing-map.x3var(--attachment-padding-x)space.12:0.75rem
Padding, top and bottomcomponent.attachment.padding-ycomponent-spacing-map.x2var(--attachment-padding-y)space.8:0.5rem
Text sizecomponent.attachment.font-sizetype.body.font-sizevar(--attachment-font-size)font.size.14:0.875rem
Background hover
Changes with theme
on hover
component.attachment.background-hovercolor.surface.sunkenvar(--attachment-background-hover)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
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)Lightviolet.light.600:#4B3FD9Darkviolet.dark.600:#A9A3F6
Focus ring offset focus
Changes with theme
on focus
component.attachment.focus-ring-offset-focuscolor.surface.canvasvar(--attachment-focus-ring-offset-focus)Lightslate.light.50:#F7F8FADarkslate.dark.0:#0D1117
Sizecomponent.attachment.sizesize.control.defaultvar(--attachment-size)size.32:2rem
Radius 2component.attachment.radius-2radius.badgevar(--attachment-radius-2)radius.0:0rem
Background 2
Changes with theme
component.attachment.background-2color.surface.sunkenvar(--attachment-background-2)Lightslate.light.100:#EEF1F5Darkslate.dark.100:#262D38
Icon sizecomponent.attachment.icon-sizesize.iconvar(--attachment-icon-size)size.16:1rem
Text
Changes with theme
component.attachment.labelcolor.text.mutedvar(--attachment-label)Lightslate.light.600:#535D6DDarkslate.dark.400:#969FAD
Weightcomponent.attachment.font-weighttype.label.font-weightvar(--attachment-font-weight)font.weight.500:500
Font size 2component.attachment.font-size-2type.caption.font-sizevar(--attachment-font-size-2)font.size.12:0.75rem
From the system
Edge
Changes with theme
color.border.default
straight from the system, through --border
Lightslate.light.200 · #DDE2EADarkslate.dark.100 · #262D38