Rost

← All components

component

Popover

A small plate that opens over the page with more about something, and closes when you click away. Card's grey, with an edge and the floating shadow.

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

Install

npx github:Runceanu/rost add popover

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

When to use

  • More about something

    How a figure was worked out, the details of a payment, a few settings for one column.

When not to use

Behaviour

It's the browser's popover: a button with popovertarget opens and closes it, Esc and a click outside close it, and only one is open at a time. It adds no type of its own, like Card. It opens under its button, lined up with its start, and moves above it or the other way along when it doesn't fit: CSS anchor positioning, with the button as the anchor. A browser without anchor positioning puts it at the top left of the window, so check the browsers your app supports.

Accessibility

  • Element

    A <div popover>, opened by a <button popovertarget>. The browser links the two for screen readers.

  • Name

    Give it an aria-label or a heading inside when it's more than a sentence.

  • Keyboard

    Enter or Space on its button opens it. Esc closes it and puts focus back on the button.

  • Colour

    Text inside keeps the page's tokens and their contrast on the #171717 plate.

Props

PropTypeValuesDefault
id string
children slot
fit boolean false

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
  • margin 0px spacing/gap/none
  • margin-block-start 8px spacing/gap/small

bordernone · backgroundtransparent · overflowvisible · colorinherit · insetauto · position-areablock-end span-inline-end · position-try-fallbacksflip-block, flip-inline

panel

  • max-width 280px no token yet
  • padding 16px spacing/gap/medium
  • border-radius 16px spacing/radius/large
  • background #171717 popover/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 popover/edge
  • box-shadow 0px 16px 24px 0px rgba(0, 0, 0, 0.16) shadow/floating

displayblock · outline-stylesolid

Only in some variants

These don't change: they're just set in some variants and not others.

Every variant

  • panel.max-width none Figma frame size