@fpkit/acss 3.1.1 → 3.2.0

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.
Files changed (202) hide show
  1. package/libs/{chunk-2NRIP6RB.cjs → chunk-2C3YLBWP.cjs} +3 -3
  2. package/libs/{chunk-NWJDAHP6.cjs → chunk-2GJHKWEK.cjs} +3 -3
  3. package/libs/{chunk-FVROL3V5.js → chunk-2JCDEC32.js} +3 -3
  4. package/libs/{chunk-IRLFZ3OL.js → chunk-3XJC4XUG.js} +2 -2
  5. package/libs/{chunk-L6PRDL6F.cjs → chunk-5CJPTDK3.cjs} +3 -3
  6. package/libs/{chunk-E4OSROCA.cjs → chunk-5QSNJQVH.cjs} +3 -3
  7. package/libs/{chunk-O3JIHC5M.cjs → chunk-6BUJZ4DJ.cjs} +3 -3
  8. package/libs/{chunk-WXBFBWYF.cjs → chunk-AFINOD2L.cjs} +3 -3
  9. package/libs/{chunk-HRRHPLER.js → chunk-AWZLSWDO.js} +2 -2
  10. package/libs/chunk-DDSXKOUB.js +7 -0
  11. package/libs/chunk-DDSXKOUB.js.map +1 -0
  12. package/libs/{chunk-CWRNJA4P.js → chunk-DIJBIOFE.js} +3 -3
  13. package/libs/chunk-EJ6KYBFE.cjs +13 -0
  14. package/libs/chunk-EJ6KYBFE.cjs.map +1 -0
  15. package/libs/{chunk-GUJSMQ3V.cjs → chunk-EKJYOCLY.cjs} +3 -3
  16. package/libs/{chunk-X5RKCLDC.cjs → chunk-F64GE6RG.cjs} +4 -4
  17. package/libs/{chunk-5RAWNUVD.js → chunk-IBUTNPTQ.js} +2 -2
  18. package/libs/chunk-IWP4VJEP.cjs +18 -0
  19. package/libs/chunk-IWP4VJEP.cjs.map +1 -0
  20. package/libs/{chunk-ZFJ4U45S.js → chunk-KDMX3FAW.js} +2 -2
  21. package/libs/{chunk-DYFAUAB7.cjs → chunk-LXODKKA3.cjs} +4 -4
  22. package/libs/{chunk-MPTMPBFT.js → chunk-M7JLT62Q.js} +2 -2
  23. package/libs/{chunk-IQ76HGVP.js → chunk-MBWI67UT.js} +2 -2
  24. package/libs/{chunk-O5XAJ7BY.cjs → chunk-NCGVF2QS.cjs} +4 -4
  25. package/libs/{chunk-W2UIN7EV.cjs → chunk-NPWHQVYB.cjs} +3 -3
  26. package/libs/{chunk-43TK2ICH.js → chunk-PMWL5XZ4.js} +3 -3
  27. package/libs/{chunk-KVKQLRJG.js → chunk-TF3GQKOY.js} +2 -2
  28. package/libs/{chunk-IEB64SWY.js → chunk-U5VA34SU.js} +2 -2
  29. package/libs/chunk-UGMP72J2.js +8 -0
  30. package/libs/chunk-UGMP72J2.js.map +1 -0
  31. package/libs/{chunk-EE3ZWSBY.cjs → chunk-URBGDUFN.cjs} +6 -6
  32. package/libs/{chunk-TPIB3RQP.js → chunk-ZF6Y7W57.js} +5 -5
  33. package/libs/component-props-50e69975.d.ts +66 -0
  34. package/libs/components/box/box.css +1 -0
  35. package/libs/components/box/box.css.map +1 -0
  36. package/libs/components/box/box.min.css +3 -0
  37. package/libs/components/breadcrumbs/breadcrumb.cjs +6 -6
  38. package/libs/components/breadcrumbs/breadcrumb.js +3 -3
  39. package/libs/components/button.cjs +4 -4
  40. package/libs/components/button.d.cts +10 -3
  41. package/libs/components/button.d.ts +10 -3
  42. package/libs/components/button.js +2 -2
  43. package/libs/components/card.cjs +7 -7
  44. package/libs/components/card.d.cts +13 -85
  45. package/libs/components/card.d.ts +13 -85
  46. package/libs/components/card.js +2 -2
  47. package/libs/components/cards/card.css +1 -1
  48. package/libs/components/cards/card.css.map +1 -1
  49. package/libs/components/cards/card.min.css +2 -2
  50. package/libs/components/cluster/cluster.css +1 -0
  51. package/libs/components/cluster/cluster.css.map +1 -0
  52. package/libs/components/cluster/cluster.min.css +3 -0
  53. package/libs/components/dialog/dialog.cjs +7 -7
  54. package/libs/components/dialog/dialog.js +5 -5
  55. package/libs/components/form/fields.cjs +4 -4
  56. package/libs/components/form/fields.js +2 -2
  57. package/libs/components/form/textarea.cjs +4 -4
  58. package/libs/components/form/textarea.js +2 -2
  59. package/libs/components/grid/grid.css +1 -0
  60. package/libs/components/grid/grid.css.map +1 -0
  61. package/libs/components/grid/grid.min.css +3 -0
  62. package/libs/components/heading/heading.cjs +3 -3
  63. package/libs/components/heading/heading.js +2 -2
  64. package/libs/components/icons/icon.cjs +4 -4
  65. package/libs/components/icons/icon.d.cts +2 -2
  66. package/libs/components/icons/icon.d.ts +2 -2
  67. package/libs/components/icons/icon.js +2 -2
  68. package/libs/components/link/link.cjs +6 -6
  69. package/libs/components/link/link.js +2 -2
  70. package/libs/components/list/list.cjs +5 -5
  71. package/libs/components/list/list.js +2 -2
  72. package/libs/components/modal.cjs +4 -4
  73. package/libs/components/modal.d.cts +1 -1
  74. package/libs/components/modal.d.ts +1 -1
  75. package/libs/components/modal.js +3 -3
  76. package/libs/components/nav/nav.cjs +7 -7
  77. package/libs/components/nav/nav.js +3 -3
  78. package/libs/components/stack/stack.css +1 -0
  79. package/libs/components/stack/stack.css.map +1 -0
  80. package/libs/components/stack/stack.min.css +3 -0
  81. package/libs/components/tables/table.d.cts +1 -1
  82. package/libs/components/tables/table.d.ts +1 -1
  83. package/libs/components/text/text.cjs +5 -5
  84. package/libs/components/text/text.js +2 -2
  85. package/libs/hooks.cjs +4 -4
  86. package/libs/hooks.js +3 -3
  87. package/libs/{icons-287fce3a.d.ts → icons-df8e744f.d.ts} +1 -1
  88. package/libs/icons.cjs +3 -3
  89. package/libs/icons.d.cts +2 -2
  90. package/libs/icons.d.ts +2 -2
  91. package/libs/icons.js +2 -2
  92. package/libs/index.cjs +64 -63
  93. package/libs/index.cjs.map +1 -1
  94. package/libs/index.css +1 -1
  95. package/libs/index.css.map +1 -1
  96. package/libs/index.d.cts +923 -4
  97. package/libs/index.d.ts +923 -4
  98. package/libs/index.js +28 -28
  99. package/libs/index.js.map +1 -1
  100. package/package.json +2 -2
  101. package/src/components/alert/STYLES.mdx +790 -0
  102. package/src/components/badge/STYLES.mdx +610 -0
  103. package/src/components/box/README.mdx +401 -0
  104. package/src/components/box/STYLES.mdx +360 -0
  105. package/src/components/box/box.scss +245 -0
  106. package/src/components/box/box.stories.tsx +395 -0
  107. package/src/components/box/box.test.tsx +425 -0
  108. package/src/components/box/box.tsx +170 -0
  109. package/src/components/box/box.types.ts +166 -0
  110. package/src/components/breadcrumbs/STYLES.mdx +99 -0
  111. package/src/components/buttons/STYLES.mdx +766 -0
  112. package/src/components/cards/STYLES.mdx +835 -0
  113. package/src/components/cards/card.scss +29 -21
  114. package/src/components/cards/card.tsx +13 -3
  115. package/src/components/cards/card.types.ts +13 -0
  116. package/src/components/cluster/README.mdx +595 -0
  117. package/src/components/cluster/STYLES.mdx +626 -0
  118. package/src/components/cluster/cluster.scss +86 -0
  119. package/src/components/cluster/cluster.stories.tsx +385 -0
  120. package/src/components/cluster/cluster.test.tsx +655 -0
  121. package/src/components/cluster/cluster.tsx +94 -0
  122. package/src/components/cluster/cluster.types.ts +75 -0
  123. package/src/components/details/STYLES.mdx +445 -0
  124. package/src/components/dialog/STYLES.mdx +888 -0
  125. package/src/components/flexbox/STYLES.mdx +1 -1
  126. package/src/components/form/STYLES.mdx +821 -0
  127. package/src/components/grid/README.mdx +709 -0
  128. package/src/components/grid/STYLES.mdx +785 -0
  129. package/src/components/grid/grid.scss +287 -0
  130. package/src/components/grid/grid.stories.tsx +486 -0
  131. package/src/components/grid/grid.test.tsx +981 -0
  132. package/src/components/grid/grid.tsx +222 -0
  133. package/src/components/grid/grid.types.ts +344 -0
  134. package/src/components/icons/STYLES.mdx +56 -0
  135. package/src/components/images/STYLES.mdx +75 -0
  136. package/src/components/layout/STYLES.mdx +556 -0
  137. package/src/components/link/STYLES.mdx +75 -0
  138. package/src/components/list/STYLES.mdx +631 -0
  139. package/src/components/nav/STYLES.mdx +460 -0
  140. package/src/components/progress/STYLES.mdx +64 -0
  141. package/src/components/stack/README.mdx +400 -0
  142. package/src/components/stack/STYLES.mdx +414 -0
  143. package/src/components/stack/stack.scss +109 -0
  144. package/src/components/stack/stack.stories.tsx +559 -0
  145. package/src/components/stack/stack.test.tsx +426 -0
  146. package/src/components/stack/stack.tsx +141 -0
  147. package/src/components/stack/stack.types.ts +133 -0
  148. package/src/components/tag/STYLES.mdx +105 -0
  149. package/src/components/text-to-speech/STYLES.mdx +80 -0
  150. package/src/components/ui.tsx +3 -3
  151. package/src/index.scss +5 -1
  152. package/src/index.ts +305 -12
  153. package/src/sass/GLOBALS-STYLES.md +631 -0
  154. package/src/sass/_globals.scss +45 -24
  155. package/src/styles/box/box.css +220 -0
  156. package/src/styles/box/box.css.map +1 -0
  157. package/src/styles/cards/card.css +22 -17
  158. package/src/styles/cards/card.css.map +1 -1
  159. package/src/styles/cluster/cluster.css +71 -0
  160. package/src/styles/cluster/cluster.css.map +1 -0
  161. package/src/styles/grid/grid.css +238 -0
  162. package/src/styles/grid/grid.css.map +1 -0
  163. package/src/styles/index.css +667 -49
  164. package/src/styles/index.css.map +1 -1
  165. package/src/styles/stack/stack.css +86 -0
  166. package/src/styles/stack/stack.css.map +1 -0
  167. package/src/types/component-props.ts +42 -14
  168. package/src/types/layout-primitives.ts +48 -0
  169. package/src/types/shared.ts +10 -26
  170. package/libs/chunk-ENTCUJ3A.cjs +0 -13
  171. package/libs/chunk-ENTCUJ3A.cjs.map +0 -1
  172. package/libs/chunk-HHLNOC5T.js +0 -7
  173. package/libs/chunk-HHLNOC5T.js.map +0 -1
  174. package/libs/chunk-KK47SYZI.js +0 -8
  175. package/libs/chunk-KK47SYZI.js.map +0 -1
  176. package/libs/chunk-W5TKWBFC.cjs +0 -18
  177. package/libs/chunk-W5TKWBFC.cjs.map +0 -1
  178. package/libs/component-props-67d978a2.d.ts +0 -38
  179. /package/libs/{chunk-2NRIP6RB.cjs.map → chunk-2C3YLBWP.cjs.map} +0 -0
  180. /package/libs/{chunk-NWJDAHP6.cjs.map → chunk-2GJHKWEK.cjs.map} +0 -0
  181. /package/libs/{chunk-FVROL3V5.js.map → chunk-2JCDEC32.js.map} +0 -0
  182. /package/libs/{chunk-IRLFZ3OL.js.map → chunk-3XJC4XUG.js.map} +0 -0
  183. /package/libs/{chunk-L6PRDL6F.cjs.map → chunk-5CJPTDK3.cjs.map} +0 -0
  184. /package/libs/{chunk-E4OSROCA.cjs.map → chunk-5QSNJQVH.cjs.map} +0 -0
  185. /package/libs/{chunk-O3JIHC5M.cjs.map → chunk-6BUJZ4DJ.cjs.map} +0 -0
  186. /package/libs/{chunk-WXBFBWYF.cjs.map → chunk-AFINOD2L.cjs.map} +0 -0
  187. /package/libs/{chunk-HRRHPLER.js.map → chunk-AWZLSWDO.js.map} +0 -0
  188. /package/libs/{chunk-CWRNJA4P.js.map → chunk-DIJBIOFE.js.map} +0 -0
  189. /package/libs/{chunk-GUJSMQ3V.cjs.map → chunk-EKJYOCLY.cjs.map} +0 -0
  190. /package/libs/{chunk-X5RKCLDC.cjs.map → chunk-F64GE6RG.cjs.map} +0 -0
  191. /package/libs/{chunk-5RAWNUVD.js.map → chunk-IBUTNPTQ.js.map} +0 -0
  192. /package/libs/{chunk-ZFJ4U45S.js.map → chunk-KDMX3FAW.js.map} +0 -0
  193. /package/libs/{chunk-DYFAUAB7.cjs.map → chunk-LXODKKA3.cjs.map} +0 -0
  194. /package/libs/{chunk-MPTMPBFT.js.map → chunk-M7JLT62Q.js.map} +0 -0
  195. /package/libs/{chunk-IQ76HGVP.js.map → chunk-MBWI67UT.js.map} +0 -0
  196. /package/libs/{chunk-O5XAJ7BY.cjs.map → chunk-NCGVF2QS.cjs.map} +0 -0
  197. /package/libs/{chunk-W2UIN7EV.cjs.map → chunk-NPWHQVYB.cjs.map} +0 -0
  198. /package/libs/{chunk-43TK2ICH.js.map → chunk-PMWL5XZ4.js.map} +0 -0
  199. /package/libs/{chunk-KVKQLRJG.js.map → chunk-TF3GQKOY.js.map} +0 -0
  200. /package/libs/{chunk-IEB64SWY.js.map → chunk-U5VA34SU.js.map} +0 -0
  201. /package/libs/{chunk-EE3ZWSBY.cjs.map → chunk-URBGDUFN.cjs.map} +0 -0
  202. /package/libs/{chunk-TPIB3RQP.js.map → chunk-ZF6Y7W57.js.map} +0 -0
@@ -0,0 +1,610 @@
1
+ import { Meta } from "@storybook/addon-docs/blocks";
2
+
3
+ <Meta title="FP.REACT Components/Badge/Styles" />
4
+
5
+ # Badge Styles
6
+
7
+ Badge component styling system with CSS custom properties for creating compact,
8
+ informative indicators and notification counters.
9
+
10
+ ## Overview
11
+
12
+ The fpkit badge styling system uses the semantic `<sup>` element containing a
13
+ `<span>` to create badges. Badges support rectangular and circular variants with
14
+ full customization through CSS variables.
15
+
16
+ ### Key Features
17
+
18
+ - **Semantic HTML** - Uses `<sup>` element for proper semantic structure
19
+ - **Two variants** - Rectangular (default) and circular/rounded badges
20
+ - **Flexible sizing** - Customizable dimensions via CSS variables
21
+ - **Content overflow** - Graceful handling of long content in circular badges
22
+ - **CSS custom properties** - Full theming control
23
+ - **Rem-based sizing** - All measurements use rem units (1rem = 16px)
24
+ - **Vertical alignment** - Automatic superscript positioning
25
+
26
+ ## CSS Custom Properties
27
+
28
+ ### Base Badge Properties
29
+
30
+ Variables for default rectangular badges:
31
+
32
+ ```css
33
+ sup:has(> span) {
34
+ /* Colors */
35
+ --badge-bg: lightgray; /* Background color */
36
+ --badge-color: currentColor; /* Text color */
37
+
38
+ /* Shape */
39
+ --badge-radius: 0.5rem; /* Border radius (8px) */
40
+
41
+ /* Spacing */
42
+ --badge-padding: 0.3rem; /* Padding (4.8px) */
43
+
44
+ /* Position */
45
+ --badge-vertical-align: 0.5rem; /* Vertical offset (8px) */
46
+
47
+ /* Typography */
48
+ --badge-fs: var(--fs-1); /* Font size */
49
+ }
50
+ ```
51
+
52
+ ### Rounded Badge Properties
53
+
54
+ Variables specific to circular badges:
55
+
56
+ ```css
57
+ sup[data-badge~="rounded"] {
58
+ --badge-radius: 50%; /* Fully circular */
59
+ --badge-padding: 0; /* No padding (size controlled by width/height) */
60
+ --badge-size: 1.5625rem; /* Circle diameter (25px) */
61
+ }
62
+ ```
63
+
64
+ ### Customizing Badge Styles
65
+
66
+ Override CSS variables:
67
+
68
+ ```css
69
+ sup:has(> span) {
70
+ --badge-bg: #0066cc;
71
+ --badge-color: white;
72
+ --badge-radius: 0.25rem;
73
+ }
74
+ ```
75
+
76
+ Or inline:
77
+
78
+ ```html
79
+ <sup style="--badge-bg: red; --badge-color: white">
80
+ <span>5</span>
81
+ </sup>
82
+ ```
83
+
84
+ ## Badge Structure
85
+
86
+ ### Basic Badge
87
+
88
+ Rectangular badge with content:
89
+
90
+ ```html
91
+ <sup>
92
+ <span>New</span>
93
+ </sup>
94
+ ```
95
+
96
+ **CSS Applied:**
97
+
98
+ ```css
99
+ sup:has(> span) {
100
+ background-color: lightgray;
101
+ color: currentColor;
102
+ padding: 0.3rem;
103
+ border-radius: 0.5rem;
104
+ vertical-align: 0.5rem;
105
+ font-size: var(--fs-1);
106
+ }
107
+
108
+ sup:has(> span) span {
109
+ color: inherit;
110
+ }
111
+ ```
112
+
113
+ ### Rounded/Circular Badge
114
+
115
+ Circular badge with fixed size:
116
+
117
+ ```html
118
+ <sup data-badge="rounded">
119
+ <span>5</span>
120
+ </sup>
121
+ ```
122
+
123
+ **CSS Applied:**
124
+
125
+ ```css
126
+ sup[data-badge~="rounded"] {
127
+ --badge-radius: 50%;
128
+ --badge-padding: 0;
129
+ --badge-size: 1.5625rem; /* 25px */
130
+ width: var(--badge-size);
131
+ height: var(--badge-size);
132
+ display: inline-flex;
133
+ align-items: center;
134
+ justify-content: center;
135
+ line-height: 1;
136
+ font-size: 0.6875rem; /* 11px */
137
+ font-weight: 700;
138
+ overflow: hidden;
139
+ box-sizing: border-box;
140
+ }
141
+
142
+ sup[data-badge~="rounded"] span {
143
+ max-width: 100%;
144
+ overflow: hidden;
145
+ text-overflow: clip;
146
+ white-space: nowrap;
147
+ padding: 0 0.125rem; /* 2px horizontal padding */
148
+ }
149
+ ```
150
+
151
+ ## Badge in Context
152
+
153
+ ### Badge on Text
154
+
155
+ Badge as superscript on inline text:
156
+
157
+ ```html
158
+ <p>
159
+ Notifications
160
+ <sup><span>3</span></sup>
161
+ </p>
162
+ ```
163
+
164
+ ### Badge on Button
165
+
166
+ Badge indicating count on button:
167
+
168
+ ```html
169
+ <button type="button">
170
+ Messages
171
+ <sup style="--badge-bg: red; --badge-color: white">
172
+ <span>12</span>
173
+ </sup>
174
+ </button>
175
+ ```
176
+
177
+ ### Badge on Icon
178
+
179
+ Badge on icon button:
180
+
181
+ ```html
182
+ <button type="button" data-btn="icon" aria-label="Notifications">
183
+ 🔔
184
+ <sup data-badge="rounded" style="--badge-bg: red; --badge-color: white">
185
+ <span>5</span>
186
+ </sup>
187
+ </button>
188
+ ```
189
+
190
+ ### Badge on Heading
191
+
192
+ Badge in heading:
193
+
194
+ ```html
195
+ <h2>
196
+ Tasks
197
+ <sup style="--badge-bg: blue; --badge-color: white">
198
+ <span>24</span>
199
+ </sup>
200
+ </h2>
201
+ ```
202
+
203
+ ## Badge Variants
204
+
205
+ ### Status Badges
206
+
207
+ Success badge (green):
208
+
209
+ ```html
210
+ <sup style="--badge-bg: #34a853; --badge-color: white">
211
+ <span>Active</span>
212
+ </sup>
213
+ ```
214
+
215
+ Error badge (red):
216
+
217
+ ```html
218
+ <sup style="--badge-bg: #d32f2f; --badge-color: white">
219
+ <span>Error</span>
220
+ </sup>
221
+ ```
222
+
223
+ Warning badge (orange):
224
+
225
+ ```html
226
+ <sup style="--badge-bg: #ff9800; --badge-color: white">
227
+ <span>Pending</span>
228
+ </sup>
229
+ ```
230
+
231
+ Info badge (blue):
232
+
233
+ ```html
234
+ <sup style="--badge-bg: #0288d1; --badge-color: white">
235
+ <span>Info</span>
236
+ </sup>
237
+ ```
238
+
239
+ ### Size Variants
240
+
241
+ Small badge:
242
+
243
+ ```html
244
+ <sup style="--badge-padding: 0.2rem; --badge-fs: 0.625rem">
245
+ <span>XS</span>
246
+ </sup>
247
+ ```
248
+
249
+ Large badge:
250
+
251
+ ```html
252
+ <sup style="--badge-padding: 0.5rem; --badge-fs: 1rem">
253
+ <span>Large</span>
254
+ </sup>
255
+ ```
256
+
257
+ ### Rounded Badge Sizes
258
+
259
+ Small circular badge:
260
+
261
+ ```html
262
+ <sup data-badge="rounded" style="--badge-size: 1.25rem; font-size: 0.5625rem">
263
+ <span>3</span>
264
+ </sup>
265
+ ```
266
+
267
+ Large circular badge:
268
+
269
+ ```html
270
+ <sup data-badge="rounded" style="--badge-size: 2rem; font-size: 0.875rem">
271
+ <span>99+</span>
272
+ </sup>
273
+ ```
274
+
275
+ ## Real-World Examples
276
+
277
+ ### Notification Count
278
+
279
+ ```html
280
+ <button type="button">
281
+ Inbox
282
+ <sup data-badge="rounded" style="--badge-bg: #d32f2f; --badge-color: white">
283
+ <span>42</span>
284
+ </sup>
285
+ </button>
286
+ ```
287
+
288
+ ### Status Indicator
289
+
290
+ ```html
291
+ <span>
292
+ Server Status
293
+ <sup
294
+ style="--badge-bg: #34a853; --badge-color: white; --badge-radius: 0.25rem"
295
+ >
296
+ <span>Online</span>
297
+ </sup>
298
+ </span>
299
+ ```
300
+
301
+ ### Feature Badge
302
+
303
+ ```html
304
+ <h3>
305
+ Premium Plan
306
+ <sup
307
+ style="--badge-bg: gold; --badge-color: #333; --badge-padding: 0.25rem 0.5rem"
308
+ >
309
+ <span>New</span>
310
+ </sup>
311
+ </h3>
312
+ ```
313
+
314
+ ### Cart Counter
315
+
316
+ ```html
317
+ <button type="button" data-btn="icon" aria-label="Shopping cart with 7 items">
318
+ 🛒
319
+ <sup
320
+ data-badge="rounded"
321
+ style="--badge-bg: #ff5722; --badge-color: white; position: absolute; top: -0.5rem; right: -0.5rem"
322
+ >
323
+ <span>7</span>
324
+ </sup>
325
+ </button>
326
+ ```
327
+
328
+ ### Beta Tag
329
+
330
+ ```html
331
+ <a href="/beta-features">
332
+ Try New Features
333
+ <sup
334
+ style="--badge-bg: #9c27b0; --badge-color: white; --badge-radius: 0.375rem"
335
+ >
336
+ <span>Beta</span>
337
+ </sup>
338
+ </a>
339
+ ```
340
+
341
+ ### User Role Badge
342
+
343
+ ```html
344
+ <div class="user-profile">
345
+ <span>John Doe</span>
346
+ <sup
347
+ style="--badge-bg: #0288d1; --badge-color: white; --badge-padding: 0.2rem 0.4rem"
348
+ >
349
+ <span>Admin</span>
350
+ </sup>
351
+ </div>
352
+ ```
353
+
354
+ ### Overflow Handling (Circular)
355
+
356
+ Long content in circular badge:
357
+
358
+ ```html
359
+ <sup data-badge="rounded" style="--badge-bg: red; --badge-color: white">
360
+ <span>999+</span>
361
+ </sup>
362
+ ```
363
+
364
+ **Note:** Content longer than the badge width will be clipped with ellipsis
365
+ handled by `text-overflow: clip` and `overflow: hidden`.
366
+
367
+ ## Positioning Badges
368
+
369
+ ### Absolute Positioning
370
+
371
+ Position badge relative to parent:
372
+
373
+ ```html
374
+ <div style="position: relative; display: inline-block">
375
+ <button type="button">Profile</button>
376
+ <sup
377
+ data-badge="rounded"
378
+ style="--badge-bg: red; --badge-color: white; position: absolute; top: -0.5rem; right: -0.5rem"
379
+ >
380
+ <span>3</span>
381
+ </sup>
382
+ </div>
383
+ ```
384
+
385
+ ### Top-Right Badge
386
+
387
+ ```html
388
+ <div style="position: relative; display: inline-block">
389
+ <span style="font-size: 2rem">📧</span>
390
+ <sup
391
+ data-badge="rounded"
392
+ style="--badge-bg: #d32f2f; --badge-color: white; position: absolute; top: 0; right: 0; transform: translate(50%, -50%)"
393
+ >
394
+ <span>5</span>
395
+ </sup>
396
+ </div>
397
+ ```
398
+
399
+ ## Accessibility Considerations
400
+
401
+ ### Screen Reader Support
402
+
403
+ Badges should convey meaning to screen readers:
404
+
405
+ ```html
406
+ <!-- Good: Badge has semantic meaning -->
407
+ <button aria-label="Notifications, 5 unread">
408
+ Notifications
409
+ <sup data-badge="rounded" aria-hidden="true">
410
+ <span>5</span>
411
+ </sup>
412
+ </button>
413
+
414
+ <!-- Alternative: Use visually hidden text -->
415
+ <button>
416
+ Notifications
417
+ <span class="sr-only">5 unread notifications</span>
418
+ <sup data-badge="rounded" aria-hidden="true">
419
+ <span>5</span>
420
+ </sup>
421
+ </button>
422
+ ```
423
+
424
+ ### Color Contrast
425
+
426
+ Ensure sufficient contrast between badge background and text (WCAG AA: 4.5:1):
427
+
428
+ ```html
429
+ <!-- Good contrast -->
430
+ <sup style="--badge-bg: #0066cc; --badge-color: white">
431
+ <span>Text</span>
432
+ </sup>
433
+
434
+ <!-- Poor contrast (avoid) -->
435
+ <sup style="--badge-bg: yellow; --badge-color: white">
436
+ <span>Text</span>
437
+ </sup>
438
+ ```
439
+
440
+ ### Decorative vs Informative
441
+
442
+ - **Decorative badges:** Add `aria-hidden="true"` if visual only
443
+ - **Informative badges:** Ensure content is accessible to screen readers
444
+
445
+ ## CSS Variable Naming Convention
446
+
447
+ All badge CSS variables follow the `--badge-{property}` pattern:
448
+
449
+ ### Property Mapping
450
+
451
+ | Category | Variable Pattern | Example |
452
+ | -------------- | ------------------------ | -------------------------------- |
453
+ | **Colors** | `--badge-{property}` | `--badge-bg`, `--badge-color` |
454
+ | **Shape** | `--badge-radius` | `--badge-radius` |
455
+ | **Spacing** | `--badge-{spacing}` | `--badge-padding` |
456
+ | **Position** | `--badge-vertical-align` | `--badge-vertical-align` |
457
+ | **Typography** | `--badge-fs` | `--badge-fs` |
458
+ | **Size** | `--badge-size` | `--badge-size` (rounded variant) |
459
+
460
+ ### Common Variables Quick Reference
461
+
462
+ ```css
463
+ /* Colors */
464
+ --badge-bg /* Background color */
465
+ --badge-color /* Text color */
466
+
467
+ /* Shape */
468
+ --badge-radius /* Border radius */
469
+
470
+ /* Spacing */
471
+ --badge-padding /* Padding */
472
+
473
+ /* Position */
474
+ --badge-vertical-align /* Vertical alignment offset */
475
+
476
+ /* Typography */
477
+ --badge-fs /* Font size */
478
+
479
+ /* Size (Rounded Variant) */
480
+ --badge-size /* Circle diameter */
481
+ ```
482
+
483
+ ## Browser Support
484
+
485
+ The badge styles use modern CSS features:
486
+
487
+ - **CSS Custom Properties:** All modern browsers (IE11 not supported)
488
+ - **`:has()` selector:** Chrome 105+, Firefox 121+, Safari 15.4+
489
+ - **Flexbox:** All modern browsers
490
+ - **`box-sizing: border-box`:** All modern browsers
491
+
492
+ ### Fallback for `:has()`
493
+
494
+ For browsers without `:has()` support, add a class:
495
+
496
+ ```css
497
+ /* Fallback */
498
+ sup.badge {
499
+ /* Badge styles */
500
+ }
501
+
502
+ /* Modern browsers */
503
+ sup:has(> span) {
504
+ /* Badge styles */
505
+ }
506
+ ```
507
+
508
+ ```html
509
+ <sup class="badge">
510
+ <span>Text</span>
511
+ </sup>
512
+ ```
513
+
514
+ ## Performance Tips
515
+
516
+ ### Use CSS Classes
517
+
518
+ Create reusable badge variants:
519
+
520
+ ```css
521
+ .badge-primary {
522
+ --badge-bg: #0066cc;
523
+ --badge-color: white;
524
+ }
525
+
526
+ .badge-success {
527
+ --badge-bg: #34a853;
528
+ --badge-color: white;
529
+ }
530
+
531
+ .badge-error {
532
+ --badge-bg: #d32f2f;
533
+ --badge-color: white;
534
+ }
535
+
536
+ .badge-small {
537
+ --badge-padding: 0.2rem;
538
+ --badge-fs: 0.625rem;
539
+ }
540
+ ```
541
+
542
+ ```html
543
+ <sup class="badge-primary"><span>Primary</span></sup>
544
+ <sup class="badge-success"><span>Success</span></sup>
545
+ ```
546
+
547
+ ### Avoid Inline Styles
548
+
549
+ Prefer classes over inline styles for better maintainability:
550
+
551
+ ```html
552
+ <!-- Good: Reusable class -->
553
+ <sup class="badge-error"><span>5</span></sup>
554
+
555
+ <!-- Less optimal: Inline styles -->
556
+ <sup style="--badge-bg: red; --badge-color: white"><span>5</span></sup>
557
+ ```
558
+
559
+ ## Migration from Other Systems
560
+
561
+ ### From Tailwind CSS
562
+
563
+ | Tailwind | fpkit Badge |
564
+ | ----------------------------- | ----------------------------------------------------------------------------- |
565
+ | `class="badge badge-primary"` | `<sup style="--badge-bg: blue; --badge-color: white"><span>Text</span></sup>` |
566
+ | `class="badge-sm"` | `<sup style="--badge-padding: 0.2rem"><span>Text</span></sup>` |
567
+ | `class="badge-lg"` | `<sup style="--badge-padding: 0.5rem"><span>Text</span></sup>` |
568
+ | `class="badge-circle"` | `<sup data-badge="rounded"><span>5</span></sup>` |
569
+
570
+ ### From Bootstrap
571
+
572
+ | Bootstrap | fpkit Badge |
573
+ | ----------------------------------- | ------------------------------------------------------------------------------ |
574
+ | `<span class="badge bg-primary">` | `<sup style="--badge-bg: blue; --badge-color: white"><span>Text</span></sup>` |
575
+ | `<span class="badge rounded-pill">` | `<sup data-badge="rounded"><span>Text</span></sup>` |
576
+ | `<span class="badge bg-success">` | `<sup style="--badge-bg: green; --badge-color: white"><span>Text</span></sup>` |
577
+
578
+ ## Semantic HTML Considerations
579
+
580
+ ### Why `<sup>`?
581
+
582
+ The badge system uses `<sup>` (superscript) because:
583
+
584
+ 1. **Semantic meaning** - Badges typically represent supplementary information
585
+ 2. **Automatic positioning** - Superscript positioning is built-in
586
+ 3. **Accessibility** - Screen readers understand superscript context
587
+
588
+ ### When to Use Badges
589
+
590
+ - **Notification counters** - Unread message counts
591
+ - **Status indicators** - Online/offline, active/inactive
592
+ - **Labels** - New features, beta tags
593
+ - **Counts** - Item quantities, totals
594
+
595
+ ### When NOT to Use Badges
596
+
597
+ - **Primary content** - Use regular text elements
598
+ - **Clickable elements** - Use buttons instead
599
+ - **Long text** - Use other components like tags or chips
600
+
601
+ ## Related Resources
602
+
603
+ - **React Component** - See [README.mdx](./README.mdx) for the React Badge
604
+ component API
605
+ - **MDN: `<sup>` element** -
606
+ [https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/sup)
607
+ - **CSS `:has()` selector** -
608
+ [https://developer.mozilla.org/en-US/docs/Web/CSS/:has](https://developer.mozilla.org/en-US/docs/Web/CSS/:has)
609
+ - **CSS Custom Properties** -
610
+ [https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)