Skip to content
Stylhero 0.8.0
Components

Core

Layout and type

Inputs

Overlays

Navigation

Data display

Charts

Transitions and utilities

Page pieces (landing pages, portfolios, docs)

Icons

Components / Overlays

Drawer

Side panel built on the native <dialog>, like Dialog: for filters, details and mobile navigation.

import { Drawer } from "@stylhero/ui";

Example

Code
import { useState } from "react";
import { Button, CheckboxGroup, Drawer } from "@stylhero/ui";

function DrawerExample() {
  const [open, setOpen] = useState(false);
  return (
    <>
      <Button onClick={() => setOpen(true)}>Filters</Button>
      <Drawer open={open} onClose={() => setOpen(false)} title="Filters" footer={<Button fullWidth onClick={() => setOpen(false)}>Show results</Button>}>
        <CheckboxGroup legend="Brand" options={["AMD", "Intel", "NVIDIA"]} />
      </Drawer>
    </>
  );
}

Props

PropTypeDefaultDescription
onClose required () => void -
open required boolean -
title required ReactNode -
children ReactNode -
side "right" | "left" | "bottom" "right" Which edge it slides from. Bottom becomes a sheet on phones.

Also takes every <dialog> attribute (id, style, data-*, aria-*, event handlers…), passed to that element.

Keyboard

KeyDoes
TabStays inside the drawer
EscCloses it (calls onClose)

Accessibility

  • Built on the native <dialog> opened with showModal(): the browser traps focus, makes the page behind it inert and returns focus to the opener on close.
  • Labelled by its title.

Generated from src/components/Drawer.tsx. Something wrong or missing? Open an issue.