DisclosureGroup
A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion. It supports both single and multiple expanded items.
install | yarn add react-aria-components |
---|---|
version | 1.4.1 |
usage | import {DisclosureGroup} from 'react-aria-components' |
Example#
import {Button, Disclosure, DisclosureGroup, DisclosurePanel, Heading} from 'react-aria-components';
<DisclosureGroup defaultExpandedKeys={['personal']}>
<Disclosure id="personal">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal Information
</Button>
</Heading>
<DisclosurePanel>
<p>Personal information form here.</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="billing">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Billing Address
</Button>
</Heading>
<DisclosurePanel>
<p>Billing address form here.</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
import {
Button,
Disclosure,
DisclosureGroup,
DisclosurePanel,
Heading
} from 'react-aria-components';
<DisclosureGroup defaultExpandedKeys={['personal']}>
<Disclosure id="personal">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal Information
</Button>
</Heading>
<DisclosurePanel>
<p>Personal information form here.</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="billing">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Billing Address
</Button>
</Heading>
<DisclosurePanel>
<p>Billing address form here.</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
import {
Button,
Disclosure,
DisclosureGroup,
DisclosurePanel,
Heading
} from 'react-aria-components';
<DisclosureGroup
defaultExpandedKeys={[
'personal'
]}
>
<Disclosure id="personal">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal
Information
</Button>
</Heading>
<DisclosurePanel>
<p>
Personal
information
form here.
</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="billing">
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Billing Address
</Button>
</Heading>
<DisclosurePanel>
<p>
Billing address
form here.
</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
Features#
Disclosure groups can be built by combing multiple disclosures built in HTML with the <details> and <summary> HTML element, but this can be difficult to style especially when adding adjacent interactive elements, like buttons, to the disclosure's heading. DisclosureGroup
helps achieve accessible disclosures implemented with the correct ARIA pattern while making custom styling easy.
- Accessible - Disclosure group is exposed to assistive technology via ARIA. Uses hidden="until-found" in supported browsers, enabling find-in-page search support and improved search engine visibility for collapsed content.
- Styleable - Disclosures include builtin states for styling such as keyboard focus, disabled, and expanded states.
Anatomy#
A disclosure group consists of a set of disclosures. Each disclosure includes a button within a heading and panel of content that is either shown or hidden. Zero or more disclosures within a group can be expanded at the same time, however, by default, only one disclosure can be expanded at a time. Users may click or touch a disclosure to expand it, or use the Tab key to navigate between disclosures and the Enter or Space key to toggle it.
import {Button, Disclosure, DisclosureGroup, DisclosurePanel, Heading} from 'react-aria-components';
<DisclosureGroup>
<Disclosure>
<Heading>
<Button />
</Heading>
<DisclosurePanel />
</Disclosure>
</DisclosureGroup>
import {
Button,
Disclosure,
DisclosureGroup,
DisclosurePanel,
Heading
} from 'react-aria-components';
<DisclosureGroup>
<Disclosure>
<Heading>
<Button />
</Heading>
<DisclosurePanel />
</Disclosure>
</DisclosureGroup>
import {
Button,
Disclosure,
DisclosureGroup,
DisclosurePanel,
Heading
} from 'react-aria-components';
<DisclosureGroup>
<Disclosure>
<Heading>
<Button />
</Heading>
<DisclosurePanel />
</Disclosure>
</DisclosureGroup>
Composed Components#
Expanded#
Default expanded#
An uncontrolled DisclosureGroup can be expanded by default using the defaultExpandedKeys
prop. The defaultExpandedKeys
must match the id
on the disclosure(s) component that you wish to expand.
import type {DisclosureProps} from 'react-aria-components';
interface MyDisclosureProps extends Omit<DisclosureProps, 'children'> {
title?: string,
children?: React.ReactNode
}
function MyDisclosure({title, children, ...props}: MyDisclosureProps) {
return (
<Disclosure {...props}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
{title}
</Button>
</Heading>
<DisclosurePanel>
<p>{children}</p>
</DisclosurePanel>
</Disclosure>
)
}
<DisclosureGroup defaultExpandedKeys={["system"]}>
<MyDisclosure id="system" title="System Requirements" >
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information" >
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
import type {DisclosureProps} from 'react-aria-components';
interface MyDisclosureProps
extends Omit<DisclosureProps, 'children'> {
title?: string;
children?: React.ReactNode;
}
function MyDisclosure(
{ title, children, ...props }: MyDisclosureProps
) {
return (
<Disclosure {...props}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
{title}
</Button>
</Heading>
<DisclosurePanel>
<p>{children}</p>
</DisclosurePanel>
</Disclosure>
);
}
<DisclosureGroup defaultExpandedKeys={['system']}>
<MyDisclosure id="system" title="System Requirements">
Details about system requirements here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
import type {DisclosureProps} from 'react-aria-components';
interface MyDisclosureProps
extends
Omit<
DisclosureProps,
'children'
> {
title?: string;
children?:
React.ReactNode;
}
function MyDisclosure(
{
title,
children,
...props
}: MyDisclosureProps
) {
return (
<Disclosure
{...props}
>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
{title}
</Button>
</Heading>
<DisclosurePanel>
<p>{children}</p>
</DisclosurePanel>
</Disclosure>
);
}
<DisclosureGroup
defaultExpandedKeys={[
'system'
]}
>
<MyDisclosure
id="system"
title="System Requirements"
>
Details about
system requirements
here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about
personal
information here
</MyDisclosure>
</DisclosureGroup>
Controlled expanded#
A controlled DisclosureGroup can be expanded and collapsed using expandedKeys
and onExpandedChange
. The expandedKeys
must match the id
on the disclosure component(s) that you wish to expand.
import {Key} from '@react-types/shared';
function ControlledExpanded() {
let [expandedKeys, setExpandedKeys] = React.useState<Set<Key>>(
new Set(['system'])
);
return (
<>
<DisclosureGroup
expandedKeys={expandedKeys}
onExpandedChange={setExpandedKeys}
>
<MyDisclosure id="system" title="System Requirements">
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information">
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
<div style={{ marginTop: '20px' }}>You have expanded: {expandedKeys}</div>
</>
);
}
import {Key} from '@react-types/shared';
function ControlledExpanded() {
let [expandedKeys, setExpandedKeys] = React.useState<
Set<Key>
>(new Set(['system']));
return (
<>
<DisclosureGroup
expandedKeys={expandedKeys}
onExpandedChange={setExpandedKeys}
>
<MyDisclosure
id="system"
title="System Requirements"
>
Details about system requirements here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
<div style={{ marginTop: '20px' }}>
You have expanded: {expandedKeys}
</div>
</>
);
}
import {Key} from '@react-types/shared';
function ControlledExpanded() {
let [
expandedKeys,
setExpandedKeys
] = React.useState<
Set<Key>
>(new Set(['system']));
return (
<>
<DisclosureGroup
expandedKeys={expandedKeys}
onExpandedChange={setExpandedKeys}
>
<MyDisclosure
id="system"
title="System Requirements"
>
Details about
system
requirements
here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about
personal
information
here
</MyDisclosure>
</DisclosureGroup>
<div
style={{
marginTop:
'20px'
}}
>
You have
expanded:{' '}
{expandedKeys}
</div>
</>
);
}
Multiple expanded#
By default, only one disclosure will be open at a time. To allow multiple disclosures to expand, use the allowsMultipleExpanded
prop.
<DisclosureGroup
defaultExpandedKeys={['system', 'personal']}
allowsMultipleExpanded
>
<MyDisclosure id="system" title="System Requirements">
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information">
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
<DisclosureGroup
defaultExpandedKeys={['system', 'personal']}
allowsMultipleExpanded
>
<MyDisclosure id="system" title="System Requirements">
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information">
Details about personal information here
</MyDisclosure>
</DisclosureGroup>
<DisclosureGroup
defaultExpandedKeys={[
'system',
'personal'
]}
allowsMultipleExpanded
>
<MyDisclosure
id="system"
title="System Requirements"
>
Details about
system requirements
here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about
personal
information here
</MyDisclosure>
</DisclosureGroup>
Disabled#
A DisclosureGroup can be disabled using the isDisabled
prop.
<DisclosureGroup isDisabled>
<MyDisclosure id="system" title="System Requirements" >
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information" >
Details about personal information here"
</MyDisclosure>
</DisclosureGroup>
<DisclosureGroup isDisabled>
<MyDisclosure id="system" title="System Requirements" >
Details about system requirements here
</MyDisclosure>
<MyDisclosure id="personal" title="Personal Information" >
Details about personal information here"
</MyDisclosure>
</DisclosureGroup>
<DisclosureGroup
isDisabled
>
<MyDisclosure
id="system"
title="System Requirements"
>
Details about
system requirements
here
</MyDisclosure>
<MyDisclosure
id="personal"
title="Personal Information"
>
Details about
personal
information here"
</MyDisclosure>
</DisclosureGroup>
Interactive elements#
In some use cases, you may want to add an interactive element, like a button, adjacent to the disclosure's heading. Please ensure that these elements are siblings of the Heading element and not children.
<DisclosureGroup>
<Disclosure id="system">
<div style={{display: 'flex', alignItems: 'center'}}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
System Requirements
</Button>
</Heading>
<Button>Click me</Button>
</div>
<DisclosurePanel>
<p>Details about system requirements here.</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="personal">
<div style={{display: 'flex', alignItems: 'center'}}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal Information
</Button>
</Heading>
<Button>Click me</Button>
</div>
<DisclosurePanel>
<p>Details about personal information here.</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
<DisclosureGroup>
<Disclosure id="system">
<div style={{display: 'flex', alignItems: 'center'}}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
System Requirements
</Button>
</Heading>
<Button>Click me</Button>
</div>
<DisclosurePanel>
<p>Details about system requirements here.</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="personal">
<div style={{display: 'flex', alignItems: 'center'}}>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal Information
</Button>
</Heading>
<Button>Click me</Button>
</div>
<DisclosurePanel>
<p>Details about personal information here.</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
<DisclosureGroup>
<Disclosure id="system">
<div
style={{
display:
'flex',
alignItems:
'center'
}}
>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
System
Requirements
</Button>
</Heading>
<Button>
Click me
</Button>
</div>
<DisclosurePanel>
<p>
Details about
system
requirements
here.
</p>
</DisclosurePanel>
</Disclosure>
<Disclosure id="personal">
<div
style={{
display:
'flex',
alignItems:
'center'
}}
>
<Heading>
<Button slot="trigger">
<svg viewBox="0 0 24 24">
<path d="m8.25 4.5 7.5 7.5-7.5 7.5" />
</svg>
Personal
Information
</Button>
</Heading>
<Button>
Click me
</Button>
</div>
<DisclosurePanel>
<p>
Details about
personal
information
here.
</p>
</DisclosurePanel>
</Disclosure>
</DisclosureGroup>
Props#
DisclosureGroup#
Name | Type | Description |
allowsMultipleExpanded | boolean | Whether multiple items can be expanded at the same time. |
isDisabled | boolean | Whether all items are disabled. |
expandedKeys | Iterable<Key> | The currently expanded keys in the group (controlled). |
defaultExpandedKeys | Iterable<Key> | The initial expanded keys in the group (uncontrolled). |
children | ReactNode | (
(values: DisclosureGroupRenderProps
& & {}
)) => ReactNode | The children of the component. A function may be provided to alter the children based on component state. |
className | string | (
(values: DisclosureGroupRenderProps
& & {}
)) => string | The CSS className for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | (
(values: DisclosureGroupRenderProps
& & {}
)) => CSSProperties | undefined | The inline style for the element. A function may be provided to compute the style based on component state. |
Disclosure#
Within a <DisclosureGroup>
, most <Disclosure>
props are set automatically. The id
prop is required to identify the disclosure within the group.
Show props
Name | Type | Description |
id | Key | An id for the disclosure when used within a DisclosureGroup, matching the id used in expandedKeys . |
isDisabled | boolean | Whether the disclosure is disabled. |
isExpanded | boolean | Whether the disclosure is expanded (controlled). |
defaultExpanded | boolean | Whether the disclosure is expanded by default (uncontrolled). |
children | ReactNode | (
(values: DisclosureRenderProps
& & {}
)) => ReactNode | The children of the component. A function may be provided to alter the children based on component state. |
className | string | (
(values: DisclosureRenderProps
& & {}
)) => string | The CSS className for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | (
(values: DisclosureRenderProps
& & {}
)) => CSSProperties | undefined | The inline style for the element. A function may be provided to compute the style based on component state. |
Events
Name | Type | Description |
onExpandedChange | (
(isExpanded: boolean
)) => void | Handler that is called when the disclosure's expanded state changes. |
Button#
Show props
Name | Type | Default | Description |
form | string | — | The |
formAction | string | — | The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner. |
formEncType | string | — | Indicates how to encode the form data that is submitted. |
formMethod | string | — | Indicates the HTTP method used to submit the form. |
formNoValidate | boolean | — | Indicates that the form is not to be validated when it is submitted. |
formTarget | string | — | Overrides the target attribute of the button's form owner. |
name | string | — | Submitted as a pair with the button's value as part of the form data. |
value | string | — | The value associated with the button's name when it's submitted with the form data. |
isPending | boolean | — | Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers. |
isDisabled | boolean | — | Whether the button is disabled. |
autoFocus | boolean | — | Whether the element should receive focus on render. |
type | 'button'
| 'submit'
| 'reset' | 'button' | The behavior of the button when used in an HTML form. |
children | ReactNode | (
(values: ButtonRenderProps
& & {}
)) => ReactNode | — | The children of the component. A function may be provided to alter the children based on component state. |
className | string | (
(values: ButtonRenderProps
& & {}
)) => string | — | The CSS className for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | (
(values: ButtonRenderProps
& & {}
)) => CSSProperties | undefined | — | The inline style for the element. A function may be provided to compute the style based on component state. |
Events
Name | Type | Description |
onPress | (
(e: PressEvent
)) => void | Handler that is called when the press is released over the target. |
onPressStart | (
(e: PressEvent
)) => void | Handler that is called when a press interaction starts. |
onPressEnd | (
(e: PressEvent
)) => void | Handler that is called when a press interaction ends, either over the target or when the pointer leaves the target. |
onPressChange | (
(isPressed: boolean
)) => void | Handler that is called when the press state changes. |
onPressUp | (
(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. |
onFocus | (
(e: FocusEvent<Target>
)) => void | Handler that is called when the element receives focus. |
onBlur | (
(e: FocusEvent<Target>
)) => void | Handler that is called when the element loses focus. |
onFocusChange | (
(isFocused: boolean
)) => void | Handler that is called when the element's focus status changes. |
onKeyDown | (
(e: KeyboardEvent
)) => void | Handler that is called when a key is pressed. |
onKeyUp | (
(e: KeyboardEvent
)) => void | Handler that is called when a key is released. |
onHoverStart | (
(e: HoverEvent
)) => void | Handler that is called when a hover interaction starts. |
onHoverEnd | (
(e: HoverEvent
)) => void | Handler that is called when a hover interaction ends. |
onHoverChange | (
(isHovering: boolean
)) => void | Handler that is called when the hover state changes. |
Layout
Name | Type | Description |
slot | string | null | A slot name for the component. Slots allow the component to receive props from a parent component.
An explicit |
Accessibility
Name | Type | Description |
id | string | The element's unique identifier. See MDN. |
excludeFromTabOrder | boolean | Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available. |
preventFocusOnPress | boolean | Whether to prevent focus from moving to the button when pressing it. Caution, this can make the button inaccessible and should only be used when alternative keyboard interaction is provided, such as ComboBox's MenuTrigger or a NumberField's increment/decrement control. |
aria-expanded | boolean
| 'true'
| 'false' | Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed. |
aria-haspopup | boolean
| 'menu'
| 'listbox'
| 'tree'
| 'grid'
| 'dialog'
| 'true'
| 'false' | Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element. |
aria-controls | string | Identifies the element (or elements) whose contents or presence are controlled by the current element. |
aria-pressed | boolean
| 'true'
| 'false'
| 'mixed' | Indicates the current "pressed" state of toggle buttons. |
aria-label | string | Defines a string value that labels the current element. |
aria-labelledby | string | Identifies the element (or elements) that labels the current element. |
aria-describedby | string | Identifies the element (or elements) that describes the object. |
aria-details | string | Identifies the element (or elements) that provide a detailed, extended description for the object. |
DisclosurePanel#
Show props
Name | Type | Description |
children | ReactNode | The children of the component. |
className | string | (
(values: DisclosurePanelRenderProps
& & {}
)) => string | The CSS className for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | (
(values: DisclosurePanelRenderProps
& & {}
)) => CSSProperties | undefined | The inline style for the element. A function may be provided to compute the style based on component state. |
Styling#
React Aria components can be styled in many ways, including using CSS classes, inline styles, utility classes (e.g. Tailwind), CSS-in-JS (e.g. Styled Components), etc. By default, all components include a builtin className
attribute which can be targeted using CSS selectors. These follow the react-aria-ComponentName
naming convention.
.react-aria-DisclosureGroup {
/* ... */
}
.react-aria-DisclosureGroup {
/* ... */
}
.react-aria-DisclosureGroup {
/* ... */
}
A custom className
can also be specified on any component. This overrides the default className
provided by React Aria with your own.
<DisclosureGroup className="my-accordion">
{/* ... */}
</DisclosureGroup>
<DisclosureGroup className="my-accordion">
{/* ... */}
</DisclosureGroup>
<DisclosureGroup className="my-accordion">
{/* ... */}
</DisclosureGroup>
In addition, some components support multiple UI states (e.g. focused, placeholder, readonly, etc.). React Aria components expose states using data attributes, which you can target in CSS selectors. For example:
.react-aria-DisclosureGroup[data-disabled] {
/* ... */
}
.react-aria-DisclosureGroup[data-disabled] {
/* ... */
}
.react-aria-DisclosureGroup[data-disabled] {
/* ... */
}
The className
and style
props also accept functions which receive states for styling. This lets you dynamically determine the classes or styles to apply, which is useful when using utility CSS libraries like Tailwind.
<Disclosure
className={({ isExpanded }) =>
isExpanded ? 'border-blue-500' : 'border-gray-600'}
/>
<Disclosure
className={({ isExpanded }) =>
isExpanded ? 'border-blue-500' : 'border-gray-600'}
/>
<Disclosure
className={(
{ isExpanded }
) =>
isExpanded
? 'border-blue-500'
: 'border-gray-600'}
/>
The states, selectors, and render props for each component used in a DisclosureGroup
are documented below.
DisclosureGroup#
A DisclosureGroup
can be targeted with the .react-aria-DisclosureGroup
CSS selector, or by overriding with a custom className
. It supports the following states:
Name | CSS Selector | Description |
isDisabled | [data-disabled] | Whether the disclosure group is disabled. |
state | — | State of the disclosure group. |
Disclosure#
A Disclosure
can be targeted with the .react-aria-Disclosure
CSS selector, or by overriding with a custom className
. It supports the following states:
Name | CSS Selector | Description |
isExpanded | [data-expanded] | Whether the disclosure is expanded. |
isFocusVisibleWithin | [data-focus-visible-within] | Whether the disclosure has keyboard focus. |
isDisabled | [data-disabled] | Whether the disclosure is disabled. |
state | — | State of the disclosure. |
Button#
A Button
can be targeted with the .react-aria-Button
CSS selector, or by overriding with a custom className
. It supports the following states:
Name | CSS Selector | Description |
isHovered | [data-hovered] | Whether the button is currently hovered with a mouse. |
isPressed | [data-pressed] | Whether the button is currently in a pressed state. |
isFocused | [data-focused] | Whether the button is focused, either via a mouse or keyboard. |
isFocusVisible | [data-focus-visible] | Whether the button is keyboard focused. |
isDisabled | [data-disabled] | Whether the button is disabled. |
isPending | [data-pending] | Whether the button is currently in a pending state. |
DisclosurePanel#
A DisclosurePanel
can be targeted with the .react-aria-DisclosurePanel
CSS selector, or by overriding with a custom className
.
Name | CSS Selector | Description |
isFocusVisibleWithin | [data-focus-visible-within] | Whether keyboard focus is within the disclosure panel. |
Advanced Customization#
State#
DisclosureGroup provides a DisclosureGroupState
object to its children via DisclosureGroupStateContext
. This can be used to access and manipulate the disclosure group's state.
Hook#
If you need to customize things even further, such as accessing internal state, you can drop down to the lower level Hook-based API. See useDisclosureGroupState for more details.