alpha

Disclosure

A collapsible section of content composed of a heading that expands and collapses a panel.

installyarn add @react-spectrum/accordion
version3.0.0-alpha.34
usageimport {Disclosure, DisclosureHeader, DisclosurePanel} from '@react-spectrum/accordion'

Example#


<Disclosure>
  <DisclosureHeader>System Requirements</DisclosureHeader>
  <DisclosurePanel>
    <p>Details about system requirements here.</p>
  </DisclosurePanel>
</Disclosure>
<Disclosure>
  <DisclosureHeader>System Requirements</DisclosureHeader>
  <DisclosurePanel>
    <p>Details about system requirements here.</p>
  </DisclosurePanel>
</Disclosure>
<Disclosure>
  <DisclosureHeader>
    System Requirements
  </DisclosureHeader>
  <DisclosurePanel>
    <p>
      Details about
      system
      requirements
      here.
    </p>
  </DisclosurePanel>
</Disclosure>

Props#


Disclosure#

NameTypeDescription
childrenReact.ReactNodeThe contents of the disclosure. The first child should be the header, and the second child should be the panel.
idKeyAn id for the disclosure when used within a DisclosureGroup, matching the id used in expandedKeys.
isDisabledbooleanWhether the disclosure is disabled.
isExpandedbooleanWhether the disclosure is expanded (controlled).
defaultExpandedbooleanWhether the disclosure is expanded by default (uncontrolled).
Events
NameTypeDescription
onExpandedChange( (isExpanded: boolean )) => voidHandler that is called when the disclosure's expanded state changes.
Layout
NameTypeDescription
slotstringnull

A slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.

Accessibility
NameTypeDescription
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.

DisclosureHeader#

NameTypeDefaultDescription
childrenReact.ReactNodeThe contents of the disclosure header.
levelnumber3The heading level of the disclosure header.
Accessibility
NameTypeDescription
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.

DisclosurePanel#

NameTypeDescription
childrenReact.ReactNodeThe contents of the accordion panel.
Accessibility
NameTypeDefaultDescription
role'group''region''group'The accessibility role for the disclosure's panel.
idstringThe element's unique identifier. See MDN.
aria-labelstringDefines a string value that labels the current element.
aria-labelledbystringIdentifies the element (or elements) that labels the current element.
aria-describedbystringIdentifies the element (or elements) that describes the object.
aria-detailsstringIdentifies the element (or elements) that provide a detailed, extended description for the object.