Todae

Todae

Disclosure

Disclosure.Root is a native <details> and Disclosure.Summary a native <summary>, styled from the disclosure contract tokens. The browser handles the keyboard, the expanded state that a screen reader announces, and the open marker. Browsers that support it also open a closed disclosure when find-in-page matches its content.

On this page
import { Disclosure } from '@tounsoo/todae/disclosure';
import { Text } from '@tounsoo/todae/text';

export default function DisclosureSingle() {
  return (
    <Disclosure.Root>
      <Disclosure.Summary>Shipping details</Disclosure.Summary>
      <Text.Root>Orders ship within two business days.</Text.Root>
    </Disclosure.Root>
  );
}
Shipping details

Orders ship within two business days.

Server Components can import it from @tounsoo/todae/disclosure.

Accordion

Give disclosures the same name and the browser keeps at most one of them open: an exclusive accordion. Named disclosures get a divider from disclosure.border. Use open to start one open, and onToggle to follow changes.

import { Disclosure } from '@tounsoo/todae/disclosure';
import { Text } from '@tounsoo/todae/text';

export default function DisclosureAccordion() {
  return (
    <div>
      <Disclosure.Root name="faq" open>
        <Disclosure.Summary>What is Todae?</Disclosure.Summary>
        <Text.Root>A low-level base for a company design system.</Text.Root>
      </Disclosure.Root>
      <Disclosure.Root name="faq">
        <Disclosure.Summary>Does it ship icons?</Disclosure.Summary>
        <Text.Root>No. Pass your own icons as children, so your icon set stays yours.</Text.Root>
      </Disclosure.Root>
      <Disclosure.Root name="faq">
        <Disclosure.Summary>Which browsers?</Disclosure.Summary>
        <Text.Root>Any browser with the native features on the platform page.</Text.Root>
      </Disclosure.Root>
    </div>
  );
}
What is Todae?

A low-level base for a company design system.

Does it ship icons?

No. Pass your own icons as children, so your icon set stays yours.

Which browsers?

Any browser with the native features on the platform page.

The marker is the browser's own and turns as the disclosure opens; to draw an icon instead, see Icons below. Content fades in over disclosure.motion.duration.enter and out over disclosure.motion.duration.exit, and does not move when the user prefers reduced motion.

In Chrome the content also grows to its height as it opens and shrinks as it closes, over the same tokens, so what follows slides into place; other browsers show the fade alone, and Firefox hides the content at once as it closes, since it can't yet keep hidden content drawn while it fades. Under reduced motion the height changes at once.

Icons

With a chevron glyph from a GlyphsProvider, the summary draws that icon in place of the browser's marker. Draw it pointing down: a closed disclosure turns it toward the text. Disclosure from the @tounsoo/todae/disclosure server entry reads no provider and keeps the browser's marker.

import { ChevronDown } from 'lucide-react';

<GlyphsProvider glyphs={{ chevron: <ChevronDown /> }}>
  <Disclosure.Root>
    <Disclosure.Summary>Shipping</Disclosure.Summary>
    …
  </Disclosure.Root>
</GlyphsProvider>

Accessible composition

Todae handles: A focus ring on the summary, the marker's color, a chevron glyph hidden from screen readers, a divider between named disclosures, and a marker that doesn't turn when the user prefers reduced motion, while the content still fades. When code closes a disclosure, such as an open prop turning false, while its content holds focus, the summary takes focus in Chromium, Firefox and WebKit, so focus doesn't fall to the page; the server entry's summary doesn't. The rest is the browser's: the toggle on the summary, its expanded state, Enter and Space, closing the others in a named group, and, where the browser supports it, opening a closed disclosure for find-in-page.

You supply: A Disclosure.Summary as the first child of each Disclosure.Root, with text that names what opens. If you put an icon of your own in the summary instead of a chevron glyph, give it aria-hidden="true"; the open state is already announced.

Watch for: A role, an aria-expanded or a click handler that toggles open on the summary: the browser already does each, and doing it again fights it. Buttons or links inside the summary, which is itself the control.

When to use

When: Optional detail the reader can open in place: FAQs, advanced settings, long explanations. Several of them with one open at a time → an accordion with a shared name.

When not: Views of the same object, one shown at a time with arrow keys → Tabs. A choice or a form that blocks the task → Dialog. Content most readers need → show it.

Props

Disclosure.Root props
NameTypeDescription
namestring

Disclosures with the same name form an exclusive accordion: the browser keeps at most one open, and a rule divides them.

openboolean

Whether the disclosure is open. A change to the prop opens or closes it, and between changes the person's own toggles stand; follow them with onToggle.

onToggle(event: React.ToggleEvent<HTMLDetailsElement>) => void

Called after the disclosure opens or closes.

childrenReact.ReactNode

A Disclosure.Summary first, then the content it shows and hides.

Disclosure.Summary props
NameTypeDescription
childrenReact.ReactNode

The toggle text. It names the disclosure for screen readers.