Drawer

Bottom/side drawer panel with new DrawerTrigger and DrawerContent subcomponents.

v0.3.0 adds DrawerTrigger and DrawerContent subcomponents. Side is set on <Drawer> itself. You can also bind @bind-Open to control open state externally — useful when you need a close button inside the content.

What changed from v0.2.x

v0.2.1 v0.3.0
External IsOpen + button required <DrawerTrigger> lives inside <Drawer>
Manual open state field State fully encapsulated (or opt-in via @bind-Open)

Installation

bash
shellui add drawer

Usage

Basic

<Drawer Side="DrawerSide.Bottom">
    <DrawerTrigger>
        <Button Variant="ButtonVariant.Outline">Open Drawer</Button>
    </DrawerTrigger>
    <DrawerContent>
        <div class="p-4 space-y-4">
            <h3 class="text-lg font-semibold">Cart</h3>
            <p class="text-sm text-muted-foreground">Your cart is empty.</p>
            <Button Class="w-full">Continue Shopping</Button>
        </div>
    </DrawerContent>
</Drawer>

With external open control (@bind-Open)

Use @bind-Open when you need a close button inside the content, or to control the drawer from outside:

<Drawer @bind-Open="_drawerOpen" Side="DrawerSide.Bottom">
    <DrawerTrigger>
        <Button Variant="ButtonVariant.Outline">Open Drawer</Button>
    </DrawerTrigger>
    <DrawerContent>
        <h4 class="font-semibold">Drawer Title</h4>
        <p class="text-sm text-muted-foreground">Drawer content here.</p>
        <Button @onclick="() => _drawerOpen = false">Close</Button>
    </DrawerContent>
</Drawer>

@code {
    private bool _drawerOpen = false;
}

Side variants

<Drawer Side="DrawerSide.Right">
    <DrawerTrigger><Button>Open Right</Button></DrawerTrigger>
    <DrawerContent><p>Slides from the right.</p></DrawerContent>
</Drawer>

New in v0.4: DrawerHeader, DrawerTitle, DrawerDescription, DrawerFooter and DrawerClose structure the drawer. Anything wrapped in DrawerClose closes it when clicked.

<Drawer @bind-Open="open" Compositional="true">
    <DrawerTrigger>
        <Button Variant="ButtonVariant.Outline">Set a goal</Button>
    </DrawerTrigger>
    <DrawerContent>
        <DrawerHeader>
            <DrawerTitle>Daily goal</DrawerTitle>
            <DrawerDescription>How many steps do you want to walk today?</DrawerDescription>
        </DrawerHeader>
        <div class="flex justify-center p-4">
            <NumberInput @bind-Value="steps" Min="1000" Max="30000" Step="500" />
        </div>
        <DrawerFooter>
            <DrawerClose>
                <Button Class="w-full">Save</Button>
            </DrawerClose>
            <DrawerClose>
                <Button Variant="ButtonVariant.Outline" Class="w-full">Cancel</Button>
            </DrawerClose>
        </DrawerFooter>
    </DrawerContent>
</Drawer>

@code {
    private bool open;
    private decimal? steps = 8000;
}
Compositional mode

<Drawer> switches to the parts when Title and Description are both empty, in the NuGet package and, from 0.4.0-alpha.3, in the CLI template. Compositional="true" turns it on explicitly. Before alpha.3, CLI components needed the flag.

API Reference

<Drawer>

Parameter Type Default Description
Side DrawerSide Bottom Which edge the drawer slides from
Open bool false Bind with @bind-Open to control open state externally
OpenChanged EventCallback<bool> — Fires when open state changes
ChildContent RenderFragment — DrawerTrigger + DrawerContent

<DrawerTrigger>

Parameter Type Default Description
ChildContent RenderFragment — Trigger button content

<DrawerContent>

Parameter Type Default Description
ChildContent RenderFragment — Drawer body content

Structure parts

Component Purpose
DrawerHeader Wraps the title and description
DrawerTitle The heading
DrawerDescription The supporting text
DrawerFooter Wraps the actions at the bottom
DrawerClose Closes the drawer when its content is clicked

Each takes ChildContent; all but DrawerClose also take Class. Drawer has a Compositional flag (bool, default false) to select this mode.

DrawerSide enum

Top · Bottom · Left · Right

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.