Modal

Dark Mode
Accessibility

A conditional modal component with built-in accessibility features.

API Reference

No API reference available.

Accessibility

The Modal component includes several accessibility features:

  • Semantic HTML: Uses the native
    <dialog>
    element for proper screen reader support
  • Focus Management: Automatically focuses elements with
    autofocus
    attribute, or the modal content itself
  • Focus Restoration: Can restore focus to the triggering element when closed using the
    triggeredBy
    prop
  • Keyboard Navigation: Supports ESC key to close the modal
  • ARIA Attributes: Includes
    aria-labelledby
    when a title is provided
  • Click Outside to Close: Users can click outside the modal to close it
  • Proper Focus Trapping: Focus remains within the modal while it's open

Examples

Actions

Nested Modals

Fallback Implementation

The Modal component automatically detects browser support for the native

<dialog>
element and falls back to an overlay-based implementation for older browsers. You can also manually force the fallback behavior using the
useDialog
prop.

Changelog

03. Nov 2021

  • Updated layout according to the latest design
  • Introducing the
    actions
    prop that renders a sticky action bar at the bottom of the Modal
  • Added Dark Mode support