Drawer#
The <Drawer> component inherits the Modal component and renders a modal overlay to a particular side of the screen.
Import#
import { Drawer } from 'bumbag';
Usage#
Backdrop#
You can hide the backdrop with the hideBackdrop prop.
Placement#
Full screen#
Animation#
Controlled#
Accessibility#
Rules#
- A
Drawermust have an accompanyingDrawer.Disclosurecomponent.
Patterns#
Drawerextends the accessibility features of the Modal component.
Props#
Drawer Props#
isFullScreen boolean
Indicates if the drawer should span the whole width/height of the screen.
9 state props
These props are returned by the state hook. You can spread them into this component (...state) or pass them separately. You can also provide these props from your own state logic.baseId string
ID that will serve as a base for all the items IDs.
visible boolean
Whether it's visible or not.
animating boolean
Whether it's animating or not.
animated number | boolean
If true, animating will be set to true when visible is updated.
It'll wait for stopAnimation to be called or a CSS transition ends.
If animated is set to a number, stopAnimation will be called only
after the same number of milliseconds have passed.
stopAnimation () => void
Stops animation. It's called automatically if there's a CSS transition.
modal boolean
Toggles Dialog's modal state.
- Non-modal:
preventBodyScrolldoesn't work and focus is free. - Modal:
preventBodyScrollis automatically enabled, focus is trapped within the dialog and the dialog is rendered within aPortalby default.
hide () => void
Changes the visible state to false
baseId string Required
ID that will serve as a base for all the items IDs.
Inherits Modal props
hideBackdrop boolean
Hides the backdrop.
placement
"top-start" | "top" | "top-end" | "right-start" | "right" | "right-end" | "bottom-end" | "bottom" | "bottom-start" | "left-end" | "left" | "left-start" | "center"
Sets the placement of the modal.
delay string
Delay of the animation (in s/ms).
duration string
Duration of the animation (in s/ms).
expand
boolean | "top" | "right" | "bottom" | "left" | "center"
Will the component have an expand animation when it is toggled on/off?
fade boolean
Will the component have a fade animation when it is toggled on/off?
slide boolean | "top" | "right" | "bottom" | "left"
Will the component have a slide animation when it is toggled on/off?
timingFunction string
Timing function of the animation
hideOnEsc boolean
When enabled, user can hide the dialog by pressing Escape.
hideOnClickOutside boolean
When enabled, user can hide the dialog by clicking outside it.
preventBodyScroll boolean
When enabled, user can't scroll on body when the dialog is visible. This option doesn't work if the dialog isn't modal.
Inherits Box props
use
string
| (ComponentClass<any, any> & { useProps: any; })
| (FunctionComponent<any> & { useProps: any; })className string
children
string
| number
| boolean
| {}
| ReactElement<any, string
| ((props: any) => ReactElement<any, string
| ...
| (new (props: any) => Component<any, any, any>)>)
| (new (props: any) => Component<...>)>
| ReactNodeArray
| ReactPortal
| ((props: BoxProps) => ReactNode)alignX "right" | "left" | "center"
alignY "top" | "bottom" | "center"
variant string
colorMode string
disabled boolean
overrides
{
useCSSVariables?: boolean;
altitudes?: AltitudesThemeConfig;
borders?: BordersThemeConfig;
borderRadii?: BorderRadiiThemeConfig;
... 95 more ...;
Template?: TemplateThemeConfig;
}elementRef ((instance: any) => void) | RefObject<any>
themeKey string
Drawer.Disclosure Props#
5 state props
These props are returned by the state hook. You can spread them into this component (...state) or pass them separately. You can also provide these props from your own state logic.visible boolean
Whether it's visible or not.
baseId string Required
ID that will serve as a base for all the items IDs.
toggle () => void Required
Toggles the visible state
toggle () => void Required
Toggles the visible state
Inherits ModalDisclosure props
disabled boolean
Same as the HTML attribute.
focusable boolean
When an element is disabled, it may still be focusable. It works
similarly to readOnly on form elements. In this case, only
aria-disabled will be set.
Inherits Box props
use
string
| (ComponentClass<any, any> & { useProps: any; })
| (FunctionComponent<any> & { useProps: any; })className string
children
string
| number
| boolean
| {}
| ReactElement<any, string
| ((props: any) => ReactElement<any, string
| ...
| (new (props: any) => Component<any, any, any>)>)
| (new (props: any) => Component<...>)>
| ReactNodeArray
| ReactPortal
| ((props: BoxProps) => ReactNode)alignX "right" | "left" | "center"
alignY "top" | "bottom" | "center"
variant string
colorMode string
overrides
{
useCSSVariables?: boolean;
altitudes?: AltitudesThemeConfig;
borders?: BordersThemeConfig;
borderRadii?: BorderRadiiThemeConfig;
... 95 more ...;
Template?: TemplateThemeConfig;
}elementRef ((instance: any) => void) | RefObject<any>
themeKey string
State#
Drawer.State API#
baseId string
ID that will serve as a base for all the items IDs.
visible boolean
Whether it's visible or not.
animated number | boolean
If true, animating will be set to true when visible is updated.
It'll wait for stopAnimation to be called or a CSS transition ends.
If animated is set to a number, stopAnimation will be called only
after the same number of milliseconds have passed.
modal boolean
Toggles Dialog's modal state.
- Non-modal:
preventBodyScrolldoesn't work and focus is free. - Modal:
preventBodyScrollis automatically enabled, focus is trapped within the dialog and the dialog is rendered within aPortalby default.
Drawer.State Return Values#
15 values
baseId string Required
ID that will serve as a base for all the items IDs.
visible boolean Required
Whether it's visible or not.
animated number | boolean Required
If true, animating will be set to true when visible is updated.
It'll wait for stopAnimation to be called or a CSS transition ends.
If animated is set to a number, stopAnimation will be called only
after the same number of milliseconds have passed.
animating boolean Required
Whether it's animating or not.
setBaseId (value: SetStateAction<string>) => void Required
Sets baseId.
show () => void Required
Changes the visible state to true
hide () => void Required
Changes the visible state to false
toggle () => void Required
Toggles the visible state
setVisible (value: SetStateAction<boolean>) => void Required
Sets visible.
setAnimated (value: SetStateAction<number | boolean>) => void Required
Sets animated.
stopAnimation () => void Required
Stops animation. It's called automatically if there's a CSS transition.
modal boolean Required
Toggles Dialog's modal state.
- Non-modal:
preventBodyScrolldoesn't work and focus is free. - Modal:
preventBodyScrollis automatically enabled, focus is trapped within the dialog and the dialog is rendered within aPortalby default.
setModal (value: SetStateAction<boolean>) => void Required
Sets modal.
Drawer.useState API#
baseId string
ID that will serve as a base for all the items IDs.
visible boolean
Whether it's visible or not.
animated number | boolean
If true, animating will be set to true when visible is updated.
It'll wait for stopAnimation to be called or a CSS transition ends.
If animated is set to a number, stopAnimation will be called only
after the same number of milliseconds have passed.
modal boolean
Toggles Dialog's modal state.
- Non-modal:
preventBodyScrolldoesn't work and focus is free. - Modal:
preventBodyScrollis automatically enabled, focus is trapped within the dialog and the dialog is rendered within aPortalby default.
Drawer.useState Return Values#
15 values
baseId string Required
ID that will serve as a base for all the items IDs.
visible boolean Required
Whether it's visible or not.
animated number | boolean Required
If true, animating will be set to true when visible is updated.
It'll wait for stopAnimation to be called or a CSS transition ends.
If animated is set to a number, stopAnimation will be called only
after the same number of milliseconds have passed.
animating boolean Required
Whether it's animating or not.
setBaseId (value: SetStateAction<string>) => void Required
Sets baseId.
show () => void Required
Changes the visible state to true
hide () => void Required
Changes the visible state to false
toggle () => void Required
Toggles the visible state
setVisible (value: SetStateAction<boolean>) => void Required
Sets visible.
setAnimated (value: SetStateAction<number | boolean>) => void Required
Sets animated.
stopAnimation () => void Required
Stops animation. It's called automatically if there's a CSS transition.
modal boolean Required
Toggles Dialog's modal state.
- Non-modal:
preventBodyScrolldoesn't work and focus is free. - Modal:
preventBodyScrollis automatically enabled, focus is trapped within the dialog and the dialog is rendered within aPortalby default.
setModal (value: SetStateAction<boolean>) => void Required
Sets modal.
Theming#
Drawer.styles.baseDrawer.styles.placements.leftDrawer.styles.placements.rightDrawer.Backdrop.styles.baseDrawer.Disclosure.styles.base