Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

OrgExpander

  • Stable
  • WCAG 2.2 evidence
  • RTL

The button that shows or hides a manager's direct reports in an organisation chart: a pill with a plus or minus and the number of reports. Built on React Aria Button: Enter and Space press it, disabled leaves the tab order, keyboard focus shows the focus ring (WCAG 2.1.1, 2.4.7, 4.1.2). The pill is 22 px tall; a transparent extension makes the pointer target 24 px (2.5.8). Colour does not carry the state: the icon (plus or minus) and the name (aria-expanded, or Expand and Collapse in the name) do (1.4.1). Consumer duties: name it after what it opens, include the count in the name, and, when you also set aria-controls, point it at the group of reports. Inside an OrgChart, OrgNode renders and wires this button for you.

import { OrgExpander } from "@nexera-ui/react";
Loading example…
6
examples
23
props
3
live controls
1
platform
8
WCAG criteria
0
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
isExpanded
defaultExpanded
isDisabled
Generated code
import { OrgExpander } from "@nexera-ui/react";

<OrgExpander />

Examples 5

The same examples as Storybook, rendered live. Open Code to copy one.

Controlled

Controlled by a parent that shows the reports. The name is fixed ("Sara Malik's reports (3)") and aria-expanded carries the state, which is the disclosure pattern.

Loading example…

Action name

The name can instead state the action and change with the state ("Expand..." then "Collapse..."). Then aria-expanded is left off, because the name already carries the state. This is what OrgNode uses inside an OrgChart.

Loading example…

Disabled

Disabled: leaves the tab order and ignores presses.

Loading example…

Long count

Long counts: the pill grows with its content and never truncates (whitespace-nowrap, hugging width).

Loading example…

Right to left

Right-to-left: the icon and the count swap sides, and the number keeps its digits.

Loading example…

Props 23

Press "Try it" on a card to load that prop into the playground.

23 props shown

countNexera
string | number

Number of reports the branch holds, shown next to the plus or minus. Keep it in the accessible name too, so the visible text is part of the name (WCAG 2.5.3). Omit it to show the icon alone.

Default –
isExpandedNexera
boolean

Whether the branch is expanded. Controlled: pair it with onExpandedChange.

Default –
defaultExpandedNexera
boolean

Whether the branch is expanded at first render (uncontrolled).

Default false
onExpandedChangeNexera
(isExpanded: boolean) => void

Called with the new state when the button is pressed (pointer, Enter or Space).

Default –
classNameNexera
string

Extra classes, merged last so they win over the defaults.

Default –
styleNexera
CSSProperties

Inline style.

Default –
aria-labelNexera
string

Accessible name that stays the same in both states ("Jane Doe's reports (4)"); aria-expanded carries the state. Translate it.

Default –
aria-labelledbyNexera
string

Id(s) of the element(s) that name the button; wins over aria-label. Id(s) of the element(s) that name the button (for example the manager's name); aria-expanded carries the state.

Default –
expandLabelNexera
string

Accessible name while collapsed, for example "Expand Jane Doe's reports (4)". Translate it.

Default –
collapseLabelNexera
string

Accessible name while expanded, for example "Collapse Jane Doe's reports (4)". Translate it.

Default –
isDisabledReact Aria
boolean

Whether the button is disabled.

Default –
onPressReact Aria
(e: PressEvent) => void

Handler that is called when the press is released over the target.

Default –
onPressStartReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction starts.

Default –
onPressEndReact Aria
(e: PressEvent) => void

Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target.

Default –
onPressChangeReact Aria
(isPressed: boolean) => void

Handler that is called when the press state changes.

Default –
onPressUpReact Aria
(e: PressEvent) => void

Handler that is called when a press is released over the target, regardless of whether it started on the target or not.

Default –
autoFocusReact Aria
boolean

Whether the element should receive focus on render.

Default –
typeReact Aria
"button" | "submit" | "reset"

The behavior of the button when used in an HTML form.

Default 'button'
formReact Aria
string

The <form> element to associate the button with. The value of this attribute must be the id of a <form> in the same document. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#form).

Default –
nameReact Aria
string

Submitted as a pair with the button's value as part of the form data.

Default –
valueReact Aria
string

The value associated with the button's name when it's submitted with the form data.

Default –
idReact Aria
string

The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).

Default –
aria-describedbyReact Aria
string

Identifies the element (or elements) that describes the object.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

6 direct · 2 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.2Meaningful SequenceLevel A · supporting test
  • 1.4.1Use of ColorLevel A · tested directly
  • 2.1.1KeyboardLevel A · tested directly
  • 2.4.7Focus VisibleLevel AA · tested directly
  • 2.5.3Label in NameLevel A · tested directly
  • 2.5.8Target Size (Minimum)Level AA · supporting test
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

  • data-disabled
  • data-hovered
  • data-pressed
Usage
<OrgExpander className="data-disabled:opacity-90 shadow-sm" />

Used in blocks

No block uses OrgExpander yet.

Related components