Rost

← All components

component

Disclosure

A line that opens to show more, for things most people won't need.

In code Contract: review Guidance: proposed Contract on GitHub Figma 705:142 As markdown
The SVG

The whole file, for the few who want it.

Default
The SVG

The whole file, for the few who want it.

Open

Hover, press or tab to one to see the other 2 states.

Install

npx github:Runceanu/rost add disclosure

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

When to use

  • The long version

    A component's full source, a whole contract, the raw SVG. There for the few who want it, out of the way for the rest.

When not to use

  • Things everyone needs

    Hiding what most people came for. If they'd open it every time, show it.

  • Switching views

    Choosing between views of the same thing. That's Tabs.

    Use Tabs

Behaviour

A line with a chevron. Clicking it, or Enter and Space on it, opens what's under it and turns the chevron down. It's a <details>, so it works before any script runs and the browser's find-in-page opens it when there's a match inside.

Accessibility

  • Element

    <details> and <summary>. The browser says whether it's open.

  • Keyboard

    Tab to the summary, Enter or Space to open and close.

  • Icon

    aria-hidden. The open state is said by the element, not by the chevron.

Content

A few words saying what's inside, as a noun ("The SVG", "Source"). Not "Click to show".

Props

PropTypeValuesDefault
summary slot
open boolean false
children slot

States: Default, Hover, Focus, Open.

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

displayblock

summary

  • gap 4px spacing/gap/2xsmall
  • border-radius 4px spacing/radius/xsmall
  • font-family 'General Sans Variable' font-family/base
  • font-size 14px typography/paragraph/font-size
  • line-height 20px typography/paragraph/line-height
  • font-weight 500 typography/paragraph/font-weight/medium
  • color #d3d9d5 non-interactive/foreground/secondary
  • transition-duration 150ms motion/duration/fast
  • transition-timing-function ease motion/easing/standard

displayflex · widthfit-content · align-itemscenter · list-stylenone · cursorpointer · transition-propertycolor

icon

  • transition-duration 150ms motion/duration/fast
  • transition-timing-function ease motion/easing/standard

flex-shrink0 · transition-propertytransform

panel

  • padding-top 8px spacing/gap/small

Only in some variants

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

Open

  • icon.transform rotate(90deg) no token yet

All but Focus

  • summary.color #ededed non-interactive/foreground/primary

Focus

  • summary.outline-color #b6ffda actions/primary/focus/focus-ring
  • summary.outline-offset 2px no token yet
  • summary.outline-style solid no token yet
  • summary.outline-width 2px spacing/outline/medium