Badge
A badge shows the status of an item, such as a release or a document, or a short label such as “Baru”.
When to use
Section titled “When to use”- Use the status variants for the state of a record:
success,warning,info,destructive. - Always put the status in words; color alone never carries a status.
- Use
defaultoroutlinefor labels that are not a status. - Don’t use a badge as a button.
SelesaiMenungguInfoDitolakBaruDraf
Selesai
Menunggu
Info
Ditolak
Baru
Draf
Do and don’t
Section titled “Do and don’t”Anatomy
Section titled “Anatomy”- 1Status color text
- 2Soft background
- 3Outline variant
Short text, text-xs medium, on radius-sm (6px). Badges are never pills. Status badges use the soft fill of their status with the status color as text.
Variants
Section titled “Variants”| Variant | Looks | Use it for |
|---|---|---|
success |
success text on success-soft |
Done, approved, published. |
warning |
warning text on warning-soft |
Pending, waiting for review. |
info |
info text on info-soft |
Neutral information. |
destructive |
destructive text on destructive-soft |
Rejected, failed, cancelled. |
default |
primary fill |
A label in the product color, such as “Baru”. |
secondary |
secondary fill |
A quiet label. |
outline |
border outline |
A label that should stay in the background, such as “Draf”. |
ghost |
No fill until hover | A quiet label inside a link or a menu. |
link |
primary-text, underlined on hover |
A badge that is itself a link. |
The default badge on Cover Clearance orange uses the same contrast exception as the primary button. Keep its label short.
| React | Vue | Flutter | Type | Default | Use |
|---|---|---|---|---|---|
variant |
variant |
named constructor, or backgroundColor + foregroundColor for status |
see Variants | default |
Meaning and weight. |
render |
as / as-child |
child |
element | span |
Renders the badge as another element, such as a link. |
import { Badge } from "@/components/ui/badge"
export default function BadgeDemo() { return ( <div className="flex flex-wrap items-center gap-2"> <Badge variant="success">Selesai</Badge> <Badge variant="warning">Menunggu</Badge> <Badge variant="info">Info</Badge> <Badge variant="destructive">Ditolak</Badge> <Badge>Baru</Badge> <Badge variant="outline">Draf</Badge> </div> )}<script setup lang="ts">import { Badge } from "@/components/ui/badge"</script>
<template> <div class="flex flex-wrap items-center gap-2"> <Badge variant="success">Selesai</Badge> <Badge variant="warning">Menunggu</Badge> <Badge variant="info">Info</Badge> <Badge variant="destructive">Ditolak</Badge> <Badge>Baru</Badge> <Badge variant="outline">Draf</Badge> </div></template>// Status colors come from the Sosialoka theme: context.sosialoka.import 'package:flutter/widgets.dart';import 'package:shadcn_ui/shadcn_ui.dart';import 'package:sosialoka_ui/sosialoka_ui.dart';
class BadgeDemo extends StatelessWidget { const BadgeDemo({super.key});
ShadBadge status(Color text, Color soft, String label) => ShadBadge(backgroundColor: soft, foregroundColor: text, child: Text(label));
@override Widget build(BuildContext context) { final c = context.sosialoka; return Wrap( spacing: 8, runSpacing: 8, children: [ status(c.success, c.successSoft, 'Selesai'), status(c.warning, c.warningSoft, 'Menunggu'), status(c.info, c.infoSoft, 'Info'), status(c.destructive, c.destructiveSoft, 'Ditolak'), const ShadBadge(child: Text('Baru')), const ShadBadge.outline(child: Text('Draf')), ], ); }}Install
Section titled “Install”npx shadcn@latest add https://design.sosialoka.tech/r/react/badge.jsonnpx shadcn-vue@latest add https://design.sosialoka.tech/r/vue/badge.jsonAccessibility
Section titled “Accessibility”- Badge text is read as normal text; keep it meaningful on its own.
- Status colors pass 4.5:1 on their soft fill in every theme.
