Drawer
Drawer
Component demo
Interactive example
<divstyle="position: relative;height:100%;width:100%;"><ic-drawerheading="Roasted coffee"message="Contrary to popular belief, light roast coffee has more caffeine than dark roast coffee. The longer coffee is roasted, the more caffeine is lost through the cooking of the bean. Light roast coffee is a light brown colour and has no oil on the surface of the beans, and these coffees typically have a crisp acidity, a mellow body, and bright flavours."boundary="parent"><svgslot="heading-adornment"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"height="1.5rem"width="1.5rem"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg><ic-buttonslot="actions">Add to order</ic-button></ic-drawer></div>
Drawer details
Props
All components also accept native properties supported by the DOM, such asclassName
and
style
.
|
|
|
|
|---|---|---|
|
|
The area within which the drawer should be contained. When set to "parent", the value of the parent element's |
|
|
|
The aria-label of the chevron button (displayed when |
|
|
|
The aria-label of the X (close) button (displayed when |
|
|
|
If |
|
|
|
If |
|
|
|
The heading of the drawer. This is required, unless a slotted heading is used. |
|
|
|
If set to |
|
|
|
The body content of the drawer. |
|
|
|
The position of the drawer. |
|
|
|
The size of the expanded drawer. |
|
|
|
Sets the drawer to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. |
|
|
|
The method in which the drawer is expanded. |
|
|
The area within which the drawer should be contained. When set to "parent", the value of the parent element's |
|
The aria-label of the chevron button (displayed when |
|
The aria-label of the X (close) button (displayed when |
|
If |
|
If |
|
The heading of the drawer. This is required, unless a slotted heading is used. |
|
If set to |
|
The body content of the drawer. |
|
The position of the drawer. |
|
The size of the expanded drawer. |
|
Sets the drawer to the dark or light theme colors. "inherit" will set the color based on the system settings or ic-theme component. |
|
The method in which the drawer is expanded. |
Slots
A slot allows for any type of element or markup to be passed into and rendered within a web component. This creates more flexibility than using a prop which must take a specific type of data.
Content can be slotted into a component by adding it as a top-level child of the component.
Slots can have a name to identify them. These specify which slot the content will be inserted into, and therefore where it will be rendered and how it will be used within the component. The name of the slot to be used can be specified by passing it via a
slot
attribute on the slotted content.
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CSS Custom Properties
|
|
|
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Events
All components also accept native events supported by the DOM, such as
onClick
and
onKeyDown
.
|
|
|
|
|---|---|---|
|
|
|
|
|
|
Variants
The drawer components in the following code examples have theboundary
prop set to"parent"
so that they are contained within each component preview. To anchor the drawer to the viewport instead, set theboundary
prop to"viewport"
.
Position
Interactive example
<divstyle="position: relative;height:100%;width:100%;"><ic-drawerheading="Roasted coffee"message="Contrary to popular belief, light roast coffee has more caffeine than dark roast coffee. The longer coffee is roasted, the more caffeine is lost through the cooking of the bean. Light roast coffee is a light brown colour and has no oil on the surface of the beans, and these coffees typically have a crisp acidity, a mellow body, and bright flavours."boundary="parent"position="top"><svgslot="heading-adornment"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"height="1.5rem"width="1.5rem"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg><ic-buttonslot="actions">Add to order</ic-button></ic-drawer></div>
Size
Interactive example
<divstyle="position: relative;height:100%;width:100%;"><ic-drawerheading="Roasted coffee"message="Contrary to popular belief, light roast coffee has more caffeine than dark roast coffee. The longer coffee is roasted, the more caffeine is lost through the cooking of the bean. Light roast coffee is a light brown colour and has no oil on the surface of the beans, and these coffees typically have a crisp acidity, a mellow body, and bright flavours."boundary="parent"size="small"><svgslot="heading-adornment"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"height="1.5rem"width="1.5rem"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg><ic-buttonslot="actions">Add to order</ic-button></ic-drawer></div>
Controlled trigger
Interactive example
<divstyle="position: relative;height:100%;width:100%;"><ic-buttonstyle="margin:1rem;"onclick="toggleDrawer()">Find out more about roasted coffee</ic-button><ic-drawerheading="Roasted coffee"message="Contrary to popular belief, light roast coffee has more caffeine than dark roast coffee. The longer coffee is roasted, the more caffeine is lost through the cooking of the bean. Light roast coffee is a light brown colour and has no oil on the surface of the beans, and these coffees typically have a crisp acidity, a mellow body, and bright flavours."boundary="parent"trigger="controlled"id="roasted-coffee-drawer"><svgslot="heading-adornment"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"height="1.5rem"width="1.5rem"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg><ic-buttonslot="actions">Add to order</ic-button></ic-drawer></div>
Slotted content
Interactive example
Roasted coffee
Contrary to popular belief, light roast coffee has more
<divstyle="position: relative;height:100%;width:100%;"><ic-drawerboundary="parent"><svgslot="heading-adornment"xmlns="http://www.w3.org/2000/svg"viewBox="0 0 24 24"height="1.5rem"width="1.5rem"><pathd="M2,21H20V19H2M20,8H18V5H20M20,3H4V13A4,4 0 0,0 8,17H14A4,4 0 0,0 18,13V10H20A2,2 0 0,0 22,8V5C22,3.89 21.1,3 20,3Z"/></svg><ic-typographyslot="heading"variant="h4"><h4>Roasted coffee</h4></ic-typography><ic-typographyslot="message"><p>Contrary to popular belief, light roast coffee has more <ic-linkhref="#">caffeine</ic-link> than dark roast coffee. The longer coffee is roasted, the more caffeine is lost through the cooking of the bean. Light roast coffee is a light brown colour and has no oil on the surface of the beans, and these coffees typically have a crisp acidity, a mellow body, and bright flavours.</p></ic-typography><ic-buttonslot="actions">Add to order</ic-button></ic-drawer></div>