Rost

← All components

component

Dialog

A question or a short task that stops everything else until it's answered. A grey plate over the page with a title, a few words and its buttons.

In code Contract: review Guidance: proposed Contract on GitHub Figma 738:35 As markdown

Try it

Every variant

Default

Install

npx github:Runceanu/rost add dialog

It lands in src/rost/dialog/, with what it needs and its contract. Install has the rest.

When to use

  • Before something you can't undo

    Deleting an invoice, closing a year. Say what will happen in the title, and put it on the main button too.

  • A short task

    Two or three fields that belong to the screen behind, like renaming a client.

When not to use

Behaviour

It opens as a modal: focus moves into it, the page behind can't be reached, and Esc closes it. That's the browser's <dialog> doing the work, not mine. The plate is Card's grey with an edge and the floating shadow. Behind it, the page dims to 72% of its own colour: the contract styles the browser's ::backdrop as a part of its own.

Accessibility

  • Element

    <dialog> opened with showModal(), labelled by its title (aria-labelledby).

  • Name

    The title.

  • Keyboard

    Focus starts on the first thing you can press in it and stays inside until it closes. Esc closes it. Put the safe choice first, so a stray Enter doesn't delete anything.

  • Focus

    When it closes, focus goes back to what opened it. The browser does that too.

  • Colour

    The title is 14:1 and the words 11:1 on the plate, in dark.

Content

The title asks the question ("Delete this invoice?"). The buttons answer it with verbs ("Keep it", "Delete"), never "Yes" and "No".

Props

PropTypeValuesDefault
open boolean false
title slot
children slot
actions slot

Values

Straight from the contract. Each value sits next to its token, because six tokens here all come out as #3a3a3a and the colour alone can't tell you which one is right.

Never changes

root

  • padding 0px spacing/gap/none

bordernone · backgroundtransparent · overflowvisible · max-widthnone · marginauto · colorinherit

backdrop

  • background #060805 dialog/backdrop
  • opacity 0.72 opacity/hard

panel

  • gap 16px spacing/gap/medium
  • width 400px no token yet
  • padding 24px spacing/gap/large
  • border-radius 24px spacing/radius/xlarge
  • background #171717 dialog/background
  • outline-width 1px spacing/outline/small
  • outline-offset calc(-1 * var(--spacing-outline-small)) on purpose: Composed from a token: the edge sits inside the plate.
  • outline-color #3a3a3a dialog/edge
  • box-shadow 0px 16px 24px 0px rgba(0, 0, 0, 0.16) shadow/floating

displayflex · flex-directioncolumn · max-widthcalc(100vw - 32px) · outline-stylesolid

title

  • font-family 'General Sans Variable' font-family/base
  • font-weight 500 typography/title/font-weight/medium
  • font-size 24px typography/title/font-size
  • line-height 32px typography/title/line-height
  • letter-spacing 0px typography/title/letter-spacing
  • color #ededed dialog/title

body

  • font-family 'General Sans Variable' font-family/base
  • font-weight 400 typography/paragraph/font-weight/regular
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • letter-spacing 0px typography/paragraph/letter-spacing
  • color #d3d9d5 dialog/body

actions

  • gap 8px spacing/gap/small

displayflex · justify-contentflex-end