side-sheet
A panel that slides in from the edge of the screen (side: right, left or bottom), on the native <dialog>: the page behind is inert, focus moves in and back, and Escape, the close button or a click outside closes it. For filters, a cart, settings, or a menu on a phone. open is two-way.
Show only what you need.
Try it: events appear here (openchange).
Source: side-sheet.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/side-sheet.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/side-sheet.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/side-sheet.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/side-sheet.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/side-sheet.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/side-sheet.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/side-sheet.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/side-sheet.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/side-sheet.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/side-sheet.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/side-sheet.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/side-sheet.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/side-sheet.js"></script>The compiled install writes src/components/zubra/side-sheet.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<button type="button" id="open-side-sheet">Filters</button>
<side-sheet label="Filters" side="right">
<p>Show only what you need.</p>
<action-button slot="actions" variant="ghost" data-close>Clear</action-button>
<action-button slot="actions" data-close>Show 24 results</action-button>
</side-sheet>
<script type="module">
import './components/zubra/side-sheet.js';
import './components/zubra/action-button.js';
const element = document.querySelector('side-sheet');
element.open = false;
element.addEventListener('openchange', (event) => console.log('openchange', event.detail));
document.querySelector('#open-side-sheet').addEventListener('click', () => { element.open = true; });
</script>import './components/zubra/side-sheet.js';
import './components/zubra/action-button.js';
import { useState } from 'react';
export function SideSheetExample() {
const [open, setOpen] = useState(false);
return (
<>
<button type="button" onClick={() => setOpen(true)}>Filters</button>
<side-sheet
label="Filters"
side="right"
open={open}
onopenchange={(event) => setOpen(event.detail)}
>
<p>Show only what you need.</p>
<action-button slot="actions" variant="ghost" data-close>Clear</action-button>
<action-button slot="actions" data-close>Show 24 results</action-button>
</side-sheet>
</>
);
}<script setup>
import { ref } from 'vue';
import './components/zubra/side-sheet.js';
import './components/zubra/action-button.js';
const open = ref(false);
</script>
<template>
<button type="button" @click="open = true">Filters</button>
<side-sheet
label="Filters"
side="right"
:open.prop="open"
@openchange="open = $event.detail"
>
<p>Show only what you need.</p>
<action-button slot="actions" variant="ghost" data-close>Clear</action-button>
<action-button slot="actions" data-close>Show 24 results</action-button>
</side-sheet>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/side-sheet.js';
import './components/zubra/action-button.js';
let open = $state(false);
</script>
<button type="button" onclick={() => (open = true)}>Filters</button>
<side-sheet
label="Filters"
side="right"
{open}
onopenchange={(event) => (open = event.detail)}
>
<p>Show only what you need.</p>
<action-button slot="actions" variant="ghost" data-close>Clear</action-button>
<action-button slot="actions" data-close>Show 24 results</action-button>
</side-sheet>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/side-sheet.js';
import './components/zubra/action-button.js';
@Component({
selector: 'app-side-sheet-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<button type="button" (click)="open = true">Filters</button>
<side-sheet
label="Filters"
side="right"
[open]="open"
(openchange)="open = $any($event).detail"
>
<p>Show only what you need.</p>
<action-button slot="actions" variant="ghost" data-close>Clear</action-button>
<action-button slot="actions" data-close>Show 24 results</action-button>
</side-sheet>
`,
})
export class SideSheetExample {
open = false;
}API
| Property | Type | Default |
|---|---|---|
open | boolean | false |
side | "right" | "left" | "bottom" | "right" |
label | string | "Panel" |
| Event | When |
|---|---|
openchange | open changed; detail is the new value. |
| Slot | For |
|---|---|
(default) | The panel's content. |
actions | Buttons pinned to the bottom, shown only when given. One with data-close closes it. |
heading | Its title, which labels it (defaults to label). |
Size
1.7 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 18.4 KB.