@xsolla/xui-badge 0.189.1 → 0.189.3
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 +33 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -3,9 +3,39 @@
|
|
|
3
3
|
A cross-platform React badge component for counts, status dots, and small labels. Sizes `xs` and `sm` render as content-less dots; larger sizes accept text and icons.
|
|
4
4
|
|
|
5
5
|
<!-- BEGIN:xui-mcp-instructions:badge -->
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
A small indicator dot that signals a new, active, or attention-requiring state. Renders as a filled circle or square at a very small fixed size, with optional content (icon or label) and an optional stroke border. Positioned absolutely over another element — most commonly on an Avatar, Icon button, or navigation icon. Unlike Tag, Badge carries no label by default and communicates through colour, shape, and position alone.
|
|
7
|
+
|
|
8
|
+
### When to use
|
|
9
|
+
- To signal an unread or unseen state on an Avatar, Icon button, or navigation item — a notification dot
|
|
10
|
+
- To indicate online/offline presence on an Avatar
|
|
11
|
+
- To mark a new feature, new content, or an attention-requiring state without interrupting the flow
|
|
12
|
+
- As a minimal indicator when a count or label would add too much visual noise (use a numeric counter badge in that case)
|
|
13
|
+
|
|
14
|
+
### When not to use
|
|
15
|
+
- When a specific count needs to be shown — use a numeric counter chip instead (e.g. inside Tabs or on an Icon button)
|
|
16
|
+
- For status labels with text — use a Tag or StatusDropdown
|
|
17
|
+
- As a standalone element on a page with no parent component to anchor it to
|
|
18
|
+
- When the state it signals needs to be explained — always pair with a tooltip or an aria-label
|
|
19
|
+
|
|
20
|
+
### Content guidelines
|
|
21
|
+
- Plain dot (default) — no text or icon. Use in the vast majority of cases. The parent*'s context and the Badge'*s colour communicate the meaning.
|
|
22
|
+
- Icon inside — use only when the icon is immediately recognisable (e.g. ✓ for verified, ★ for featured). Keep to 1 icon, centred. Only at XL or L sizes.
|
|
23
|
+
- Label inside — use only for a very short string: a single digit (*"3"*), an abbreviation (*"en"*), or a tier indicator (*"A"*). Keep to 1–3 characters. Only at XL or L sizes.
|
|
24
|
+
|
|
25
|
+
### Behaviour guidelines
|
|
26
|
+
- Visibility — show the Badge only when the state it signals is active. Remove it (unmount or hide with visibility: hidden) when the state is no longer true — e.g. once the user has read all notifications, remove the notification Badge from the Avatar.
|
|
27
|
+
- Animated entrance — optionally animate the Badge's appearance with a scale-in animation (transform: scale(0) → scale(1)) to draw attention to the new state without being distracting. Keep the animation under 200ms. Respect prefers-reduced-motion — use an instant appearance for users who prefer reduced motion.
|
|
28
|
+
- Real-time updates — if the Badge reflects a live count or state (e.g. presence), update it in real time without remounting the parent component. Change only the Badge's visibility or tone.
|
|
29
|
+
- Stacking — do not place two Badges on the same parent element simultaneously. If multiple states must be signalled, use the Badge for the highest-priority state only.
|
|
30
|
+
- Colour alone — Badge communicates state primarily through colour. Always pair with a tooltip or aria-label on the parent element to describe the state for users who cannot perceive colour.
|
|
31
|
+
|
|
32
|
+
### Accessibility
|
|
33
|
+
- Badge itself has no accessible role — it is a visual decorator. All accessibility information must be on the parent element.
|
|
34
|
+
- The parent element (Avatar, Icon button, navigation icon) must have aria-label that includes the Badge's meaning — e.g. aria-label=*"Alex Johnson, online"* or aria-label=*"Notifications, 3 unread"* or aria-label=*"Settings, update available"*.
|
|
35
|
+
- Do not rely on the Badge's colour alone to communicate state (WCAG 1.4.1 Use of Colour). The aria-label on the parent provides the non-colour signal.
|
|
36
|
+
- When the Badge appears or disappears dynamically, announce the change via aria-live=*"polite"* on a visually hidden region — e.g. *"Alex Johnson is now online"* or *"New notifications"*.
|
|
37
|
+
- The Badge element itself must have aria-hidden=*"true"* so screen readers do not attempt to read the dot as content.
|
|
38
|
+
- When Icon=true or Label=true, the badge may carry readable content, but the meaning is still communicated via the parent's aria-label — keep aria-hidden=*"true"* on the Badge and include the relevant information in the parent label.
|
|
9
39
|
<!-- END:xui-mcp-instructions:badge -->
|
|
10
40
|
|
|
11
41
|
## Installation
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-badge",
|
|
3
|
-
"version": "0.189.
|
|
3
|
+
"version": "0.189.3",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"test:coverage": "vitest run --coverage"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@xsolla/xui-core": "0.189.
|
|
18
|
-
"@xsolla/xui-primitives-core": "0.189.
|
|
17
|
+
"@xsolla/xui-core": "0.189.3",
|
|
18
|
+
"@xsolla/xui-primitives-core": "0.189.3"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
21
|
"react": ">=16.8.0",
|