Toast
Controlled status feedback. Applications own visibility and removal.
File uploaded
import { Toast } from "density-base-ui";
export default function ToastDefaultExample() {
return <Toast title="File uploaded" />;
}Color
Set color to destructive, warning, or success for semantic toast feedback.
Upload failed
Storage almost full
File uploaded
import { Toast, View } from "density-base-ui";
export default function ToastColorExample() {
return (
<View>
<Toast color="destructive" title="Upload failed" />
<Toast color="warning" title="Storage almost full" />
<Toast color="success" title="File uploaded" />
</View>
);
}Content slots
import { Toast } from "density-base-ui";
export default function ToastContentExample() {
return (
<Toast
childrenEnd={<a href="#view">View</a>}
childrenStart="✓"
subtitle="Your file is ready to share."
title="File uploaded"
/>
);
}Controlled dismissal
Dismissable toast
import { Toast } from "density-base-ui";
export default function ToastDismissableExample() {
return <Toast dismissable title="Dismissable toast" />;
}Subtitle
File uploaded
Your file is ready to share.
import { Toast } from "density-base-ui";
export default function ToastSubtitleExample() {
return (
<Toast subtitle="Your file is ready to share." title="File uploaded" />
);
}Leading content
File uploaded
import { Toast } from "density-base-ui";
import { Check } from "lucide-react";
export default function ToastChildrenStartExample() {
return (
<Toast
childrenStart={<Check aria-hidden="true" size={16} />}
title="File uploaded"
/>
);
}Trailing content
File uploaded
import { Toast, Button } from "density-base-ui";
export default function ToastChildrenEndExample() {
return <Toast childrenEnd={<Button>View</Button>} title="File uploaded" />;
}Size
import { Toast } from "density-base-ui";
import "./ToastOptionsExample.css";
export default function ToastSizeExample() {
return (
<div className="toast-options-example">
{(["2xs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"] as const).map(
(size) => (
<Toast
key={size}
size={size}
subtitle="Title and Close control follow this size."
title={`Size: ${size}`}
/>
),
)}
</div>
);
}Depth
import { Toast } from "density-base-ui";
import "./ToastOptionsExample.css";
export default function ToastDepthExample() {
return (
<div className="toast-options-example">
{(["1", "2", "3", "4", "5", "6", "7"] as const).map((depth) => (
<Toast
depth={depth}
key={depth}
subtitle="Depth controls surface elevation."
title={`Depth: ${depth}`}
/>
))}
</div>
);
}| Prop | Values | Required | Default | Behavior | Description |
|---|---|---|---|---|---|
childrenEnd | ReactNode | Not required | — | — | — |
childrenStart | ReactNode | Not required | — | — | — |
color | destructive, warning, success | Not required | — | — | — |
depth | 1, 2, 3, 4, 5, 6, 7 | Not required | "4" | — | — |
dismissable | false, true | Not required | false | — | — |
onOpenChange | (open: boolean) => void | Not required | — | — | — |
open | false, true | Not required | true | — | — |
size | 2xs, xs, sm, md, lg, xl, 2xl, 3xl | Not required | — | — | — |
subtitle | ReactNode | Not required | — | — | — |
title | ReactNode | Required | — | — | — |