1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use *;
use ;
use component_doc;
use inject_style;
use badge_styles;
/// Compact inline label for status, categories, or short counts in tables and navigation.
///
/// Pick `appearance`, `size`, and `color` for the emphasis you need. Keep label text short — one or two words or a count. For numeric overlays on avatars or icons use [`CounterBadge`](crate::CounterBadge); for availability dots use [`PresenceBadge`](crate::PresenceBadge) — not this component.
///
/// # Examples
///
/// ## Brand badge
/// A filled brand badge highlights new or featured items beside titles, in tables, or on navigation. Keep labels to one or two words.
/// <!-- preview -->
/// ```rust
/// use crate::{Badge, BadgeAppearance, BadgeColor};
/// view! {
/// <div data-testid="badge-preview">
/// <Badge appearance=BadgeAppearance::Filled color=BadgeColor::Brand>
/// "New"
/// </Badge>
/// </div>
/// }
/// ```
///
/// ## Appearances
/// Filled, tint, outline, and ghost presets trade emphasis against surrounding chrome.
/// <!-- preview -->
/// ```rust
/// use crate::{Badge, BadgeAppearance, BadgeColor};
/// view! {
/// <div data-testid="badge-appearance" style="display: flex; gap: 8px;">
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Brand)>"Filled"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Tint) color=Signal::from(BadgeColor::Brand)>"Tint"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Outline) color=Signal::from(BadgeColor::Brand)>"Outline"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Ghost) color=Signal::from(BadgeColor::Brand)>"Ghost"</Badge>
/// </div>
/// }
/// ```
///
/// ## Sizes
/// Size presets scale badge height and padding for inline labels versus navigation counts.
/// <!-- preview -->
/// ```rust
/// use crate::{Badge, BadgeAppearance, BadgeColor, BadgeSize};
/// view! {
/// <div data-testid="badge-sizes" style="display: flex; gap: 8px; align-items: center;">
/// <div data-testid="badge-size-small"><Badge size=Signal::from(BadgeSize::Small) appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Brand)>"S"</Badge></div>
/// <div data-testid="badge-size-large"><Badge size=Signal::from(BadgeSize::Large) appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Brand)>"L"</Badge></div>
/// </div>
/// }
/// ```
///
/// ## Semantic colors
/// Map badge color to success, warning, danger, or informative semantics for status labels.
/// <!-- preview -->
/// ```rust
/// use crate::{Badge, BadgeAppearance, BadgeColor};
/// view! {
/// <div data-testid="badge-colors" style="display: flex; gap: 8px; flex-wrap: wrap;">
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Success)>"OK"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Warning)>"Warn"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Danger)>"Err"</Badge>
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Informative)>"Info"</Badge>
/// </div>
/// }
/// ```
///
/// ## On navigation item
/// Badges beside navigation labels communicate unread counts or new items.
/// <!-- preview -->
/// ```rust
/// use crate::{Badge, BadgeAppearance, BadgeColor};
/// view! {
/// <div data-testid="badge-nav" style="display: flex; align-items: center; gap: 8px;">
/// <span>"Inbox"</span>
/// <Badge appearance=Signal::from(BadgeAppearance::Filled) color=Signal::from(BadgeColor::Brand)>"3"</Badge>
/// </div>
/// }
/// ```