Display

Badge

A short label for status or category.

Installation

npx sinaui add badge

Examples

Neutral

The default, for plain facts. Each tone carries its icon, as Alert does, so the meaning never rests on color alone.

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

<Badge>Cataloged</Badge>

Accent

For something new or good.

Recently copied
<script lang="ts">
	import Badge from '#lib/ui/Badge.svelte';
</script>

<Badge tone="accent">Recently copied</Badge>

Warning

For something that needs attention soon.

On loan
<script lang="ts">
	import Badge from '#lib/ui/Badge.svelte';
</script>

<Badge tone="warning">On loan</Badge>

Danger

For something wrong or missing.

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

<Badge tone="danger">Missing</Badge>

Your own icon

Any Hugeicons icon in place of the tone's.

In the reading room
<script lang="ts">
	import { BookOpen01Icon } from '@hugeicons/core-free-icons';
	import Badge from '#lib/ui/Badge.svelte';
</script>

<Badge tone="accent" icon={BookOpen01Icon}>In the reading room</Badge>

No icon

Pass false as the icon to show the label alone.

On loan
<script lang="ts">
	import Badge from '#lib/ui/Badge.svelte';
</script>

<Badge tone="warning" icon={false}>On loan</Badge>

With a status dot

For live status; replaces the icon.

Reading room open
<script lang="ts">
	import Badge from '#lib/ui/Badge.svelte';
</script>

<Badge tone="accent" dot>Reading room open</Badge>

Props

PropTypeDefault
tone'neutral' | 'accent' | 'warning' | 'danger''neutral'
iconboolean | IconNodetrue
dotbooleanfalse

Accessibility

  • Plain text in a <span>: the words carry the meaning, never the color alone.
  • Every tone keeps at least 4.5:1 text contrast on its tint, and its icon at least 3:1, in light and dark.
  • The icon is decorative (hidden from screen readers): the words already say it.
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