Zubra UI
Code for
GitHub

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.

Clear Show 24 results

Try it: events appear here (openchange).

Source: side-sheet.zb, and its registry item.

Install

Compiled (any project)
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
One file, no dependencies (4.8 KB gzipped)
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
.zb source (to edit it with Zubra)
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
No build: a script tag, straight from this site
HTML
<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

index.html
<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>
Example.jsx
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>
    </>
  );
}
Example.vue
<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('-') } } }) -->
Example.svelte
<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>
example.component.ts
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

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
openbooleanfalse
side"right" | "left" | "bottom""right"
labelstring"Panel"
Events
EventWhen
openchangeopen changed; detail is the new value.
Slots
SlotFor
(default)The panel's content.
actionsButtons pinned to the bottom, shown only when given. One with data-close closes it.
headingIts 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.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour