Weftv0.4.0
GitHubFigma
Blade AI
Display & Navigation · Modalstable

Modal

A dialog on the native dialog element that interrupts the page for a focused task, with title, description, body and footer actions.

Preview

#preview

Switch size, description and backdrop behaviour, then open the live modal. Show code opens the React and CSS below.

Delete 3 files?

This removes them for everyone in the workspace.

size small · description on · backdrop closes
modal-example.tsx
import { Modal } from "@blade-ai/weft/components/modal";
import { Button } from "@blade-ai/weft/components/button";

export function DeleteModal({ isOpen, onClose }: Props) {
  return (
    <Modal
      isOpen={isOpen}
      onClose={onClose}
      title="Delete 3 files?"
      description="This removes them for everyone in the workspace."
      footer={
        <>
          <Button variant="secondary" size="small" onClick={onClose}>Cancel</Button>
          <Button size="small" onClick={onClose}>Delete</Button>
        </>
      }
    />
  );
}

All states

#all-states

The card for every size and content layout, shown inline. The live modal sits on the top layer over a dimmed backdrop.

Modal · 6 variants · static card
Delete 3 files?
This removes them for everyone in the workspace.
Small · 400
Rename workspace
Members see the new name straight away.
Medium · 560
Review payout batch
Check each line before you approve the batch.
Large · 760
Discard changes?
No description
Keyboard shortcuts
Press ? anywhere to open this list.
No footer
Invite a teammate
Form body

Props

#props

The app owns isOpen. onClose fires on Esc, the close button and, unless disabled, a backdrop click.

Prop
Type
Default
Description
isOpen *
boolean
—
Controls visibility. The app owns this state.
onClose *
() => void
—
Fires on Esc, the close button and (unless disabled) a backdrop click. Set isOpen to false in response.
title *
string
—
Heading; also the dialog's accessible name.
description
ReactNode
—
Supporting text under the title.
size
"small" | "medium" | "large"
"small"
Width 400 / 560 / 760px.
children
ReactNode
—
Body content slot between the header and footer.
footer
ReactNode
—
Right-aligned actions, usually a secondary and a primary Button (size small). Primary last.
closeOnBackdropClick
boolean
true
Closes on a click outside the card. Turn off for forms with unsaved input.
closeLabel
string
"Close"
Accessible name of the close button.
className
string
—
Extra classes on the card.

Usage

#usage

Short rules for using modal.

Do
Use a modal for one focused decision or short task.
Put the primary action last in the footer.
Turn off closeOnBackdropClick when a form has unsaved input.
Write the title as the action: Delete 3 files?
Don't
Don't open a modal from another modal.
Don't use it for long flows; use a full page or Drawer.
Don't use it for passing feedback; use Toast or Alert.
Don't fill the body with scrolling content.

Accessibility

#accessibility

Built on the native dialog: showModal() provides the focus trap, inert page, Esc and focus restore.

Keyboard
Key
Action
Tab / Shift+Tab
Cycles focus inside the dialog; the page behind is inert.
Enter / Space
Activates the focused button, including Close.
Esc
Fires onClose. The app decides whether to close.
ARIA
Element
Role / attribute
When
Dialog
native <dialog> (modal), aria-labelledby, aria-describedby
Labelled by the title; described by the description when present.
Title
<h2>
Always.
Close button
aria-label
Defaults to Close; set closeLabel to localise.
Backdrop
::backdrop
Page behind becomes inert while open.