Feedback

Alert

A message about the page or a result, shown in place.

Installation

npx sinaui add alert

Examples

Info

The default, for news worth knowing.

Reading room hours have changed

During Ramadan the Baghdad reading room opens after the evening prayer.
<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
</script>

<Alert title="Reading room hours have changed">
	During Ramadan the Baghdad reading room opens after the evening prayer.
</Alert>

Success

When something worked.

Copy commissioned

A scribe will finish it within the season.
<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
</script>

<Alert tone="success" title="Copy commissioned">A scribe will finish it within the season.</Alert>

Warning

When something needs attention soon.

Loan due in 3 days

Return The Book of Optics by Thursday.
<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
</script>

<Alert tone="warning" title="Loan due in 3 days">Return The Book of Optics by Thursday.</Alert>

Danger

When something went wrong or can't be undone.

This manuscript is damaged

Folios 12 to 19 are water-stained; handle with gloves.
<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
</script>

<Alert tone="danger" title="This manuscript is damaged">
	Folios 12 to 19 are water-stained; handle with gloves.
</Alert>

Actions and dismiss

Loan due in 3 days

Renew it now to keep reading, or return it to the Baghdad desk.
<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
	import Button from '#lib/ui/Button.svelte';

	let shown = $state(true);
</script>

{#if shown}
	<Alert tone="warning" title="Loan due in 3 days" ondismiss={() => (shown = false)}>
		Renew it now to keep reading, or return it to the Baghdad desk.
		{#snippet actions()}
			<Button size="sm" variant="ghost">Return it</Button>
			<Button size="sm">Renew for 40 days</Button>
		{/snippet}
	</Alert>
{:else}
	<Button variant="secondary" onclick={() => (shown = true)}>Show the alert again</Button>
{/if}

Announced results

With live, it is read out as it appears: status politely, danger as an alert.

<script lang="ts">
	import Alert from '#lib/ui/Alert.svelte';
	import Button from '#lib/ui/Button.svelte';

	let result = $state<'saved' | 'failed' | undefined>();
</script>

<div class="row">
	<Button variant="secondary" onclick={() => (result = 'saved')}>Save the note</Button>
	<Button variant="secondary" onclick={() => (result = 'failed')}>Save offline</Button>
</div>
<!-- live: announced as it appears, because the person is waiting for this result. -->
{#if result === 'saved'}
	<Alert live tone="success" title="Note saved to the margin." />
{:else if result === 'failed'}
	<Alert live tone="danger" title="Couldn't save: the catalog is unreachable." />
{/if}

<style>
	.row {
		display: flex;
		gap: 0.5rem;
	}
</style>

Props

PropTypeDefault
tone'info' | 'success' | 'warning' | 'danger''info'
titlestring (required)
liveboolean: announce on appearancefalse
ondismiss() => void: shows a close button
actionsSnippet

Accessibility

  • Static by default: it is simply read in page order, like any text. Only live alerts are announced, so screen readers are not flooded on page load.
  • Tone is in the icon and the words, never color alone.
  • The close button is named (translate dismissLabel).
Introduction
Theming
Changelog
Button
Action button
Confirm button
Copy button
Hold to confirm
Split button
Calendar
Checkbox
Color picker
Combobox
Date picker
Date range picker
File drop
Form
Input
Mention input
Multi select
Number field
OTP input
Password input
Phone input
Radio cards
Radio group
Rich text editor
Search field
Segmented control
Select
Signature pad
Slider
Switch
Tag input
Upload
Wheel picker
Textarea
Time field
Toggle group
Toolbar
Alert dialog
Command palette
Context menu
Dialog
Drawer
Dropdown
Hover card
Popover
Tooltip
Announcement bar
Alert
Empty state
Meter
Progress
Rolling number
Skeleton
Spinner
Toast
Avatar
Avatar group
Badge
Card
Carousel
Chart
Chat
Code block
Data table
Folder
Kbd
Mind map
Resizable panels
Scroll area
Separator
Sortable
Table
Tag group
Virtual list
Audio player
Image
Image compare
Video
Visualizer
Breadcrumb
File tree
Menubar
Navigation menu
Pagination
Sidebar layout
Stepper
Tabs
Alarm clock
Clock
Dynamic island
Fluid orb
Hourglass
Stopwatch
Timer
AI chat
AI media
Auth
Board
Booking
Dashboard
File explorer
Messaging
Notifications
Settings
Team
Overview
Pricing
Agent chat
Calendar
Voice agent
Mail inbox
CMS
Blog
Marketing site
E-commerce
AI agents
SaaS landing page
SaaS app
Accordion
Dark theme
Light theme