Import
import {
Sheet ,
SheetPortal ,
SheetOverlay ,
SheetTrigger ,
SheetClose ,
SheetContent ,
SheetHeader ,
SheetFooter ,
SheetTitle ,
SheetDescription ,
} from 'studs-react' ;
Usage
< Sheet >
< SheetTrigger asChild >
< Button variant = "outline" >
Open
</ Button >
</ SheetTrigger >
< SheetContent side = "end" >
< SheetHeader >
< SheetTitle >
Edit profile
</ SheetTitle >
< SheetDescription >
Make changes to your profile here. Click save when you're done.
</ SheetDescription >
</ SheetHeader >
// Content
< SheetFooter >
< SheetClose asChild >
< Button type = "submit" >
Save changes
</ Button >
</ SheetClose >
</ SheetFooter >
</ SheetContent >
</ Sheet >
<Sheet> PropsIf true, the sheet will be open by default.
If true, the sheet will be open.
Callback function that is called when the open state changes.
When set to true, interaction with outside elements will be disabled and only
sheet content will be visible to screen readers.
<SheetPortal> PropsUsed to force mounting when more control is needed.
container
HTMLElement
default: "document.body"
The container element to render the sheet into.
<SheetOverlay> PropsIf true, the overlay will render as a child component.
Used to force mounting when more control is needed.
<SheetContent> PropsIf true, the content will render as a child component.
If true, the content will always be mounted in the DOM.
side
top | start | bottom | end
default: "end"
The edge of the screen where the sheet will appear.
Event handler called when focus moves into the component after opening. It can be prevented by calling event.preventDefault.
Event handler called when focus moves to the trigger after closing. It can beprevented by calling event.preventDefault.
Event handler called when the escape key is down. It can be prevented by
calling event.preventDefault.
Event handler called when a pointer event occurs outside the bounds of the
component. It can be prevented by calling event.preventDefault.
Event handler called when an interaction (pointer or focus event) happens outside the bounds of the component. It can be prevented by calling event.preventDefault.
If true, the close button will render as a child component.
Styling Classes The component applies the following CSS classes:
sheet-overlay - Applied to the overlay component
sheet - Base sheet class for the content
sheet-close-button - Applied to the close button
sheet-close-icon - Applied to the close icon
sheet-header - Applied to the header component
sheet-footer - Applied to the footer component
sheet-title - Applied to the title component
sheet-description - Applied to the description component
For examples, visit the Storybook . @inject DialogService DialogService
await DialogService.OpenSheetAsync < T > (Title, options: new SheetDialogOptions {
Title = Title,
Position = Position,
ShowMask = ShowMask,
AutoFocusFirstElement = AutoFocusFirstElement,
ShowTitle = ShowTitle,
ShowClose = ShowClose,
Width = Width,
Height = Height,
Style = Style,
CloseDialogOnOverlayClick = CloseDialogOnOverlayClick,
CssClass = CssClass,
WrapperCssClass = WrapperCssClass,
ContentCssClass = ContentCssClass,
CloseTabIndex = CloseTabIndex
});
DialogService Methods OpenSheetAsync<T>(string title, Dictionary<string, object> parameters = null, SheetDialogOptions options = null)
Opens a sheet dialog with the specified component type and parameters.
OpenSheetAsync(string title, RenderFragment<DialogService> childContent, SheetDialogOptions options = null)
Opens a sheet dialog with custom content using a RenderFragment.
CloseSheet(dynamic result = null)
Closes the currently open sheet dialog with an optional result.
SheetDialogOptions ParametersGets or sets the title of the sheet.
Position
DialogPosition
default: "DialogPosition.End"
Gets or sets the position of the sheet (Start, End, Top, Bottom).
Gets or sets a value indicating whether to show the overlay mask behind the sheet.
Gets or sets a value indicating whether to auto-focus the first focusable element when the sheet opens.
Gets or sets a value indicating whether to show the title bar in the sheet header.
Gets or sets a value indicating whether to show the close button in the sheet header.
Gets or sets the width of the sheet (e.g., “400px”, “50%”).
Gets or sets the height of the sheet (e.g., “600px”, “80vh”).
Gets or sets additional CSS styles to apply to the sheet.
CloseDialogOnOverlayClick
Gets or sets a value indicating whether to close the sheet when the overlay is clicked.
Gets or sets a value indicating whether to close the sheet when the Escape key is pressed.
Gets or sets custom CSS classes to apply to the sheet container.
Gets or sets CSS classes to apply to the sheet’s wrapper element.
Gets or sets CSS classes to apply to the sheet’s content area.
Gets or sets the tab index for the close button.
ChildContent
RenderFragment<DialogService>
Gets or sets the content to display inside the sheet when using RenderFragment approach.
Usage Examples Basic Sheet
Sheet with Custom Content
Sheet with Parameters
Different Positions
Custom Styling
@inject DialogService DialogService
< StudsButton Text = "Open Basic Sheet" Click = " @ OpenBasicSheet " />
@code {
async Task OpenBasicSheet ()
{
await DialogService . OpenSheetAsync < MySheetContent >( "Basic Sheet" ,
options : new SheetDialogOptions {
Position = DialogPosition . End ,
Width = "300px"
});
}
}
Styling Classes The following CSS classes are applied by the Sheet components:
sheet – Root sheet container with positioning
sheet.-start – Left-positioned sheet modifier
sheet.-end – Right-positioned sheet modifier
sheet.-top – Top-positioned sheet modifier
sheet.-bottom – Bottom-positioned sheet modifier
dialog-titlebar – Title bar container
dialog-title – Title text styling
dialog-titlebar-close – Close button in title bar
dialog-content – Main content area
dialog-mask – Background overlay/mask
For more examples, visit the Storybook .