Markdown:
Components

Drawer

Display a content that slides in from the side of the screen.

Hello!!

Usage

Use standalone.

Svelte
<Drawer {...props}>Content</Drawer>

Anatomy

The class attribute values represent part names. Other attributes represent their corresponding props.

Svelte
<dialog class="whole" {...rest} {style}>
  {children}
</dialog>

Props

NameTypeDefaultDescription
children*Snippet-Drawer content; receives the variant as its argument
openbooleanfalseBindable open state
positionPosition"left"Specifies where to display the Drawer
sizestring"auto"Specifies a valid CSS value for the Drawer width or height
durationnumber200Animation duration in milliseconds
cssvarRecord-Renames the published animation-timing custom property; cssvar.duration makes the Drawer read --svs-duration from a caller-named token
closablebooleantrueWhether light dismiss is enabled; false creates a forced-action modal with no light-dismiss or Escape
ariaLabelstring-Accessible label for the dialog
elementHTMLDialogElement-Bindable root element
stylingSVSClass-Styling override
variantSVSVariantNEUTRALDrawer variant

* required. Other HTMLDialogAttributes are passed to <dialog> via rest props; class is merged onto the root.

If size is omitted, auto is used. It's recommended to specify the size explicitly, since the CSS property interpolate-size: allow-keywords;, which is not yet supported by some browsers, is applied when using auto.

Drawer is a native modal <dialog> opened with showModal(): focus is trapped and background content is inert while open, and page scroll is locked with :root:has(dialog[open]).

Styling

In this component, margin and padding cannot be used for the whole part. To learn more, see Styling.

Variant Management

No automatic switching.

Default Class Name

svs-drawer

Behavior

Drawer is modal: focus is trapped and background siblings are inert while open by native dialog behavior. closable=false creates a forced-action modal (no light-dismiss/Escape). Open/close animation timing is published as --svs-duration for caller CSS; cssvar.duration renames it (caller then owns reduced-motion for that token).

Accessibility

ARIA Roles and Attributes

The component applies these automatically:

  • Dialog (whole <dialog>): aria-label from the ariaLabel prop.

Provide an accessible name yourself because there is no built-in visible label. Pass ariaLabel, or pass aria-labelledby through the rest props. The managed aria-label attribute is omitted from DrawerProps and cannot be passed as aria-label.

Standards Basis

Drawer is built on a native <dialog> opened with showModal(), so keyboard and assistive-technology support follows the browser standard for modal dialogs. See the Concepts standards-first guidance for the library's approach. When closable is false, the component prevents the native Escape light-dismiss.

Exports

Types

TypeScript
type Position = "top" | "right" | "bottom" | "left";
type DrawerCssVar = "duration";
interface DrawerProps extends Omit<HTMLDialogAttributes, "children" | "style" | "aria-label"> {
  children: Snippet<[string]>; // Snippet<[variant]>
  open?: boolean; // bindable (false)
  position?: Position; // ("left")
  size?: string; // ("auto")
  duration?: number; // (200)
  cssvar?: Partial<Record<DrawerCssVar, string>>;
  closable?: boolean; // (true)
  ariaLabel?: string;
  element?: HTMLDialogElement; // bindable
  styling?: SVSClass;
  variant?: SVSVariant; // (VARIANT.NEUTRAL)
  // other HTMLDialogAttributes are passed to <dialog> via ...rest; `class` is merged onto root
  // style is component-owned (omitted)
}
type DrawerReqdProps = "children";
type DrawerBindProps = "open" | "element";

Others

No additional exports are available.

Examples

The example code uses Tailwind CSS along with SVSClass.

Basic

Hello!!

With Interactive Variant

Preset for Demo
Enter variant as you like
Drawer Title

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.