SaladUI.AlertDialog (SaladUI v1.0.0)

Copy Markdown View Source

Implementation of Alert Dialog component for SaladUI framework.

Alert Dialogs are modal dialogs that require a user action before they can be dismissed, used to confirm user decisions or provide critical information.

Examples:

<.alert_dialog id="delete-confirmation">
  <.alert_dialog_trigger>
    <.button variant="destructive">Delete Account</.button>
  </.alert_dialog_trigger>
  <.alert_dialog_content>
    <.alert_dialog_header>
      <.alert_dialog_title>Are you absolutely sure?</.alert_dialog_title>
      <.alert_dialog_description>
        This action cannot be undone. This will permanently delete your
        account and remove your data from our servers.
      </.alert_dialog_description>
    </.alert_dialog_header>
    <.alert_dialog_footer>
      <.alert_dialog_cancel>Cancel</.alert_dialog_cancel>
      <.alert_dialog_action>Continue</.alert_dialog_action>
    </.alert_dialog_footer>
  </.alert_dialog_content>
</.alert_dialog>

Component events

  • :on-open - Maps the open event. Fired when dialog enters open state.
  • :on-close - Maps the close event. Fired when dialog enters closed state.

Server commands

  • "open" - Opens the dialog.
  • "close" - Closes the dialog.

Summary

Functions

The main alert dialog component.

The primary action button for the alert dialog.

The cancel button for the alert dialog.

The content container of the alert dialog.

The description of the alert dialog.

The footer section of the alert dialog containing action buttons.

The header section of the alert dialog.

The title of the alert dialog.

The trigger element that opens the alert dialog.

Functions

alert_dialog(assigns)

The main alert dialog component.

Options

  • :id - Required unique identifier for the alert dialog.
  • :open - Whether the alert dialog is initially open. Defaults to false.
  • :on-open - Handler for open event. Accepts a server event name or %Phoenix.LiveView.JS{}.
  • :on-close - Handler for close event. Accepts a server event name or %Phoenix.LiveView.JS{}.
  • :class - Additional CSS classes.

Component events

  • :on-open - Fired when the dialog opens.
  • :on-close - Fired when the dialog closes.

Server commands

  • "open" - Opens the dialog.
  • "close" - Closes the dialog.

Attributes

  • id (:string) (required) - Unique identifier for the alert dialog.
  • open (:boolean) - Whether the alert dialog is initially open. Defaults to false.
  • on-open (:any) - Handler for alert dialog open event. Defaults to nil.
  • on-close (:any) - Handler for alert dialog close event. Defaults to nil.
  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_action(assigns)

The primary action button for the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • variant (:string) - Defaults to "default". Must be one of "default", "secondary", "destructive", "outline", "ghost", or "link".
  • size (:string) - Defaults to "default". Must be one of "default", "sm", "lg", or "icon".
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_cancel(assigns)

The cancel button for the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • variant (:string) - Defaults to "outline". Must be one of "default", "secondary", "destructive", "outline", "ghost", or "link".
  • size (:string) - Defaults to "default". Must be one of "default", "sm", "lg", or "icon".
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_content(assigns)

The content container of the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • aria-label (:string) - Defaults to "Alert dialog".
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_description(assigns)

The description of the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_footer(assigns)

The footer section of the alert dialog containing action buttons.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_header(assigns)

The header section of the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_title(assigns)

The title of the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

alert_dialog_trigger(assigns)

The trigger element that opens the alert dialog.

Attributes

  • class (:string) - Defaults to nil.
  • as (:any) - Defaults to "div".
  • Global attributes are accepted.

Slots

  • inner_block (required)