Description
The Drawer component is a Modal variation that appears as a side panel at any chosen side of the page; top, bottom, left or right (default right
). A Drawer is typically used to show additional information. It can also be used to have easy/quick tasks while being in context.
Parts in Drawer
To provide custom content to parts of the Drawer, a set of component parts are provided:
<Drawer.Navigation>
: The navigation field at the top of the component, default with a close button (Equal to the propnavContent
).<Drawer.Header>
: The header field of the component, where thetitle
will appear (Equal to the propheaderContent
).<Drawer.Body>
: The body of the Drawer, provided with a section background color, defaultblack-3
(Equal to the propmodalContent
).
More detailed information
For more details regarding the component functionality, check out the Modal documentation.
Converting from Modal mode drawer
If you are converting from <Modal mode="drawer" />
to <Drawer />
, there are a few differences you need to take into consideration:
- All
trigger_*
props are not supported for Drawer, usetriggerAttributes
instead to pass in props for the trigger button.- Change prop
trigger_hidden
toomitTriggerButton
to omit the default trigger button from Modal.
- Change prop
- Only camelCase props are supported for Drawer, so you will need to update the prop names.
Modal.Inner
/Modal.Content
converts toDrawer.Body
.Modal.Bar
converts toDrawer.Navigaton
.Modal
was a class component andDrawer
is a functional component.
Demos
Basic Drawer
<Drawertitle="Drawer title"triggerAttributes={{text: "Open drawer"}}><P top>Some informational content</P><P top>Elementum eu suspendisse sit platea elit porttitor magnalaoreet ad ultrices tempus urna curae parturient conubiaquisque viverra eget vestibulum neque pulvinar sempervulputate id dis varius pellentesque nunc egestas risus ametmus aptent luctus imperdiet netus natoque cubilia mattisnostra proin ornare scelerisque sodales faucibus placerat sembibendum pretium rutrum vitae sociis ligula inceptos morbiquam mi sed pharetra fermentum tortor ullamcorper ipsumtellus eros euismod volutpat nisl dui lectus fames suscipitphasellus praesent justo mollis montes velit taciti gravida</P></Drawer>
Drawer with custom content
<Drawertitle="Custom title"><Drawer.Navigation><Breadcrumb onClick={handleBack} /></Drawer.Navigation><Drawer.Header><P bottom>This is a lorem ipsum dolor</P><Button bottom size="large">Lorem ipsum</Button><Button bottom size="large" variant="secondary">Dolor sit</Button><FormStatus state="info">This is a lorem ipsum dolor</FormStatus><Tabsid="unique-linked-id"data={[{title: 'One',key: 'one',},{title: 'Two',key: 'two',},]}/></Drawer.Header><Drawer.Body><Tabs.Content id="unique-linked-id">{({ title }) => {return (<><H2>{title}</H2><P top>This is a left aligned Drawer content.</P><P top>Elementum eu suspendisse sit platea elit porttitor magnalaoreet ad ultrices tempus urna curae parturient conubiaquisque viverra eget vestibulum neque pulvinar sempervulputate id dis varius pellentesque nunc egestas risus ametmus aptent luctus imperdiet netus natoque cubilia mattisnostra proin ornare scelerisque sodales faucibus placerat sembibendum pretium rutrum vitae sociis ligula inceptos morbiquam mi sed pharetra fermentum tortor ullamcorper ipsumtellus eros euismod volutpat nisl dui lectus fames suscipitphasellus praesent justo mollis montes velit taciti gravidalacus commodo senectus feugiat lorem etiam consequatpenatibus cum hendrerit accumsan orci potenti purus nullainterdum metus sollicitudin magnis libero sapien habitant nonclass ridiculus consectetur congue nec litora sociosqualiquet felis in rhoncus nascetur odio ultricies nullam aiaculis massa nisi ante nam cras aenean erat facilisi vivamusut cursus auctor arcu lobortis himenaeos dictum habitassetristique mauris at blandit sagittis nibh dignissimcondimentum per integer duis lacinia malesuada est adipiscingmaecenas donec eleifend turpis dictumst dapibus tempor fuscealiquam torquent hac ac curabitur venenatis et tinciduntaugue porta vehicula enim facilisis posuere primis molestieconvallis diam vel fringilla dolor leo quis diam cursus massasapien tristique cum senectus sed tortor natoque amethendrerit ut fusce ipsum quis</P></>)}}</Tabs.Content></Drawer.Body></Drawer>
Customize trigger button
<Drawertitle="Drawer with custom trigger"triggerAttributes={{text: "Custom trigger",variant: "primary",size: "large",icon: "loupe",icon_position: "left"}}><Drawer.Body spacing><P>Opened a Drawer with a custom trigger button!</P></Drawer.Body></Drawer>
Close Drawer by callback method
<Drawertitle="Drawer title"triggerAttributes={{text: "Open drawer"}}hideCloseButton>{({ close }) => (<><Button text="Close by callback" on_click={close} /></>)}</Drawer>
Remove animation and spacing
<Drawertitle="No spacing or animation"noAnimationspacing={false}hideCloseButton><Drawer.Body><P top bottom>This is a lorem ipsum dolor</P><Button bottom size="large">Lorem ipsum</Button><Button bottom size="large" variant="secondary">Dolor sit</Button><FormStatus state="info">This is a lorem ipsum dolor</FormStatus></Drawer.Body></Drawer>