Tally UI
Primitives

AlertDialog

A modal dialog for important confirmations that requires an explicit response.

Import

import { AlertDialog } from '@tallyui/primitives';

Usage

<AlertDialog.Root open={open} onOpenChange={setOpen}>
  <AlertDialog.Trigger>
    <Text>Delete Account</Text>
  </AlertDialog.Trigger>
  <AlertDialog.Portal>
    <AlertDialog.Overlay />
    <AlertDialog.Content>
      <AlertDialog.Title>Are you sure?</AlertDialog.Title>
      <AlertDialog.Description>This action is permanent.</AlertDialog.Description>
      <AlertDialog.Cancel>
        <Text>Cancel</Text>
      </AlertDialog.Cancel>
      <AlertDialog.Action>
        <Text>Delete</Text>
      </AlertDialog.Action>
    </AlertDialog.Content>
  </AlertDialog.Portal>
</AlertDialog.Root>

Components

AlertDialog.Root

Manages the open/closed state. Does not render a DOM element.

PropTypeDefaultDescription
openbooleanControlled open state
defaultOpenbooleanfalseInitial state (uncontrolled)
onOpenChange(open: boolean) => voidCalled when open state changes

AlertDialog.Trigger

A pressable that opens the alert dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

AlertDialog.Portal

Renders children into a portal.

PropTypeDefaultDescription
forceMounttrueAlways mount portal content
hostNamestringTarget portal host name

AlertDialog.Overlay

A backdrop layer behind the content.

PropTypeDefaultDescription
forceMounttrueAlways render the overlay
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

AlertDialog.Content

The alert dialog panel.

PropTypeDefaultDescription
forceMounttrueAlways render the content
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native ViewProps.

AlertDialog.Title

An accessible title for the alert dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native TextProps.

AlertDialog.Description

An accessible description for the alert dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native TextProps.

AlertDialog.Action

A pressable for the confirming action. Closes the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

AlertDialog.Cancel

A pressable for the cancellation action. Closes the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Accessibility

  • Role: alertdialog
  • ARIA: aria-modal, aria-labelledby (linked to Title), aria-describedby (linked to Description)
  • Unlike Dialog, clicking the overlay does not close an AlertDialog -- the user must pick an explicit action
  • Escape key does not close an AlertDialog on web

On this page