Skip to content
dev

Drawer

Slide-over panels for detail views and configuration forms.

Default Rendered example
Usage Example
@drawer.Drawer(drawer.Config{
    ID:    "projectDetails",
    Title: "Project details",
    Side:  drawer.SideRight,
    Width: drawer.WidthLG,
}) {
    <div id="projectDetails-body">...</div>
}

Built-in text: the development API provides expressions.Drawer for application defaults, request preferences, and individual component overrides. Read the expression guide.

Responsive Drawer

Set NonModalMinWidth to keep the surrounding page interactive at wider viewport sizes.

Responsive Drawer Rendered example
Responsive Drawer
@drawer.Drawer(drawer.Config{
    ID:               "responsiveDrawer",
    Title:            "Deployment details",
    NonModalMinWidth: 1100,
}) {
    <p>Ready for review</p>
}

Left Side

Set Side: drawer.SideLeft when the panel should enter from the navigation edge.

Left Side Rendered example
Left Side
@drawer.Drawer(drawer.Config{
    ID:    "filtersDrawer",
    Title: "Filters",
    Side:  drawer.SideLeft,
    Width: drawer.WidthSM,
			}) {
    <div id="filtersDrawer-body">...</div>
}

Top and Bottom

Use SideTop or SideBottom for navigation drawers, command surfaces, and mobile action trays. Height controls the vertical extent.

Top and Bottom Rendered example
Top and Bottom
@drawer.Drawer(drawer.Config{
    ID:     "mobileNavigation",
    Title:  "Navigation",
    Side:   drawer.SideTop,
    Height: drawer.HeightMD,
}) {
    <nav>...</nav>
}

Persistent Drawer

Set Persistent: true when the drawer hosts an unfinished form or confirmation flow. The close button still works, but backdrop clicks and Escape do not dismiss it.

Persistent Drawer Rendered example
Persistent Drawer
@drawer.Drawer(drawer.Config{
    ID:         "editProfile",
    Title:      "Edit profile",
    Persistent: true,
}) {
    <form id="editProfile-body">...</form>
}

HTMX Body Target

Give BodyID a stable value so HTMX responses can replace only the drawer body, then open the drawer with a drawer:open event or HX-Trigger header.

HTMX Body Target Rendered example
HTMX Body Target
@drawer.Drawer(drawer.Config{
    ID:     "orderDrawer",
    Title:  "Order details",
    BodyID: "orderDrawerBody",
}) {
    <div id="orderDrawerBody">Select an order.</div>
}

<button
    hx-get="/orders/42/drawer"
    hx-target="#orderDrawerBody"
    x-on:click="$dispatch('drawer:open', { id: 'orderDrawer' })">
    View order
</button>

Go API

development

The examples above cover behavior and composition. pkg.go.dev is the canonical reference for exported types, functions, methods, and Go documentation.

github.com/araihu/goshtoso/components/drawer

An exact external API link is added to versioned builds.