Skip to main content

Bubble

A chat message in a bubble that shows who sent it.

In Accessible first

See it live​

Start Storybook to see it live: npm run storybook

When to use it​

In Accessible first: A back-and-forth conversation, in large text with strong contrast. Not for comments or long text.

  • Use it when: A back-and-forth conversation between people or with an assistant.
  • Not when: Comments on a page or long text (use a message or a card).

Instead:

  • Message: One message with its author and time, without the bubble shape.

Words​

  • Use common words. Explain any term you must use.
  • One idea per sentence. Put the action first.
  • Never blame the person.
  • Use: Continue, Change, Start, You. Avoid: Invalid, Utilise, Submit, Error code.

The labels components use, from the voice tokens:

  • content.action.commit: Continue
  • content.action.cancel: Go back
  • content.action.destroy: Delete
  • content.action.retry: Try again
  • content.action.empty-action: Start a new application

See Voice and tone for the whole voice.

Use it in code​

npx open-ds add bubble

The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.

Tokens it reads​

Bubble reads 11 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 Bubble's tokens to change Bubble alone.

Changes with theme

Accessible 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.

PartIts token and the semantic it aliasesValue
Them
Fill
Changes with theme
component.bubble.them.backgroundcolor.surface.sunkenvar(--bubble-them-background)Lightgray.light.100:#EDEDEDDarkgray.dark.100:#222222
Text
Changes with theme
component.bubble.them.labelcolor.text.primaryvar(--bubble-them-label)Lightgray.light.900:#141414Darkgray.dark.900:#F7F7F7
Me
Fill
Changes with theme
component.bubble.me.backgroundcolor.action.primaryvar(--bubble-me-background)Lightblue.light.600:#0B4FC0Darkblue.dark.600:#8AB4F8
Text
Changes with theme
component.bubble.me.labelcolor.text.on-actionvar(--bubble-me-label)Lightgray.light.0:#FFFFFFDarkgray.light.900:#141414
Bubble
Gapcomponent.bubble.gapspace.gap.tightvar(--bubble-gap)space.12:0.75rem
Text sizecomponent.bubble.font-sizetype.caption.font-sizevar(--bubble-font-size)font.size.16:1rem
Text
Changes with theme
component.bubble.labelcolor.text.mutedvar(--bubble-label)Lightgray.light.500:#595959Darkgray.dark.500:#949494
Body
Cornercomponent.bubble.body.radiusradius.containervar(--bubble-body-radius)radius.8:0.5rem
Padding, left and rightcomponent.bubble.body.padding-xcomponent-spacing-map.x3var(--bubble-body-padding-x)space.20:1.25rem
Padding, top and bottomcomponent.bubble.body.padding-ycomponent-spacing-map.x2var(--bubble-body-padding-y)space.8:0.5rem
Text sizecomponent.bubble.body.font-sizetype.body.font-sizevar(--bubble-body-font-size)font.size.19:1.1875rem