Import
import {
Drawer ,
DrawerTrigger ,
DrawerContent ,
DrawerHeader ,
DrawerTitle ,
DrawerDescription ,
DrawerFooter ,
DrawerClose ,
} from '@strongtie/design-system/drawer' ;
Usage
< Drawer >
< DrawerTrigger > Open Drawer </ DrawerTrigger >
< DrawerContent >
< DrawerHeader >
< DrawerTitle > Drawer Title </ DrawerTitle >
< DrawerDescription >
This is a description of the drawer.
</ DrawerDescription >
</ DrawerHeader >
< div className = "p-4" >
< p > Drawer content goes here. </ p >
</ div >
< DrawerFooter >
< DrawerClose asChild >
< Button variant = "outline" > Cancel </ Button >
</ DrawerClose >
</ DrawerFooter >
</ DrawerContent >
</ Drawer >
<Drawer> PropsIf true, the background will scale when the drawer is opened.
If true, the drawer will be open by default.
Controls the open state of the drawer.
Callback function that is called when the open state changes.
direction
"top" | "bottom" | "left" | "right"
default: "bottom"
The direction from which the drawer appears.
If true, the drawer will be rendered in a modal.
If true, the drawer is nested within another drawer.
If true, the drawer can be dismissed.
<DrawerPortal> PropsIf true, the portal will be mounted even if the drawer is closed.
container
HTMLElement
default: "document.body"
The container in which the portal will be rendered.
<DrawerOverlay> PropsIf true, the overlay will be rendered as a child of the drawer.
If true, the overlay will be mounted even if the drawer is closed.
<DrawerContent> PropsIf true, the content will be mounted even if the drawer is closed.
Event handler called when focus moves into the component after opening.
Event handler called when focus moves out of the component after closing.
Event handler called when the escape key is pressed.
Event handler called when a pointer event occurs outside the component.
Event handler called when an interaction occurs outside the component.
<DrawerClose>, <DrawerTrigger>, <DrawerTitle>, <DrawerDescription> PropsIf true, the component will be rendered as a child of the drawer.
Usage Examples Basic
With Footer
Controlled
No Background Scaling
< Drawer >
< DrawerTrigger > Open Drawer </ DrawerTrigger >
< DrawerContent >
< DrawerHeader >
< DrawerTitle > Basic Drawer </ DrawerTitle >
< DrawerDescription > A simple drawer example. </ DrawerDescription >
</ DrawerHeader >
< div >
< p > Drawer content goes here. </ p >
</ div >
</ DrawerContent >
</ Drawer >
Styling Classes The following CSS classes are applied by the Drawer components:
drawer-overlay – Background overlay that appears behind the drawer.
drawer-content – Main container for the drawer content.
drawer-content-handle – The drag handle at the top of the drawer.
drawer-header – Container for the drawer title and description.
drawer-title – Title text styling.
drawer-description – Description text styling.
drawer-footer – Container for footer actions and buttons.
For more examples, visit the Storybook . < StudsButton Text = "Open Drawer" ButtonStyle = "ButtonStyle.Secondary" Click = " @ OpenDrawerDialog " />
@code {
async Task OpenDrawerDialog ()
{
await DialogService . OpenDrawerAsync < DialogContent >( "Drawer Title" ,
options : new DrawerDialogOptions {
Description = "Drawer description" ,
CloseDialogOnEsc = true
});
}
}
DrawerDialogOptions ParametersThe title displayed on the dialog.
Gets or sets the description text displayed under the title.
Gets or sets a value indicating whether the dialog is draggable.
Gets or sets a value indicating whether to focus the first focusable HTML element.
CloseDialogOnOverlayClick
Gets or sets a value indicating whether the dialog should be closed by clicking the overlay.
Gets or sets a value indicating whether the dialog should be closed on ESC key press.
Gets or sets a value indicating whether to show the title bar.
Gets or sets the CSS style of the dialog.
Gets or sets dialog box custom class.
Gets or sets the CSS classes added to the dialog’s wrapper element.
Gets or sets the CSS classes added to the dialog’s content element.
Gets or sets a value the dialog escape tabindex.
ChildContent
RenderFragment<DialogService>
The content to display inside the drawer.
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default: "CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Usage Examples Basic
With Content
No Description
Custom Styling
< StudsButton Text = "Open Basic Drawer" Click = " @ OpenBasicDrawer " />
@code {
async Task OpenBasicDrawer ()
{
await DialogService . OpenDrawerAsync ( "Basic Drawer" ,
new Dictionary < string , object >(),
new DrawerDialogOptions {
Description = "A simple drawer example"
});
}
}
Styling Classes The following CSS classes are applied by the Drawer components:
drawer – Root drawer container
dialog-grab-bar – The drag handle at the top of the drawer
dialog-header – Container for title and description
dialog-titlebar – Title bar container
dialog-title – Title text styling
dialog-description – Description text styling
dialog-content – Main content area
dialog-mask – Background overlay/mask
For more examples, visit the Storybook .