<div class="drawer" x-data="{ open: false }" @click.outside="open = false">
<input type="checkbox" :checked="open" class="drawer-toggle" />
<div class="drawer-content">
<button @click="open = true" class="btn">
Open drawer
</button>
</div>
<div class="drawer-side z-50">
<label class="drawer-overlay" @click="open = false"></label>
<div class="w-3/4">
<ul class="menu text-base-content">
<li><a>Sidebar Item 1</a></li>
<li><a>Sidebar Item 2</a></li>
</ul>
</div>
</div>
</div>
@jrmc.drawer()
@jrmc.drawer.content()
@!jrmc.button({ text: 'Open drawer', ...$context.event.open })
@end
@jrmc.drawer.side({ class: 'w-3/4' })
<ul class="menu text-base-content">
<li><a>Sidebar Item 1</a></li>
<li><a>Sidebar Item 2</a></li>
</ul>
@end
@end
Doc : daisyui drawer
Drawer sidebar can be visible by default on large screens or it can be toggleable on both large and small screens.
⚠️ Unlike the native daisyUI, AlpineJS is used to control the display
Class name | Type | |
---|---|---|
drawer | Component | Container element |
drawer-toggle | Component | For checkbox element that controls the drawer |
drawer-content | Component | The content container |
drawer-side | Component | The sidebar container |
drawer-overlay | Component | The label covers the content when drawer is open |
drawer-mobile | Modifier | Makes drawer to open/close on mobile but will be always visible on desktop |
drawer-end | Modifier | puts drawer to the right |