Tally UI
Primitives

Dialog

A modal window that overlays the main content and requires user interaction.

Import

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

Usage

<Dialog.Root open={open} onOpenChange={setOpen}>
  <Dialog.Trigger>
    <Text>Open Dialog</Text>
  </Dialog.Trigger>
  <Dialog.Portal>
    <Dialog.Overlay />
    <Dialog.Content>
      <Dialog.Title>Edit Profile</Dialog.Title>
      <Dialog.Description>Make changes to your profile.</Dialog.Description>
      <Dialog.Close>
        <Text>Close</Text>
      </Dialog.Close>
    </Dialog.Content>
  </Dialog.Portal>
</Dialog.Root>

Components

Dialog.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

Dialog.Trigger

A pressable that opens the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Dialog.Portal

Renders children into a portal. On native, this uses PortalHost.

PropTypeDefaultDescription
forceMounttrueAlways mount portal content
hostNamestringTarget portal host name

Dialog.Overlay

A backdrop layer behind the content. Typically used for dimming.

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

Plus all React Native ViewProps.

Dialog.Content

The dialog panel that contains the main content.

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

Plus all React Native ViewProps.

Dialog.Title

An accessible title for the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native TextProps.

Dialog.Description

An accessible description for the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native TextProps.

Dialog.Close

A pressable that closes the dialog.

PropTypeDefaultDescription
asChildbooleanfalseMerge props onto child instead of rendering

Plus all React Native PressableProps.

Accessibility

  • Role: dialog
  • ARIA: aria-modal, aria-labelledby (linked to Title), aria-describedby (linked to Description)
  • Focus is trapped inside the dialog on web
  • Escape key closes the dialog on web

Examples

Controlled

function ConfirmDialog() {
  const [open, setOpen] = React.useState(false);

  return (
    <Dialog.Root open={open} onOpenChange={setOpen}>
      <Dialog.Trigger>
        <Text>Delete Item</Text>
      </Dialog.Trigger>
      <Dialog.Portal>
        <Dialog.Overlay />
        <Dialog.Content>
          <Dialog.Title>Confirm deletion</Dialog.Title>
          <Dialog.Description>This action cannot be undone.</Dialog.Description>
          <Dialog.Close>
            <Text>Cancel</Text>
          </Dialog.Close>
        </Dialog.Content>
      </Dialog.Portal>
    </Dialog.Root>
  );
}

On this page