Edit page

Disclosure

A disclosure is a button that controls visibility of a section of content —WAI-ARIA-Practices-1.1

Basic Usage

Props

children

function({}) | required

This is the only required prop. children is our render prop and must be a function. It is called with an object argument:

propertytypedescription
getControlPropsfunction(props: object)returns the props for the control element (e.g., a button)
getContentPropsfunction(props: object)returns the props for the content element
isExpandedbooleanthe current state of the component

isExpanded

boolean

If you want the disclosure to be controlled, you can pass in a boolean to isExpanded and the component will honor the prop's value.

onChange

function({})

Called whenever the component attempts a state change. If the component is is controlled (i.e., you are managing isExpanded), you should update isExpanded based on this handler

propertytypedescription
isExpandedbooleanthe next state of the component