Alert
An alert shows a message that stays on the page until its cause is gone, such as a rejected release or a subscription about to end.
When to use
Section titled “When to use”- Use it for a state of the page or the account that people need to see while they work.
- Use a Toast to confirm an action that just happened; a toast goes away by itself.
- Show validation errors under their field with a Field, not in an alert. A form may add one
destructivealert at the top when the backend refuses the whole form. - Write a short title and one sentence that says what to do.
Laporan bulan ini sudah siap
Kamu bisa mengunduhnya dari menu Royalti.
Rilis dijadwalkan
"Senja di Kota" tayang 1 Des 2026 pukul 00.00 WIB.
Rilis terkirim
Semua toko musik sudah menerima "Kaset Pertama".
Langgananmu hampir habis
Masa langgananmu habis 3 hari lagi.
Rilis ditolak
Sampulnya belum sesuai aturan toko musik.
Laporan bulan ini sudah siap
Kamu bisa mengunduhnya dari menu Royalti.
Rilis dijadwalkan
"Senja di Kota" tayang 1 Des 2026 pukul 00.00 WIB.
Rilis terkirim
Semua toko musik sudah menerima "Kaset Pertama".
Langgananmu hampir habis
Masa langgananmu habis 3 hari lagi.
Rilis ditolak
Sampulnya belum sesuai aturan toko musik.
Anatomy
Section titled “Anatomy”- 1Container in a soft status color
- 2Icon
- 3Title
- 4Description
An icon on the left, a title and a description, on radius-lg with px-4 py-3. The status variants sit on the soft status surface with the icon and title in the status color and the description in foreground; default sits on card with a border.
Variants
Section titled “Variants”| Variant | Use it for |
|---|---|
default |
Neutral news, such as a report that is ready. |
info |
Something to know, such as a scheduled release. |
success |
A state that turned out well, such as a delivered release. |
warning |
Something that needs attention soon, such as a subscription about to end. |
destructive |
Something that failed or was refused, such as a rejected release. |
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
variant |
variant |
ShadAlert / ShadAlert.destructive, status colors from context.sosialoka |
text | default |
The status. |
AlertTitle |
AlertTitle |
title |
text | none | The short title. |
AlertDescription |
AlertDescription |
description |
text | none | One sentence on what to do. |
| icon as the first child | icon as the first child | icon |
element | none | A Lucide icon for the status. |
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon, type LucideIcon } from "lucide-react"import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
const alerts: { variant: "default" | "info" | "success" | "warning" | "destructive"; icon: LucideIcon; title: string; description: string }[] = [ { variant: "default", icon: InfoIcon, title: "Laporan bulan ini sudah siap", description: "Kamu bisa mengunduhnya dari menu Royalti." }, { variant: "info", icon: InfoIcon, title: "Rilis dijadwalkan", description: "\"Senja di Kota\" tayang 1 Des 2026 pukul 00.00 WIB." }, { variant: "success", icon: CircleCheckIcon, title: "Rilis terkirim", description: "Semua toko musik sudah menerima \"Kaset Pertama\"." }, { variant: "warning", icon: TriangleAlertIcon, title: "Langgananmu hampir habis", description: "Masa langgananmu habis 3 hari lagi." }, { variant: "destructive", icon: CircleAlertIcon, title: "Rilis ditolak", description: "Sampulnya belum sesuai aturan toko musik." },]
export default function AlertDemo() { return ( <div className="grid w-full max-w-md gap-3"> {alerts.map(({ variant, icon: Icon, title, description }) => ( <Alert key={variant} variant={variant}> <Icon /> <AlertTitle>{title}</AlertTitle> <AlertDescription>{description}</AlertDescription> </Alert> ))} </div> )}<script setup lang="ts">import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon } from "@lucide/vue"import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
const alerts = [ { variant: "default", icon: InfoIcon, title: "Laporan bulan ini sudah siap", description: "Kamu bisa mengunduhnya dari menu Royalti." }, { variant: "info", icon: InfoIcon, title: "Rilis dijadwalkan", description: "\"Senja di Kota\" tayang 1 Des 2026 pukul 00.00 WIB." }, { variant: "success", icon: CircleCheckIcon, title: "Rilis terkirim", description: "Semua toko musik sudah menerima \"Kaset Pertama\"." }, { variant: "warning", icon: TriangleAlertIcon, title: "Langgananmu hampir habis", description: "Masa langgananmu habis 3 hari lagi." }, { variant: "destructive", icon: CircleAlertIcon, title: "Rilis ditolak", description: "Sampulnya belum sesuai aturan toko musik." },] as const</script>
<template> <div class="grid w-full max-w-md gap-3"> <Alert v-for="a in alerts" :key="a.variant" :variant="a.variant"> <component :is="a.icon" /> <AlertTitle>{{ a.title }}</AlertTitle> <AlertDescription>{{ a.description }}</AlertDescription> </Alert> </div></template>import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';import 'package:sosialoka_ui/sosialoka_ui.dart';
class AlertDemo extends StatelessWidget { const AlertDemo({super.key});
@override Widget build(BuildContext context) { final c = context.sosialoka; final theme = ShadTheme.of(context); // Status alerts: the soft status surface, the icon and title in the status color. ShadAlert status(Color color, Color soft, IconData icon, String title, String description) => ShadAlert( icon: Icon(icon), iconColor: color, title: Text(title), titleStyle: theme.textTheme.p.copyWith(color: color, fontWeight: FontWeight.w500), description: Text(description), decoration: ShadDecoration(color: soft, border: ShadBorder.none), ); return ConstrainedBox( constraints: const BoxConstraints(maxWidth: 448), child: Column( mainAxisSize: MainAxisSize.min, spacing: 12, children: [ const ShadAlert( icon: Icon(LucideIcons.info), title: Text('Laporan bulan ini sudah siap'), description: Text('Kamu bisa mengunduhnya dari menu Royalti.'), ), status(c.info, c.infoSoft, LucideIcons.info, 'Rilis dijadwalkan', '"Senja di Kota" tayang 1 Des 2026 pukul 00.00 WIB.'), status(c.success, c.successSoft, LucideIcons.circleCheck, 'Rilis terkirim', 'Semua toko musik sudah menerima "Kaset Pertama".'), status(c.warning, c.warningSoft, LucideIcons.triangleAlert, 'Langgananmu hampir habis', 'Masa langgananmu habis 3 hari lagi.'), status(c.destructive, c.destructiveSoft, LucideIcons.circleAlert, 'Rilis ditolak', 'Sampulnya belum sesuai aturan toko musik.'), ], ), ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/alert.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/alert.jsonAccessibility
Section titled “Accessibility”- It has
role="alert", so screen readers announce it when it appears. Render alerts that are there from the start with the page, so they are not announced again on every change. - The status is in the title too, not only in the color.
- The icon is decorative.
