useDisclosure

Provides the behavior and accessibility implementation for a disclosure component.

Example
Disclosure.tsx
Disclosure.css
Content.css
import {Disclosure} from './Disclosure';

<Disclosure title="System Requirements">
  Details about system requirements here.
</Disclosure>

API

LandscapeButtonLandscape contentPanel
<Disclosure>
  <Heading>
    <Button slot="trigger" />
  </Heading>
  <DisclosurePanel />
</Disclosure>
useDisclosureState(props: ): useDisclosureGroupState(props: ): useDisclosure( props: , state: , ref: RefObject<HTMLElementnull> ):

DisclosureState

Properties

NameType
isExpandedboolean

Whether the disclosure is currently expanded.

Methods

setExpanded(isExpanded: boolean): void
Sets whether the disclosure is expanded.
expand(): void
Expand the disclosure.
collapse(): void
Collapse the disclosure.
toggle(): void
Toggles the disclosure's visibility.

AriaDisclosureProps

NameType
isDisabledboolean

Whether the disclosure is disabled.

isExpandedboolean

Whether the disclosure is expanded (controlled).

defaultExpandedboolean

Whether the disclosure is expanded by default (uncontrolled).

DisclosureAria

NameType
buttonProps

Props for the disclosure button.

panelPropsHTMLAttributes<HTMLElement>

Props for the disclosure panel.