Skip to content

Overlay

A dimmed backdrop for content that needs focus.

Installation

Terminal
pnpm dlx shadcn@latest add \
  https://react-toolbox.io/r/overlay.json \
  https://react-toolbox.io/r/button.json

New here? Set up your project first. Styles, fonts, and required components are included. The command includes the components used by the examples below.

Usage

Overlay supplies a backdrop and scroll lock. Portal a full-screen backdrop to the document body and set its stacking level above your application’s chrome, as shown in the example. Use Dialog or Drawer for modal content with focus management.

State and callbacks

Set active to false in your click or Escape handler to dismiss the overlay. Use lockScroll to control background scrolling while it is active.

API reference

Key props and defaults. Full types and inline documentation are included with the source in material/overlay.

Overlay

Property Type Default
active boolean false
lockScroll boolean true
onEscKeyDown (event: KeyboardEvent) => void —

Material guidelines

  • A backdrop establishes separation between a modal surface and the underlying screen. It accompanies a dialog or temporary drawer rather than being a standalone task.
  • Prefer Dialog or Drawer for complete modal interactions. A custom composition must provide an accessible name, focus containment, and a clear dismissal path.

Material Design 1: Dialogs