DismissButton

A visually hidden button that can be used to allow screen reader users to dismiss a modal or popup when there is no visual affordance to do so.

installyarn add react-aria
version3.20.0
usageimport {DismissButton} from 'react-aria'

Introduction#


DismissButton is a visually hidden button that can be used by screen reader users to close an overlay in the absence of a visual dismiss button. This may typically be used with a menu or a popover since they often forgo a visual dismiss button, instead allowing users to use the Escape key to dismiss the menu or popover.

Props#


Events
NameTypeDefaultDescription
onDismiss() => voidCalled when the dismiss button is activated.
Accessibility
NameTypeDefaultDescription
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.

Example#


See useMenu and usePopover for examples of how to use DismissButton with a menu or popover.