Components

Alert Dialog

Presents critical information or prompts to the user, typically requiring their attention or action.

Structure

	<script lang="ts">
  import { AlertDialog } from "bits-ui";
</script>
 
<AlertDialog.Root>
  <AlertDialog.Trigger />
  <AlertDialog.Portal>
    <AlertDialog.Overlay />
    <AlertDialog.Content>
      <AlertDialog.Title />
      <AlertDialog.Description />
      <AlertDialog.Cancel />
      <AlertDialog.Action />
    </AlertDialog.Content>
  </AlertDialog.Portal>
</AlertDialog.Root>
	<script lang="ts">
  import { AlertDialog } from "bits-ui";
</script>
 
<AlertDialog.Root>
  <AlertDialog.Trigger />
  <AlertDialog.Portal>
    <AlertDialog.Overlay />
    <AlertDialog.Content>
      <AlertDialog.Title />
      <AlertDialog.Description />
      <AlertDialog.Cancel />
      <AlertDialog.Action />
    </AlertDialog.Content>
  </AlertDialog.Portal>
</AlertDialog.Root>

Component API

Root

The root component used to set and manage the state of the alert dialog.

Prop Default Type/Description
preventScroll true boolean

Whether or not to prevent scroll on the body when the alert dialog is open.

closeOnEscape true boolean

Whether to close the alert dialog when the escape key is pressed.

closeOnOutsideClick true boolean

Whether to close the alert dialog when a click occurs outside of it.

open false boolean

Whether or not the alert dialog is open.

onOpenChange

-

(open: boolean) => void

A callback function called when the open state changes.

Trigger

The element which opens the alert dialog on press.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Content

The content displayed within the alert dialog modal.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Data Attribute Value/Description
data-state 'open' | 'closed'

The state of the alert dialog.

Overlay

An overlay which covers the body when the alert dialog is open.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Data Attribute Value/Description
data-state 'open' | 'closed'

The state of the alert dialog.

Portal

A portal which renders the alert dialog into the body when it is open.

Action

A button used to close the alert dialog by taking an action.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Cancel

A button used to close the alert dialog without taking an action.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Title

An accessibile title for the alert dialog.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

Description

An accessibile description for the alert dialog.

Prop Default Type/Description
asChild false boolean

Whether to use render delegation with this component or not.

🚧 UNDER CONSTRUCTION 🚧