solid-tom-ui 1.0.11 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +246 -246
- package/dist/README.md +246 -246
- package/dist/components/avatar/avatar.js.map +1 -1
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/chat-bubble/chatBubble.js.map +1 -1
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/collapse/collapse.js.map +1 -1
- package/dist/components/context-menu/context-menu.js.map +1 -1
- package/dist/components/context-menu/context-menu.store.js.map +1 -1
- package/dist/components/divider/divider.js.map +1 -1
- package/dist/components/dropdown/dropdown.js.map +1 -1
- package/dist/components/dropdown/dropdown.store.js.map +1 -1
- package/dist/components/float-button/float-button.js.map +1 -1
- package/dist/components/hover-3d-image/hover-3d-image.js.map +1 -1
- package/dist/components/image-preview/image-preview.js.map +1 -1
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/input.utils.js.map +1 -1
- package/dist/components/input/variants/input-color.js.map +1 -1
- package/dist/components/input/variants/input-date.js.map +1 -1
- package/dist/components/input/variants/input-number.d.ts.map +1 -1
- package/dist/components/input/variants/input-number.js +1 -1
- package/dist/components/input/variants/input-number.js.map +1 -1
- package/dist/components/input/variants/input-otp.js.map +1 -1
- package/dist/components/input/variants/input-password.js.map +1 -1
- package/dist/components/input/variants/input-radio.js.map +1 -1
- package/dist/components/input/variants/input-range.js.map +1 -1
- package/dist/components/input/variants/input-text.d.ts.map +1 -1
- package/dist/components/input/variants/input-text.js +1 -1
- package/dist/components/input/variants/input-text.js.map +1 -1
- package/dist/components/input/variants/input-textarea.js.map +1 -1
- package/dist/components/loading/loading.js.map +1 -1
- package/dist/components/mansory/mansory.js.map +1 -1
- package/dist/components/menu/menu.js.map +1 -1
- package/dist/components/modal/modal.js.map +1 -1
- package/dist/components/modal/modalContext.js.map +1 -1
- package/dist/components/pagination/pagination.js.map +1 -1
- package/dist/components/progress-bar/progress-bar.js.map +1 -1
- package/dist/components/qr-code/qr-code.js.map +1 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select-zone/select-zone.js.map +1 -1
- package/dist/components/skeleton/skeleton.js.map +1 -1
- package/dist/components/slider/slider.js.map +1 -1
- package/dist/components/splitter/splitter.js.map +1 -1
- package/dist/components/steps/steps.js.map +1 -1
- package/dist/components/swap/swap.js.map +1 -1
- package/dist/components/switch/switch.js.map +1 -1
- package/dist/components/tab/tab.js.map +1 -1
- package/dist/components/table/table.js.map +1 -1
- package/dist/components/timeline/timeline.js.map +1 -1
- package/dist/components/toast/icons/ErrorIcon.js.map +1 -1
- package/dist/components/toast/icons/IconCircle.js.map +1 -1
- package/dist/components/toast/icons/InfoIcon.js.map +1 -1
- package/dist/components/toast/icons/LoaderIcon.js.map +1 -1
- package/dist/components/toast/icons/SuccessIcon.js.map +1 -1
- package/dist/components/toast/icons/WarningIcon.js.map +1 -1
- package/dist/components/toast/toast.js.map +1 -1
- package/dist/components/toast/toast.store.js.map +1 -1
- package/dist/components/tooltip/tooltip.js.map +1 -1
- package/dist/components/tour/tour.js.map +1 -1
- package/dist/components/upload/upload.js.map +1 -1
- package/dist/components/z-index/z-index.context.js.map +1 -1
- package/dist/components/z-index/z-index.js.map +1 -1
- package/dist/components/z-index/z-index.store.js.map +1 -1
- package/dist/components/z-index/z-index.types.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/skill/avatar.skill.md.txt +255 -255
- package/dist/skill/badge.skill.md.txt +223 -223
- package/dist/skill/breadcrumb.skill.md.txt +177 -177
- package/dist/skill/button.skill.md.txt +198 -198
- package/dist/skill/carousel.skill.md.txt +406 -406
- package/dist/skill/chat-bubble.skill.md.txt +342 -342
- package/dist/skill/checkbox.skill.md.txt +326 -326
- package/dist/skill/code-preview.skill.md.txt +240 -240
- package/dist/skill/collapse.skill.md.txt +329 -329
- package/dist/skill/context-menu.skill.md.txt +233 -233
- package/dist/skill/diff.skill.md.txt +244 -244
- package/dist/skill/divider.skill.md.txt +151 -151
- package/dist/skill/doc.skill.md.txt +191 -191
- package/dist/skill/drawer.skill.md.txt +157 -157
- package/dist/skill/dropdown.skill.md.txt +198 -198
- package/dist/skill/float-button.skill.md.txt +315 -315
- package/dist/skill/hover-3d-image.skill.md.txt +120 -120
- package/dist/skill/iframe.skill.md.txt +114 -114
- package/dist/skill/image-preview.skill.md.txt +162 -162
- package/dist/skill/indicator.skill.md.txt +60 -60
- package/dist/skill/input.skill.md.txt +489 -489
- package/dist/skill/loading.skill.md.txt +127 -127
- package/dist/skill/menu.skill.md.txt +476 -476
- package/dist/skill/modal.skill.md.txt +359 -359
- package/dist/skill/pagination.skill.md.txt +405 -405
- package/dist/skill/progress-bar.skill.md.txt +207 -207
- package/dist/skill/qr-code.skill.md.txt +136 -136
- package/dist/skill/rating.skill.md.txt +167 -167
- package/dist/skill/select-zone.skill.md.txt +93 -93
- package/dist/skill/select.skill.md.txt +663 -663
- package/dist/skill/skeleton.skill.md.txt +192 -192
- package/dist/skill/slider.skill.md.txt +404 -404
- package/dist/skill/splitter.skill.md.txt +411 -411
- package/dist/skill/steps.skill.md.txt +264 -264
- package/dist/skill/swap.skill.md.txt +139 -139
- package/dist/skill/switch.skill.md.txt +191 -191
- package/dist/skill/tab.skill.md.txt +484 -484
- package/dist/skill/table.example.header.md.txt +666 -666
- package/dist/skill/table.skill.md.txt +1407 -1407
- package/dist/skill/text-rotate.skill.md.txt +186 -186
- package/dist/skill/timeline.skill.md.txt +247 -247
- package/dist/skill/toast.skill.md.txt +531 -531
- package/dist/skill/tooltip.skill.md.txt +222 -222
- package/dist/skill/tour.skill.md.txt +156 -156
- package/dist/skill/upload.skill.md.txt +358 -358
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/element-tracker.js.map +1 -1
- package/dist/utils/helper.js.map +1 -1
- package/dist/utils/hoc.js.map +1 -1
- package/package.json +132 -133
|
@@ -1,223 +1,223 @@
|
|
|
1
|
-
## COMPONENT IDENTITY
|
|
2
|
-
|
|
3
|
-
- **Import**: `import { Badge } from 'solid-tom-ui';`
|
|
4
|
-
- **Export**: `Badge` (named export), `BadgeVariantsProps` (type export)
|
|
5
|
-
- **Framework**: SolidJS
|
|
6
|
-
- **Purpose**: Small label/tag for status, category, count, or metadata display
|
|
7
|
-
|
|
8
|
-
## TYPE SIGNATURE
|
|
9
|
-
|
|
10
|
-
```typescript
|
|
11
|
-
import { Badge } from 'solid-tom-ui';
|
|
12
|
-
|
|
13
|
-
interface BadgeProps {
|
|
14
|
-
content?: SolidComponent; // Text string or JSXElement (default: "lorem")
|
|
15
|
-
size?: '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
|
|
16
|
-
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
17
|
-
variants?: 'outline' | 'soft' | 'dashed';
|
|
18
|
-
class?: string; // Append additional Tailwind classes
|
|
19
|
-
overrideClass?: string; // Completely replace all variant classes
|
|
20
|
-
customColor?: string; // Custom CSS color string
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## CLASS SLOTS
|
|
25
|
-
|
|
26
|
-
`Badge` is a single-element component. Use `class` to append classes and `overrideClass` to fully replace all variant classes. No named sub-element slots.
|
|
27
|
-
|
|
28
|
-
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `bg01`, `bg02`) per project convention.
|
|
29
|
-
|
|
30
|
-
## DEFAULTS
|
|
31
|
-
|
|
32
|
-
| Prop | Default |
|
|
33
|
-
| ---------- | ----------- |
|
|
34
|
-
| `size` | `"md"` |
|
|
35
|
-
| `color` | `"primary"` |
|
|
36
|
-
| `variants` | `"soft"` |
|
|
37
|
-
| `content` | `"lorem"` |
|
|
38
|
-
|
|
39
|
-
## SIZE REFERENCE
|
|
40
|
-
|
|
41
|
-
| Size | Height | Font size |
|
|
42
|
-
| ----- | ------ | ----------------- |
|
|
43
|
-
| `3xs` | h-3.5 | text-[10px] |
|
|
44
|
-
| `2xs` | h-4 | text-xs |
|
|
45
|
-
| `xs` | h-4.5 | text-sm |
|
|
46
|
-
| `sm` | h-5 | text-sm |
|
|
47
|
-
| `md` | h-5.5 | text-sm (default) |
|
|
48
|
-
| `lg` | h-6 | text-base |
|
|
49
|
-
| `xl` | h-6.5 | text-base |
|
|
50
|
-
| `2xl` | h-7 | text-base |
|
|
51
|
-
| `3xl` | h-7.5 | text-base |
|
|
52
|
-
|
|
53
|
-
## VARIANT SEMANTICS
|
|
54
|
-
|
|
55
|
-
| Variant | Visual appearance | Use case |
|
|
56
|
-
| --------- | ------------------------------- | ---------------------------------- |
|
|
57
|
-
| `soft` | Filled background (low opacity) | Default — status labels, tags |
|
|
58
|
-
| `outline` | Transparent bg, colored border | Category tags, filters |
|
|
59
|
-
| `dashed` | Dashed border, white bg | Draft / temporary / pending states |
|
|
60
|
-
|
|
61
|
-
## COLOR SEMANTICS
|
|
62
|
-
|
|
63
|
-
| Color | Semantic meaning |
|
|
64
|
-
| ----------- | ---------------------------- |
|
|
65
|
-
| `primary` | Brand / highlight (default) |
|
|
66
|
-
| `secondary` | Secondary brand |
|
|
67
|
-
| `accent` | Special highlight |
|
|
68
|
-
| `neutral` | Gray, no meaning, draft |
|
|
69
|
-
| `info` | Informational |
|
|
70
|
-
| `success` | Positive / active / complete |
|
|
71
|
-
| `warning` | Caution / pending |
|
|
72
|
-
| `error` | Negative / failed / critical |
|
|
73
|
-
|
|
74
|
-
## USAGE PATTERNS
|
|
75
|
-
|
|
76
|
-
### Simple text badge
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
<Badge content="Active" color="success" variants="soft" size="sm" />
|
|
80
|
-
<Badge content="Pending" color="warning" variants="soft" size="sm" />
|
|
81
|
-
<Badge content="Failed" color="error" variants="soft" size="sm" />
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Status indicators
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
// Active/inactive status
|
|
88
|
-
<Badge color="success" variants="soft" size="xs" content="Active" />
|
|
89
|
-
<Badge color="error" variants="soft" size="xs" content="Inactive" />
|
|
90
|
-
<Badge color="warning" variants="soft" size="xs" content="Pending" />
|
|
91
|
-
<Badge color="info" variants="soft" size="xs" content="Processing" />
|
|
92
|
-
<Badge color="neutral" variants="soft" size="xs" content="Draft" />
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
### Category / filter tags
|
|
96
|
-
|
|
97
|
-
```tsx
|
|
98
|
-
<Badge color="primary" variants="outline" size="xs" content="Technology" />
|
|
99
|
-
<Badge color="secondary" variants="outline" size="xs" content="Design" />
|
|
100
|
-
<Badge color="accent" variants="outline" size="xs" content="Marketing" />
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### Notification count badges
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
// Small number counts — use tiny sizes
|
|
107
|
-
<Badge color="error" variants="soft" size="3xs" content="5" />
|
|
108
|
-
<Badge color="primary" variants="soft" size="3xs" content="12" />
|
|
109
|
-
<Badge color="success" variants="soft" size="3xs" content="99+" />
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### Priority levels
|
|
113
|
-
|
|
114
|
-
```tsx
|
|
115
|
-
<Badge color="error" variants="dashed" size="xs" content="Critical" />
|
|
116
|
-
<Badge color="warning" variants="dashed" size="xs" content="High" />
|
|
117
|
-
<Badge color="info" variants="dashed" size="xs" content="Medium" />
|
|
118
|
-
<Badge color="neutral" variants="dashed" size="xs" content="Low" />
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Badge with icon (JSX content)
|
|
122
|
-
|
|
123
|
-
```tsx
|
|
124
|
-
import { Icon } from 'lucide-solid';
|
|
125
|
-
|
|
126
|
-
// Completed badge with checkmark
|
|
127
|
-
<Badge
|
|
128
|
-
color="success"
|
|
129
|
-
variants="soft"
|
|
130
|
-
size="sm"
|
|
131
|
-
content={() => (
|
|
132
|
-
<div class="flex items-center gap-1">
|
|
133
|
-
<Icon name="check" size={12} />
|
|
134
|
-
<span class="-translate-y-px">Completed</span>
|
|
135
|
-
</div>
|
|
136
|
-
)}
|
|
137
|
-
/>
|
|
138
|
-
|
|
139
|
-
// Closable badge (close button inside content)
|
|
140
|
-
<Badge
|
|
141
|
-
color="neutral"
|
|
142
|
-
variants="soft"
|
|
143
|
-
size="sm"
|
|
144
|
-
content={() => (
|
|
145
|
-
<div class="flex items-center gap-1">
|
|
146
|
-
<span class="-translate-y-px">Tag Label</span>
|
|
147
|
-
<Icon name="x" size={10} class="cursor-pointer hover:opacity-70" onClick={handleRemove} />
|
|
148
|
-
</div>
|
|
149
|
-
)}
|
|
150
|
-
/>
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
### Custom Tailwind classes (append)
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
// Append extra styles — does not remove defaults
|
|
157
|
-
<Badge content="Amber" class="h-5 bg-amber-200 text-sm text-amber-900/80" />
|
|
158
|
-
<Badge content="Gradient" class="h-5 bg-linear-to-r from-purple-400 to-pink-400 text-sm text-white" />
|
|
159
|
-
<Badge content="Pill shape" class="h-5 rounded-full px-3" />
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Full class override
|
|
163
|
-
|
|
164
|
-
```tsx
|
|
165
|
-
// Completely replace component classes
|
|
166
|
-
<Badge
|
|
167
|
-
content="Custom"
|
|
168
|
-
overrideClass="inline-flex items-center px-2 py-1 rounded text-xs font-bold bg-purple-600 text-white"
|
|
169
|
-
/>
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
## DECISION RULES
|
|
173
|
-
|
|
174
|
-
**Choosing `variants`:**
|
|
175
|
-
|
|
176
|
-
- Status / label → `soft` (default, most readable)
|
|
177
|
-
- Filter chip / selectable tag → `outline`
|
|
178
|
-
- Unconfirmed / draft / temporary → `dashed`
|
|
179
|
-
|
|
180
|
-
**Choosing `size`:**
|
|
181
|
-
|
|
182
|
-
- Inline with body text → `xs` or `sm`
|
|
183
|
-
- Standalone label → `md` (default)
|
|
184
|
-
- Notification dot / count → `3xs` or `2xs`
|
|
185
|
-
- Headline-level badge → `lg` or `xl`
|
|
186
|
-
|
|
187
|
-
**Choosing `color`:**
|
|
188
|
-
|
|
189
|
-
- Boolean positive state (active, online, success) → `success`
|
|
190
|
-
- Boolean negative state (inactive, offline, error) → `error`
|
|
191
|
-
- Transitional state (loading, pending) → `warning`
|
|
192
|
-
- Informational only → `info`
|
|
193
|
-
- Neutral tags with no semantic meaning → `neutral`
|
|
194
|
-
- Primary brand label → `primary`
|
|
195
|
-
|
|
196
|
-
**Rich content (icons, buttons inside badge):**
|
|
197
|
-
|
|
198
|
-
- Pass a function `() => JSX` or a JSX element to `content`
|
|
199
|
-
- Keep content minimal — badge is meant to be small
|
|
200
|
-
|
|
201
|
-
**Text truncation:**
|
|
202
|
-
|
|
203
|
-
- Long text auto-truncates with ellipsis
|
|
204
|
-
- Wrap badge in a width-constrained container if truncation is needed
|
|
205
|
-
|
|
206
|
-
## ANTI-PATTERNS
|
|
207
|
-
|
|
208
|
-
```tsx
|
|
209
|
-
// ❌ Missing content — shows "lorem" placeholder
|
|
210
|
-
<Badge color="success" />
|
|
211
|
-
|
|
212
|
-
// ❌ Using overrideClass for minor adjustments — use class instead
|
|
213
|
-
<Badge content="X" overrideClass="rounded px-2 text-xs bg-blue-500 text-white flex items-center" />
|
|
214
|
-
// ✅ Prefer class for additive changes
|
|
215
|
-
<Badge content="X" color="info" variants="soft" class="rounded-full px-3" />
|
|
216
|
-
|
|
217
|
-
// ❌ Nesting complex interactive UIs inside Badge content
|
|
218
|
-
// Badge is display-only — avoid heavy interaction inside content
|
|
219
|
-
|
|
220
|
-
// ✅ For notification bubbles over avatars/icons, compose Badge with the parent container
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
> **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
|
|
1
|
+
## COMPONENT IDENTITY
|
|
2
|
+
|
|
3
|
+
- **Import**: `import { Badge } from 'solid-tom-ui';`
|
|
4
|
+
- **Export**: `Badge` (named export), `BadgeVariantsProps` (type export)
|
|
5
|
+
- **Framework**: SolidJS
|
|
6
|
+
- **Purpose**: Small label/tag for status, category, count, or metadata display
|
|
7
|
+
|
|
8
|
+
## TYPE SIGNATURE
|
|
9
|
+
|
|
10
|
+
```typescript
|
|
11
|
+
import { Badge } from 'solid-tom-ui';
|
|
12
|
+
|
|
13
|
+
interface BadgeProps {
|
|
14
|
+
content?: SolidComponent; // Text string or JSXElement (default: "lorem")
|
|
15
|
+
size?: '3xs' | '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
|
|
16
|
+
color?: 'neutral' | 'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error';
|
|
17
|
+
variants?: 'outline' | 'soft' | 'dashed';
|
|
18
|
+
class?: string; // Append additional Tailwind classes
|
|
19
|
+
overrideClass?: string; // Completely replace all variant classes
|
|
20
|
+
customColor?: string; // Custom CSS color string
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CLASS SLOTS
|
|
25
|
+
|
|
26
|
+
`Badge` is a single-element component. Use `class` to append classes and `overrideClass` to fully replace all variant classes. No named sub-element slots.
|
|
27
|
+
|
|
28
|
+
> **CSS encoding**: internal CSS classes use short encoded names (e.g. `bg01`, `bg02`) per project convention.
|
|
29
|
+
|
|
30
|
+
## DEFAULTS
|
|
31
|
+
|
|
32
|
+
| Prop | Default |
|
|
33
|
+
| ---------- | ----------- |
|
|
34
|
+
| `size` | `"md"` |
|
|
35
|
+
| `color` | `"primary"` |
|
|
36
|
+
| `variants` | `"soft"` |
|
|
37
|
+
| `content` | `"lorem"` |
|
|
38
|
+
|
|
39
|
+
## SIZE REFERENCE
|
|
40
|
+
|
|
41
|
+
| Size | Height | Font size |
|
|
42
|
+
| ----- | ------ | ----------------- |
|
|
43
|
+
| `3xs` | h-3.5 | text-[10px] |
|
|
44
|
+
| `2xs` | h-4 | text-xs |
|
|
45
|
+
| `xs` | h-4.5 | text-sm |
|
|
46
|
+
| `sm` | h-5 | text-sm |
|
|
47
|
+
| `md` | h-5.5 | text-sm (default) |
|
|
48
|
+
| `lg` | h-6 | text-base |
|
|
49
|
+
| `xl` | h-6.5 | text-base |
|
|
50
|
+
| `2xl` | h-7 | text-base |
|
|
51
|
+
| `3xl` | h-7.5 | text-base |
|
|
52
|
+
|
|
53
|
+
## VARIANT SEMANTICS
|
|
54
|
+
|
|
55
|
+
| Variant | Visual appearance | Use case |
|
|
56
|
+
| --------- | ------------------------------- | ---------------------------------- |
|
|
57
|
+
| `soft` | Filled background (low opacity) | Default — status labels, tags |
|
|
58
|
+
| `outline` | Transparent bg, colored border | Category tags, filters |
|
|
59
|
+
| `dashed` | Dashed border, white bg | Draft / temporary / pending states |
|
|
60
|
+
|
|
61
|
+
## COLOR SEMANTICS
|
|
62
|
+
|
|
63
|
+
| Color | Semantic meaning |
|
|
64
|
+
| ----------- | ---------------------------- |
|
|
65
|
+
| `primary` | Brand / highlight (default) |
|
|
66
|
+
| `secondary` | Secondary brand |
|
|
67
|
+
| `accent` | Special highlight |
|
|
68
|
+
| `neutral` | Gray, no meaning, draft |
|
|
69
|
+
| `info` | Informational |
|
|
70
|
+
| `success` | Positive / active / complete |
|
|
71
|
+
| `warning` | Caution / pending |
|
|
72
|
+
| `error` | Negative / failed / critical |
|
|
73
|
+
|
|
74
|
+
## USAGE PATTERNS
|
|
75
|
+
|
|
76
|
+
### Simple text badge
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
<Badge content="Active" color="success" variants="soft" size="sm" />
|
|
80
|
+
<Badge content="Pending" color="warning" variants="soft" size="sm" />
|
|
81
|
+
<Badge content="Failed" color="error" variants="soft" size="sm" />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Status indicators
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
// Active/inactive status
|
|
88
|
+
<Badge color="success" variants="soft" size="xs" content="Active" />
|
|
89
|
+
<Badge color="error" variants="soft" size="xs" content="Inactive" />
|
|
90
|
+
<Badge color="warning" variants="soft" size="xs" content="Pending" />
|
|
91
|
+
<Badge color="info" variants="soft" size="xs" content="Processing" />
|
|
92
|
+
<Badge color="neutral" variants="soft" size="xs" content="Draft" />
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Category / filter tags
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
<Badge color="primary" variants="outline" size="xs" content="Technology" />
|
|
99
|
+
<Badge color="secondary" variants="outline" size="xs" content="Design" />
|
|
100
|
+
<Badge color="accent" variants="outline" size="xs" content="Marketing" />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Notification count badges
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
// Small number counts — use tiny sizes
|
|
107
|
+
<Badge color="error" variants="soft" size="3xs" content="5" />
|
|
108
|
+
<Badge color="primary" variants="soft" size="3xs" content="12" />
|
|
109
|
+
<Badge color="success" variants="soft" size="3xs" content="99+" />
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Priority levels
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
<Badge color="error" variants="dashed" size="xs" content="Critical" />
|
|
116
|
+
<Badge color="warning" variants="dashed" size="xs" content="High" />
|
|
117
|
+
<Badge color="info" variants="dashed" size="xs" content="Medium" />
|
|
118
|
+
<Badge color="neutral" variants="dashed" size="xs" content="Low" />
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Badge with icon (JSX content)
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { Icon } from 'lucide-solid';
|
|
125
|
+
|
|
126
|
+
// Completed badge with checkmark
|
|
127
|
+
<Badge
|
|
128
|
+
color="success"
|
|
129
|
+
variants="soft"
|
|
130
|
+
size="sm"
|
|
131
|
+
content={() => (
|
|
132
|
+
<div class="flex items-center gap-1">
|
|
133
|
+
<Icon name="check" size={12} />
|
|
134
|
+
<span class="-translate-y-px">Completed</span>
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
/>
|
|
138
|
+
|
|
139
|
+
// Closable badge (close button inside content)
|
|
140
|
+
<Badge
|
|
141
|
+
color="neutral"
|
|
142
|
+
variants="soft"
|
|
143
|
+
size="sm"
|
|
144
|
+
content={() => (
|
|
145
|
+
<div class="flex items-center gap-1">
|
|
146
|
+
<span class="-translate-y-px">Tag Label</span>
|
|
147
|
+
<Icon name="x" size={10} class="cursor-pointer hover:opacity-70" onClick={handleRemove} />
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
/>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Custom Tailwind classes (append)
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
// Append extra styles — does not remove defaults
|
|
157
|
+
<Badge content="Amber" class="h-5 bg-amber-200 text-sm text-amber-900/80" />
|
|
158
|
+
<Badge content="Gradient" class="h-5 bg-linear-to-r from-purple-400 to-pink-400 text-sm text-white" />
|
|
159
|
+
<Badge content="Pill shape" class="h-5 rounded-full px-3" />
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Full class override
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
// Completely replace component classes
|
|
166
|
+
<Badge
|
|
167
|
+
content="Custom"
|
|
168
|
+
overrideClass="inline-flex items-center px-2 py-1 rounded text-xs font-bold bg-purple-600 text-white"
|
|
169
|
+
/>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## DECISION RULES
|
|
173
|
+
|
|
174
|
+
**Choosing `variants`:**
|
|
175
|
+
|
|
176
|
+
- Status / label → `soft` (default, most readable)
|
|
177
|
+
- Filter chip / selectable tag → `outline`
|
|
178
|
+
- Unconfirmed / draft / temporary → `dashed`
|
|
179
|
+
|
|
180
|
+
**Choosing `size`:**
|
|
181
|
+
|
|
182
|
+
- Inline with body text → `xs` or `sm`
|
|
183
|
+
- Standalone label → `md` (default)
|
|
184
|
+
- Notification dot / count → `3xs` or `2xs`
|
|
185
|
+
- Headline-level badge → `lg` or `xl`
|
|
186
|
+
|
|
187
|
+
**Choosing `color`:**
|
|
188
|
+
|
|
189
|
+
- Boolean positive state (active, online, success) → `success`
|
|
190
|
+
- Boolean negative state (inactive, offline, error) → `error`
|
|
191
|
+
- Transitional state (loading, pending) → `warning`
|
|
192
|
+
- Informational only → `info`
|
|
193
|
+
- Neutral tags with no semantic meaning → `neutral`
|
|
194
|
+
- Primary brand label → `primary`
|
|
195
|
+
|
|
196
|
+
**Rich content (icons, buttons inside badge):**
|
|
197
|
+
|
|
198
|
+
- Pass a function `() => JSX` or a JSX element to `content`
|
|
199
|
+
- Keep content minimal — badge is meant to be small
|
|
200
|
+
|
|
201
|
+
**Text truncation:**
|
|
202
|
+
|
|
203
|
+
- Long text auto-truncates with ellipsis
|
|
204
|
+
- Wrap badge in a width-constrained container if truncation is needed
|
|
205
|
+
|
|
206
|
+
## ANTI-PATTERNS
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
// ❌ Missing content — shows "lorem" placeholder
|
|
210
|
+
<Badge color="success" />
|
|
211
|
+
|
|
212
|
+
// ❌ Using overrideClass for minor adjustments — use class instead
|
|
213
|
+
<Badge content="X" overrideClass="rounded px-2 text-xs bg-blue-500 text-white flex items-center" />
|
|
214
|
+
// ✅ Prefer class for additive changes
|
|
215
|
+
<Badge content="X" color="info" variants="soft" class="rounded-full px-3" />
|
|
216
|
+
|
|
217
|
+
// ❌ Nesting complex interactive UIs inside Badge content
|
|
218
|
+
// Badge is display-only — avoid heavy interaction inside content
|
|
219
|
+
|
|
220
|
+
// ✅ For notification bubbles over avatars/icons, compose Badge with the parent container
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
> **Unique IDs**: if this component needs to generate HTML `id` attributes, always use `createUniqueId()` from `solid-js` — never `Math.random()` or `Date.now()`.
|