Skip to content
Storybook

Modal

Dialog that blocks the page for a focused task or confirmation. Built on native <dialog>.

Preview

React · live from the Storybook

HTML and CSS

The same component as plain HTML with pixels-ui.css, no framework needed.

Create new project

Please enter a name for this project.

Usage

  • Use for short tasks; long forms belong on a page or in a Drawer.

Installation

Included in the core files. No extra install.

HTML
<link rel="stylesheet" href="/css/pixels-tokens.css">
<link rel="stylesheet" href="/css/pixels-ui.css">
<script src="/js/pixels-ui.js" defer></script>

Examples

Destructive

px-modal--destructive.

Delete project?

This project and its files will be deleted. This can’t be undone.

API reference

Class / attributeTypeDescription
dialog.px-modal · --md · --lg · --destructiveclassSize and type.
data-px-open="id"attributeOpens the dialog with showModal().
data-px-closeattributeCloses it. Backdrop click and Escape close too.
__body · __icon · __title · __desc · __foot · __closeclassSlots.

Figma properties

Modal12 variants · page “Overlays”Open

Dialog that blocks the page for a focused task or confirmation. Width from --px-modal-width-*; place over --px-overlay-scrim. role=dialog + aria-modal, trap focus, Escape closes, return focus to the t…

PropertyTypeValues
TitleText“Create new project”
DescriptionText“Please enter a name for this project.”
Featured iconBoolean—
ContentBoolean—
Content swapInstance swap—
SizeVariantSmall Medium Large
TypeVariantDefault Destructive
DirectionVariantLTR RTL

Design tokens

Component tokens from the Figma Component collection. Override them to restyle just this component.

TokenAliasLight value
--px-modal-dividercolor-border-neutral-subtle#f2f4f7
--px-modal-radiusradius-xl16px
--px-modal-paddingspacing-2xl24px
--px-modal-width-sm400px400px
--px-modal-width-md560px560px
--px-modal-width-lg720px720px

Accessibility

  • showModal() traps focus and sets the rest of the page inert.
  • Label with aria-labelledby; focus returns to the trigger.