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.
| Method | Type | Default | Description |
|---|---|---|---|
.description(text) | impl Into<SharedString> | — | Description text |
.variant(variant) | AlertVariant | Default | Visual style |
AlertVariant
| Variant | Style |
|---|---|
Default | bg WHITE, ZINC_200 border, ZINC_900 title, ZINC_500 description |
Destructive | bg 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.