Drawer
A sheet docked to the bottom, top, left or right edge, on the native modal dialog.
On this page
Examples
Drawer
Bound open state; the slide respects prefers-reduced-motion.
Drawer: closed
Razor
<div class="flex flex-col items-center gap-3">
<KlyDrawer @bind-Open="_open" Title="Quick actions" Description="Pick something to do next.">
<ChildContent><KlyButton Label="Open drawer" Variant="ButtonVariant.Outline" data-testid="drawer-trigger" /></ChildContent>
<Body>
<p class="text-sm text-(--klyroo-text-muted)">The drawer is a native modal dialog: the page behind it is inert and Escape closes it.</p>
</Body>
<Footer>
<KlyButton Label="Cancel" Color="KlyColor.Neutral" Variant="ButtonVariant.Ghost" data-kly-close />
<KlyButton Label="Done" data-kly-close data-testid="drawer-done" />
</Footer>
</KlyDrawer>
<p class="text-sm text-(--klyroo-text-muted)" data-testid="drawer-state">Drawer: @(_open ? "open" : "closed")</p>
</div>
@code {
private bool _open;
}Directions
The handle shows on top and bottom drawers; Inset floats the drawer.
Razor
<KlyDrawer Direction="DrawerDirection.Top" Title="From the top" Close>
<ChildContent><KlyButton Label="Top" Variant="ButtonVariant.Outline" /></ChildContent>
<Body><p class="text-sm text-(--klyroo-text-muted)">Handle at the bottom edge.</p></Body>
</KlyDrawer>
<KlyDrawer Direction="DrawerDirection.Left" Title="From the left" Close>
<ChildContent><KlyButton Label="Left" Variant="ButtonVariant.Outline" /></ChildContent>
<Body><p class="text-sm text-(--klyroo-text-muted)">Side drawers have no handle.</p></Body>
</KlyDrawer>
<KlyDrawer Direction="DrawerDirection.Right" Inset Title="Inset, from the right" Close>
<ChildContent><KlyButton Label="Right, inset" Variant="ButtonVariant.Outline" /></ChildContent>
<Body><p class="text-sm text-(--klyroo-text-muted)">Inset floats the drawer away from the edges.</p></Body>
</KlyDrawer>API
KlyDrawer
Panel docked to one edge of the screen in a modal dialog, with a title, a description, a body and a footer.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
AriaLabel |
string |
Accessible name when there is no Title . | |
Class |
string |
Classes added to the root element, merged last so they win over the theme. | |
Close |
bool |
false |
Shows a close button in the header (a title or a description also shows the header). |
Description |
string |
Text under the title of the drawer. | |
Direction |
DrawerDirection |
DrawerDirection. |
The edge the drawer is docked to. Values: Bottom, Top, Left, Right. |
Dismissible |
bool |
true |
Escape and a click on the backdrop close the drawer. |
Handle |
bool |
true |
The grab handle shown on top and bottom drawers. It is decorative: the drawer closes with Escape, the backdrop or a close button. |
Inset |
bool |
false |
Floats the drawer away from the edges of the screen. |
Open (@bind-Open) |
bool |
false |
Open state. Use @bind-Open : the browser closes the drawer on its own (Escape, backdrop, close button). |
Title |
string |
Title of the drawer, which also names the dialog. | |
Ui |
DrawerUi |
Per-instance class overrides of the slots of the drawer, see DrawerUi . They are merged after the theme and the Class parameter wins on the root slot. |
Slots
| Name | Type | Description |
|---|---|---|
Body |
RenderFragment |
Content of the body of the drawer. |
Footer |
RenderFragment |
Footer actions. Add data-kly-close to a button to make it close the drawer. |
ChildContent |
RenderFragment |
The trigger: its first button opens the drawer. |
Ui slots
Ui takes a DrawerUi with one class string per slot, merged after the theme.
| Slot | Styles |
|---|---|
Content |
Classes merged into the content slot of KlyDrawer , after the theme and the app configuration. |
Handle |
Classes merged into the handle slot of KlyDrawer , after the theme and the app configuration. |
Header |
Classes merged into the header slot of KlyDrawer , after the theme and the app configuration. |
Wrapper |
Classes merged into the wrapper slot of KlyDrawer , after the theme and the app configuration. |
Title |
Classes merged into the title slot of KlyDrawer , after the theme and the app configuration. |
Description |
Classes merged into the description slot of KlyDrawer , after the theme and the app configuration. |
Close |
Classes merged into the close slot of KlyDrawer , after the theme and the app configuration. |
Body |
Classes merged into the body slot of KlyDrawer , after the theme and the app configuration. |
Footer |
Classes merged into the footer slot of KlyDrawer , after the theme and the app configuration. |