Extends the Dialog component to display content that complements the main content of the screen.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/input" "github.com/axadrn/shadcn-templ/v2/components/label" "github.com/axadrn/shadcn-templ/v2/components/sheet") templ SheetDemo() { @sheet.Sheet() { @button.Button(button.Props{ Variant: button.VariantOutline, Attributes: sheet.Trigger(ctx), }) { Open } @sheet.Content() { @sheet.Header() { @sheet.Title() { Edit profile } @sheet.Description() { Make changes to your profile here. Click save when you're done. } } <div class="grid flex-1 auto-rows-min gap-6 px-4"> <div class="grid gap-3"> @label.Label(label.Props{For: "sheet-demo-name"}) { Name } @input.Input(input.Props{ID: "sheet-demo-name", Value: "Axel Adrian"}) </div> <div class="grid gap-3"> @label.Label(label.Props{For: "sheet-demo-username"}) { Username } @input.Input(input.Props{ID: "sheet-demo-username", Value: "@axadrn"}) </div> </div> @sheet.Footer() { @button.Button(button.Props{Type: button.TypeSubmit}) { Save changes } @button.Button(button.Props{ Variant: button.VariantOutline, Attributes: sheet.Close(ctx), }) { Close } } } }}Installation
Usage
Composition
Use the following composition to build a Sheet:
Side
Use the Side prop on sheet.Content to set the edge of the screen where the sheet appears. Values are top, right, bottom, and left.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/sheet") var sheetSides = []sheet.Side{sheet.SideTop, sheet.SideRight, sheet.SideBottom, sheet.SideLeft} templ SheetSide() { <div class="flex flex-wrap gap-2"> for _, side := range sheetSides { @sheet.Sheet() { @button.Button(button.Props{ Variant: button.VariantOutline, Class: "capitalize", Attributes: sheet.Trigger(ctx), }) { { string(side) } } @sheet.Content(sheet.ContentProps{Side: side, Class: "data-[side=bottom]:max-h-[50vh] data-[side=top]:max-h-[50vh]"}) { @sheet.Header() { @sheet.Title() { Edit profile } @sheet.Description() { Make changes to your profile here. Click save when you're done. } } <div class="no-scrollbar overflow-y-auto px-4"> for range 10 { <p class="mb-2 leading-relaxed"> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </p> } </div> @sheet.Footer() { @button.Button(button.Props{Type: button.TypeSubmit}) { Save changes } @button.Button(button.Props{ Variant: button.VariantOutline, Attributes: sheet.Close(ctx), }) { Close } } } } } </div>}No Close Button
Use HideCloseButton on sheet.Content to hide the close button.
package examples import (package examples import ( "github.com/axadrn/shadcn-templ/v2/components/button" "github.com/axadrn/shadcn-templ/v2/components/sheet") templ SheetNoCloseButton() { @sheet.Sheet() { @button.Button(button.Props{ Variant: button.VariantOutline, Attributes: sheet.Trigger(ctx), }) { Open Sheet } @sheet.Content(sheet.ContentProps{HideCloseButton: true}) { @sheet.Header() { @sheet.Title() { No Close Button } @sheet.Description() { This sheet doesn't have a close button in the top-right corner. Click outside to close. } } } }}API Reference
Sheet
The sheet.Sheet component is the root, it carries the id that links trigger and content.
SheetTrigger
sheet.Trigger(ctx) returns the attributes that turn any element into the sheet trigger, sheet.TriggerFor(id) targets a sheet outside the current root. sheet.Close(ctx) and sheet.CloseFor(id) close it.
SheetContent
The sheet.Content component is the sliding panel.
SheetHeader
The sheet.Header component wraps the title and description.
SheetFooter
The sheet.Footer component holds actions at the bottom.
SheetTitle
The sheet.Title component renders the accessible sheet title.
SheetDescription
The sheet.Description component renders the accessible sheet description.