Skip to Content

Collapse

A brandless disclosure component built on the native <details> and <summary> elements. Open/close behavior is handled entirely by the browser — no JavaScript required.

Demo

What is Froglet UI?

Froglet is a brandless, accessible React component library.

Usage

import { Collapse, CollapseSummary } from '@froglet/ui' <Collapse> <CollapseSummary>What is Froglet?</CollapseSummary> <p>Froglet is a brandless React component library.</p> </Collapse> // Open by default <Collapse open> <CollapseSummary>Always starts open</CollapseSummary> <p>Content visible on initial render.</p> </Collapse>

Props

Collapse

PropTypeDescription
openbooleanWhether the disclosure starts open.
childrenReactNodeContent. Include a <CollapseSummary> as the first child.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLDetailsElement>Forwarded to the underlying <details>.
...propsHTMLAttributes<HTMLDetailsElement>All standard details attributes.

CollapseSummary

PropTypeDescription
childrenReactNodeTrigger text or content.
classNamestringAdditional CSS classes.
refReact.Ref<HTMLElement>Forwarded to the underlying <summary>.
...propsHTMLAttributes<HTMLElement>All standard element attributes.

CSS Custom Properties

Collapse (.collapse)

TokenDefaultDescription
--collapse-border-width0Border width.
--collapse-border-stylesolidBorder style.
--collapse-border-colorBorder color. No border when unset.
--collapse-border-radius0Corner rounding.
--collapse-padding0Outer spacing.
--collapse-background-colortransparentBackground fill.

CollapseSummary (.collapse-summary)

TokenDefaultDescription
--collapse-summary-padding0Trigger padding.
--collapse-summary-font-sizeinheritFont size.
--collapse-summary-font-weightinheritFont weight.
--collapse-summary-text-colorText color. Inherits when unset.
--collapse-summary-background-colortransparentTrigger background.
--collapse-summary-background-color-hovertransparentBackground on hover.
--collapse-summary-outline-color-focuscurrentColorFocus ring color.
--collapse-summary-marker-content"▶"Marker character (closed).
--collapse-summary-marker-transformrotate(0deg)Marker transform (closed).
--collapse-summary-marker-transform-openrotate(90deg)Marker transform (open).

Accessibility

  • <details> and <summary> are native HTML disclosure elements — no ARIA attributes needed.
  • The browser handles aria-expanded on <summary> automatically.
  • Enter or Space on a focused <summary> toggles the panel.
Last updated on