component
Disclosure
A line that opens to show more, for things most people won't need.
The SVG
The whole file, for the few who want it.
DefaultThe SVG
The whole file, for the few who want it.
OpenHover, press or tab to one to see the other 2 states.
import { Disclosure } from 'rost/components/disclosure/Disclosure'
<Disclosure summary="The SVG">
<Code block>{svg}</Code>
</Disclosure> src/components/disclosure/Disclosure.tsx
import type { DetailsHTMLAttributes, ReactNode } from 'react'
import { Icon } from '../icon/Icon'
import './disclosure.css'
export interface DisclosureProps extends Omit<DetailsHTMLAttributes<HTMLDetailsElement>, 'summary'> {
/** What's inside, in a few words. Always shown. */
readonly summary: ReactNode
/** Starts open. */
readonly open?: boolean
/** What opens. */
readonly children?: ReactNode
}
const b = 'rost-disclosure'
/** A line that opens to show more. Built from contracts/disclosure.contract.yaml. */
export function Disclosure({ summary, open, className, children, ...rest }: DisclosureProps) {
return (
<details className={[b, className].filter(Boolean).join(' ')} open={open} {...rest}>
<summary className={`${b}__summary`}><Icon name="chevron-right" size="small" className={`${b}__icon`} />{summary}</summary>
<div className={`${b}__panel`}>{children}</div>
</details>
)
}
The source for everything on this page: contracts/disclosure.contract.yaml (opens in a new tab). The CSS, the docs and the checks in each app are built from it.
# yaml-language-server: $schema=../schema/component-contract.schema.json
schemaVersion: 2
id: disclosure
name: Disclosure
kind: component
status: review
summary: A line that opens to show more, for things most people won't need.
category: display
related: [ code, text ]
source:
tool: figma
fileKey: 1Zy0wiWKXQAvsfDBX3KR0d
nodeId: "705:142"
url: https://www.figma.com/design/1Zy0wiWKXQAvsfDBX3KR0d/UI-Kit-v01?node-id=705-142
extractedAt: "2026-11-04"
extractedBy: hand
frozenAt: "2026-11-04"
props:
summary: { type: slot, notes: "What's inside, in a few words. Always shown." }
open:
type: boolean
default: false
notes: Starts open. After that the browser keeps track.
children: { type: slot, notes: What opens. }
stateSelectors:
Hover: ":has(> .rost-disclosure__summary:hover)"
Focus: ":has(> .rost-disclosure__summary:focus-visible)"
Open: "[open]"
states: [ Default, Hover, Focus, Open ]
elements:
root:
notes: "A `<details>`, so it opens without any script."
styles:
display: { value: block, assert: false }
summary:
notes: "The `<summary>`: the chevron, then the words."
styles:
display: { value: flex, assert: false, notes: "A row, not inline: inline it sits on a line of text and takes the room under the baseline." }
width: { value: fit-content, assert: false, notes: "As wide as the chevron and the words, so the click area is too." }
align-items: { value: center }
gap: { token: spacing/gap/2xsmall, value: 4px }
list-style: { value: none, assert: false, notes: "The browser's triangle goes. The chevron replaces it." }
cursor: { value: pointer, assert: false }
border-radius: { token: spacing/radius/xsmall, value: 4px }
font-family: { token: font-family/base, value: "'General Sans Variable'" }
font-size: { token: typography/paragraph/font-size, value: 14px }
line-height: { token: typography/paragraph/line-height, value: 20px }
font-weight: { token: typography/paragraph/font-weight/medium, value: "500" }
color: { token: non-interactive/foreground/secondary, value: "#d3d9d5" }
transition-property: { value: color, assert: false }
transition-duration: { token: motion/duration/fast, value: 150ms }
transition-timing-function: { token: motion/easing/standard, value: ease }
icon:
notes: "Icon's `chevron-right`, turning down when it's open."
styles:
flex-shrink: { value: "0", assert: false }
transition-property: { value: transform, assert: false }
transition-duration: { token: motion/duration/fast, value: 150ms }
transition-timing-function: { token: motion/easing/standard, value: ease }
panel:
notes: What opens, under the summary.
styles:
padding-top: { token: spacing/gap/small, value: 8px }
variants:
- when: { state: Hover }
figmaNode: "705:122"
elements:
summary:
color: { token: non-interactive/foreground/primary, value: "#ededed" }
- when: { state: Focus }
figmaNode: "705:128"
elements:
summary:
outline-style: { value: solid }
outline-width: { token: spacing/outline/medium, value: 2px }
outline-color: { token: actions/primary/focus/focus-ring, value: "#b6ffda" }
outline-offset: { value: 2px }
- when: { state: Open }
figmaNode: "705:135"
elements:
summary:
color: { token: non-interactive/foreground/primary, value: "#ededed" }
icon:
transform: { value: rotate(90deg) }
guidance:
status: proposed
use:
- title: The long version
text: "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."
show: state=Default
avoid:
- title: Things everyone needs
text: Hiding what most people came for. If they'd open it every time, show it.
- title: Switching views
text: "Choosing between views of the same thing. That's **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".
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.
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
| Prop | Type | Values | Default |
|---|---|---|---|
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
-
gap4pxspacing/gap/2xsmall -
border-radius4pxspacing/radius/xsmall -
font-family'General Sans Variable'font-family/base -
font-size14pxtypography/paragraph/font-size -
line-height20pxtypography/paragraph/line-height -
font-weight500typography/paragraph/font-weight/medium -
color#d3d9d5non-interactive/foreground/secondary -
transition-duration150msmotion/duration/fast -
transition-timing-functioneasemotion/easing/standard
displayflex · widthfit-content · align-itemscenter · list-stylenone · cursorpointer · transition-propertycolor
icon
-
transition-duration150msmotion/duration/fast -
transition-timing-functioneasemotion/easing/standard
flex-shrink0 · transition-propertytransform
panel
-
padding-top8pxspacing/gap/small
Only in some variants
These don't change: they're just set in some variants and not others.
Open
-
icon.transformrotate(90deg)no token yet
All but Focus
-
summary.color#ededednon-interactive/foreground/primary
Focus
-
summary.outline-color#b6ffdaactions/primary/focus/focus-ring -
summary.outline-offset2pxno token yet -
summary.outline-stylesolidno token yet -
summary.outline-width2pxspacing/outline/medium