Phoenix UI

Phoenix UI home page
  1. Getting Started
  2. Installation: Tailwind CLI

Alert

An alert displays a short, important message in a way that attracts the user's attention without interrupting the user's task.

Examples

Below you can view various demos with example markup.

Variant

The alert component comes with three variants: filled, outlined, and standard (default).

Severity

The alert component comes with four severities: error, warning, info (default), and success.

Title

You can use the :title slot to display a formatted title above the content.

Action

An alert can have an action, such as a close or undo button. It is rendered after the message, at the end of the alert.

If action phx-click or other Heroicon-specific attributes are set, a close icon is displayed. The action can be used as a slot to provide an alternative action, for example using a Button.

Icon

The icon prop allows you to add an icon to the beginning of the alert component. This will override the default icon for the specified severity.

Setting the icon to false will remove the icon altogether.

API

API documentation for the component. Learn about imports and available attributes.

Import

There are multiple ways to import components.


    # PhoenixUI macro which imports all components
    use PhoenixUI
    # Or import component individually
    import PhoenixUI.Components.Alert, only: [alert: 1]
    

Attributes

Below is a list of attributes that can be applied to the component.

Name Type Default Description
HTML attribute any Supports all HTML attributes.
action heroicon attrs | slot
content* inner_block | slot | string
extend_class string Adds additional classes.
icon heroicon attrs | slot []
phx-{any} binding Supports all Phoenix DOM element bindings.
severity string info
title string | slot
variant "filled" | "outlined" | "standard" standard