The default slot holds the trigger; open it from any element inside with @click="drawerOpen = true". Put the body in the content slot and any actions in the footer slot.
Update your profile and preferences.
Drawer body content goes here. It scrolls if it grows taller than the panel.
<c-ui.drawer title="Account details" description="Update your profile and preferences.">
<c-ui.button @click="drawerOpen = true">Open drawer</c-ui.button>
<c-slot name="content">
Drawer body content goes here.
</c-slot>
<c-slot name="footer">
<div class="flex justify-end gap-2">
<c-ui.button @click="drawerOpen = false">Cancel</c-ui.button>
<c-ui.button variant="primary" @click="drawerOpen = false">Save</c-ui.button>
</div>
</c-slot>
</c-ui.drawer>
{% cotton ui.drawer title="Account details" description="Update your profile and preferences." %}
{% cotton ui.button @click="drawerOpen = true" %}Open drawer{% endcotton %}
{% cotton:slot content %}
Drawer body content goes here.
{% endcotton:slot %}
{% cotton:slot footer %}
<div class="flex justify-end gap-2">
{% cotton ui.button @click="drawerOpen = false" %}Cancel{% endcotton %}
{% cotton ui.button variant="primary" @click="drawerOpen = false" %}Save{% endcotton %}
</div>
{% endcotton:slot %}
{% endcotton %}
side opens the drawer from right (default), left, top or bottom.
Slides in from the right.
Slides in from the left.
Slides in from the top.
Slides in from the bottom.
<c-ui.drawer title="Filters" side="left">
<c-ui.button @click="drawerOpen = true">Filters</c-ui.button>
<c-slot name="content">...</c-slot>
</c-ui.drawer>
{% cotton ui.drawer title="Filters" side="left" %}
{% cotton ui.button @click="drawerOpen = true" %}Filters{% endcotton %}
{% cotton:slot content %}...{% endcotton:slot %}
{% endcotton %}
size sets the panel width from sm to 2xl (for top/bottom drawers it sets the height instead). For a one-off, pass max_size with any CSS length, it applies an inline max-width/height, so it works without a matching Tailwind class.
size="sm"
size="md" (default)
size="lg"
size="xl"
size="2xl"
A narrow custom width (16rem), smaller than the sm scale, via inline style.
{# named scale #}
<c-ui.drawer size="lg"> ... </c-ui.drawer>
{# one-off custom width (any CSS length) #}
<c-ui.drawer max_size="16rem"> ... </c-ui.drawer>
{# named scale #}
{% cotton ui.drawer size="lg" %} ... {% endcotton %}
{# one-off custom width (any CSS length) #}
{% cotton ui.drawer max_size="16rem" %} ... {% endcotton %}
| Name | Description | Type | Options | Default |
|---|---|---|---|---|
title |
Heading shown at the top of the panel. | str | — | |
description |
Sub-text under the title. | str | — | |
side |
Edge the drawer slides in from. | str |
rightlefttopbottom
|
right |
size |
Panel width (left/right) or height (top/bottom). | str |
smmdlgxl2xl
|
md |
max_size |
Custom panel size as a CSS length (e.g. 34rem), applied inline. Overrides size. | str | — | |
:dismissible |
Allow closing by clicking the overlay or pressing Escape. | bool |
TrueFalse
|
True |
:close_button |
Show the close (X) button in the header. | bool |
TrueFalse
|
True |
:open |
Open on load. The open state is exposed via x-modelable for x-model binding. | bool |
TrueFalse
|
False |
| Name | Description | Type | Options | Default |
|---|---|---|---|---|
default |
Holds the trigger. Use @click="drawerOpen = true" to open. | slot | — | |
content |
The panel body (scrolls). | slot | — | |
footer |
Pinned footer for actions. | slot | — |