@xsolla/xui-switch 0.174.3 → 0.175.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.
- package/README.md +48 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,54 @@
|
|
|
1
1
|
# Switch
|
|
2
2
|
|
|
3
3
|
A cross-platform toggle for binary on/off settings; a visual alternative to a checkbox.
|
|
4
|
+
<!-- BEGIN:xui-mcp-instructions:switch -->
|
|
5
|
+
Use a switch when a user can choose only one of the options: on or off. Use when items in a list can be independently controlled.
|
|
6
|
+
|
|
7
|
+
### When to use
|
|
8
|
+
|
|
9
|
+
- To toggle a single setting, feature, or preference on or off
|
|
10
|
+
- When each item in a list can be independently enabled or disabled
|
|
11
|
+
- When the change takes effect immediately, without requiring a *"Save"* or *"Submit"* action
|
|
12
|
+
|
|
13
|
+
### When not to use
|
|
14
|
+
- When the user must choose between more than two states — use a Select or Radio group
|
|
15
|
+
- When the change requires confirmation before taking effect — use a Checkbox with a submit action instead
|
|
16
|
+
- When the options are not binary (on/off) — use a ToggleButtonGroup
|
|
17
|
+
|
|
18
|
+
### Content guidelines
|
|
19
|
+
|
|
20
|
+
Label should describe the feature or setting being toggled, written as a noun or noun phrase: *"Email notifications"*, *"Auto-renew"*, *"Dark mode"*.
|
|
21
|
+
|
|
22
|
+
Avoid labelling the switch with the action: not *"Enable notifications"* — just *"Notifications"*.
|
|
23
|
+
|
|
24
|
+
Description should explain the impact of the toggle in plain language. Keep it to one sentence.
|
|
25
|
+
|
|
26
|
+
Error message should be specific and constructive: *"This setting cannot be changed while another process is running"* — not just *"Error"*.
|
|
27
|
+
|
|
28
|
+
### Behaviour guidelines
|
|
29
|
+
|
|
30
|
+
The switch should take effect immediately on toggle, without requiring a confirmation step. If the action has significant consequences, show a confirmation dialog before applying.
|
|
31
|
+
|
|
32
|
+
In a list of switches, each one is independent — toggling one should never affect the others unless there is an explicit dependency (e.g. a parent/child relationship between settings).
|
|
33
|
+
|
|
34
|
+
Disabled switches should preserve their current value visibly so the user understands the current state even if they cannot change it. Provide a tooltip explaining why the switch is disabled.
|
|
35
|
+
|
|
36
|
+
Avoid using a switch to replace a Checkbox in a form that is submitted later — switches imply immediate effect.
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
|
|
40
|
+
The switch should render as role=*"switch"* with aria-checked=*"true"* or aria-checked=*"false"* to communicate its state to screen readers.
|
|
41
|
+
|
|
42
|
+
The Description text should be linked via aria-describedby so screen readers announce it alongside the label.
|
|
43
|
+
|
|
44
|
+
The Error message must be linked via aria-describedby so it is announced on focus in the Error state.
|
|
45
|
+
|
|
46
|
+
Disabled switches should remain focusable (aria-disabled=*"true"* rather than the HTML disabled attribute) to allow tooltip display and screen reader announcement.
|
|
47
|
+
|
|
48
|
+
Ensure the focus ring is visible for keyboard users — the component does not define a focus state visually; this must be implemented in code.
|
|
49
|
+
|
|
50
|
+
The minimum touch target for interactive elements is 44×44px. Sizes S (16px tall) and M (18px tall) require additional padding in touch contexts to meet this threshold.
|
|
51
|
+
<!-- END:xui-mcp-instructions:switch -->
|
|
4
52
|
|
|
5
53
|
## Installation
|
|
6
54
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-switch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.175.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-core": "0.
|
|
17
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-core": "0.175.0",
|
|
17
|
+
"@xsolla/xui-primitives-core": "0.175.0"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": ">=16.8.0",
|