Skip to content

Alert

A callout banner for user attention. Two variants.

When to use

  • A Default alert for neutral, informational messages.
  • A Destructive alert for errors or irreversible actions.

API

Alert::new(title)

Creates an alert with the given title.

MethodTypeDefaultDescription
.description(text)impl Into<SharedString>Description text
.variant(variant)AlertVariantDefaultVisual style

AlertVariant

VariantStyle
Defaultbg WHITE, ZINC_200 border, ZINC_900 title, ZINC_500 description
Destructivebg RED_50, RED_500 border, RED_600 title and description

Usage

rust
use gpui::{Component, div, prelude::*};
use components::{Alert, AlertVariant};

div().child(Component::new(
    Alert::new("Alert Title")
        .description("This is an alert description.")
        .variant(AlertVariant::Destructive),
))

Copy the source

crates/components/src/alert.rs — self-contained, stateless, and free to modify.

Released under the MIT License.