SidebarModal
A panel that slides in from the side for extra detail, without leaving the page. Opened by name through `useShowSidebar`.
Health
Source
Design
Storybook
Playground
No Example
Accessibility
partially-compliant
Platform
Web
Accessibility issues
The focus is trapped correctly. The modal is missing a labelledby attribute. The first interactive element is not focused when the modal is opened. The main content is not hidden from screen readers when the modal is opened.
- Overview
- Props
- Figma
Opening
Every SidebarModal is declared with a name. To open a modal, you need to use the useShowSidebar hook, which returns a function to use to open a specific modal (e.g.show('my-modal')).
Closing
SidebarModal can be closed by clicking on the close button or by clicking on the overlay. You can also close a modal by using the useHideSidebar hook, which returns a function to use to close the opened modal (e.g.hide()).
Accessibility
The SidebarModal component comes with a SidebarModal.Title component that should be used to provide a title for the modal.
When using it, make sure other modal headings are start at h3 level or below.
SidebarModal props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| aria-label | string | Accessible name of the dialog. Prefer `aria-labelledby` when a visible title exists. | ||
| aria-labelledby | string | Id of the visible element naming the dialog. | ||
| backButtonLabel | string | |||
| children | ReactNode | |||
| closeButtonLabel | string | |||
| cover | ReactNode | |||
| id | string | |||
| name* | stringRegExp | |||
| onClose | () => void | |||
| onGoBack | () => void | |||
| scrollOffset | number | |||
| showBackButton | boolean | |||
| showCloseButton | boolean | |||
| size | SideModalSize | |||
| style | CSSProperties |