FeedbackNew
Glass Alert
A tinted glass message with four tones, an icon and an optional dismiss button.
Preview
Heads up
Your trial ends in three days.
Saved
Every change is in.
Almost full
You have used 92% of your storage.
Payment failed
Update your card to keep your plan.
Demos ready. Update 0.
The preview runs the React version. On iOS 26 and later, the React Native version uses the system’s own glass. See it on a phone.
Installation
For React 19+ apps with Tailwind CSS 4.
npx shadcn@4.14.1 add @glassyui/glass-alertAdds 5 files to components/glassyui and installs clsx.
Usage
Usage
import { GlassAlert } from "@/components/glassyui/glass-alert";
export function TrialAlert() {
return <GlassAlert title="Heads up">Your trial ends in three days.</GlassAlert>;
}React Native usage
import { useState } from 'react';
import { GlassAlert } from '@/components/glassyui/glass-alert';
export default function AlertExample() {
const [visible, setVisible] = useState(true);
if (!visible) return null;
return (
<GlassAlert onDismiss={() => setVisible(false)} title="Payment failed" tone="danger">
Update your card to keep your plan.
</GlassAlert>
);
}
Examples
Tones
<GlassAlert tone="success" title="Saved">Every change is in.</GlassAlert>
<GlassAlert tone="warning" title="Almost full">92% of your storage is used.</GlassAlert>
<GlassAlert tone="danger" title="Payment failed">Update your card.</GlassAlert>Dismissible
<GlassAlert title="New version" onDismiss={() => setShown(false)}>
Reload to get it.
</GlassAlert>API reference
GlassAlert
className, ref and other props reach the inner alert. Space stacked dismissible alerts with margin, not a parent gap, so the space folds away with them.
| Prop | Type | Default | Description |
|---|---|---|---|
tone | 'info' | 'success' | 'warning' | 'danger' | 'info' | Colour, icon and announcement role. |
title | ReactNode | None | A bold line above the message. |
icon | ReactNode | false | tone icon | Replaces the tone's decorative icon; false shows none. |
onDismiss | () => void | None | Shows a close button and runs after the alert folds away; remove the alert here and give each alert a stable key. |
dismissLabel | string | 'Dismiss' | Accessible name of the close button. |
role | string | 'alert' for warning and danger, else 'status' | Overrides the announcement role. |
Also accepts HTML div attributes, with title replaced.
- Types
GlassAlertPropsGlassAlertTone- Accessibility
- warning and danger use role alert and interrupt screen readers, while info and success use role status; pass role to change that.
The React Native props and exports are in the component’s source.