@warp-ds/elements 2.9.0-next.4 → 2.9.0-next.6
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/dist/custom-elements.json +3554 -3442
- package/dist/docs/affix/accessibility.md +7 -0
- package/dist/docs/affix/affix.md +174 -10
- package/dist/docs/affix/api.md +28 -10
- package/dist/docs/affix/examples.md +92 -0
- package/dist/docs/affix/usage.md +47 -0
- package/dist/docs/alert/alert.md +12 -12
- package/dist/docs/alert/api.md +12 -12
- package/dist/docs/attention/api.md +46 -46
- package/dist/docs/attention/attention.md +46 -46
- package/dist/docs/badge/accessibility.md +44 -0
- package/dist/docs/badge/api.md +12 -8
- package/dist/docs/badge/badge.md +191 -10
- package/dist/docs/badge/examples.md +82 -0
- package/dist/docs/badge/usage.md +53 -0
- package/dist/docs/button/api.md +46 -42
- package/dist/docs/button/button.md +46 -42
- package/dist/docs/card/api.md +11 -11
- package/dist/docs/card/card.md +11 -11
- package/dist/docs/combobox/api.md +62 -62
- package/dist/docs/combobox/combobox.md +62 -62
- package/dist/docs/datepicker/api.md +74 -66
- package/dist/docs/datepicker/datepicker.md +74 -66
- package/dist/docs/expandable/api.md +26 -26
- package/dist/docs/expandable/expandable.md +26 -26
- package/dist/docs/link/api.md +28 -28
- package/dist/docs/link/link.md +28 -28
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/page-indicator.md +6 -6
- package/dist/docs/pagination/api.md +3 -3
- package/dist/docs/pagination/pagination.md +3 -3
- package/dist/docs/pill/api.md +19 -15
- package/dist/docs/pill/pill.md +19 -15
- package/dist/docs/select/api.md +44 -44
- package/dist/docs/select/select.md +44 -44
- package/dist/docs/slider/api.md +80 -78
- package/dist/docs/slider/slider.md +80 -78
- package/dist/docs/slider-thumb/api.md +28 -76
- package/dist/docs/slider-thumb/slider-thumb.md +28 -76
- package/dist/docs/switch/api.md +16 -16
- package/dist/docs/switch/switch.md +16 -16
- package/dist/docs/tab/api.md +26 -40
- package/dist/docs/tab/tab.md +26 -40
- package/dist/docs/tab-panel/api.md +1 -17
- package/dist/docs/tab-panel/tab-panel.md +1 -17
- package/dist/docs/tabs/api.md +3 -3
- package/dist/docs/tabs/tabs.md +3 -3
- package/dist/docs/textarea/api.md +42 -40
- package/dist/docs/textarea/textarea.md +42 -40
- package/dist/docs/textfield/accessibility.md +15 -0
- package/dist/docs/textfield/api.md +86 -83
- package/dist/docs/textfield/examples.md +147 -0
- package/dist/docs/textfield/textfield.md +279 -86
- package/dist/docs/textfield/usage.md +30 -0
- package/dist/index.d.ts +343 -319
- package/dist/packages/affix/affix.d.ts +23 -14
- package/dist/packages/affix/affix.js +24 -11
- package/dist/packages/affix/affix.js.map +4 -4
- package/dist/packages/affix/affix.stories.d.ts +3 -0
- package/dist/packages/affix/affix.stories.js +16 -0
- package/dist/packages/affix/affix.test.js +7 -0
- package/dist/packages/affix/locales/da/messages.d.mts +1 -0
- package/dist/packages/affix/locales/da/messages.mjs +1 -0
- package/dist/packages/affix/locales/en/messages.d.mts +1 -0
- package/dist/packages/affix/locales/en/messages.mjs +1 -0
- package/dist/packages/affix/locales/fi/messages.d.mts +1 -0
- package/dist/packages/affix/locales/fi/messages.mjs +1 -0
- package/dist/packages/affix/locales/nb/messages.d.mts +1 -0
- package/dist/packages/affix/locales/nb/messages.mjs +1 -0
- package/dist/packages/affix/locales/sv/messages.d.mts +1 -0
- package/dist/packages/affix/locales/sv/messages.mjs +1 -0
- package/dist/packages/badge/badge.d.ts +7 -5
- package/dist/packages/badge/badge.js.map +2 -2
- package/dist/packages/badge/badge.react.stories.d.ts +1 -1
- package/dist/packages/box/box.react.stories.d.ts +1 -1
- package/dist/packages/breadcrumbs/breadcrumbs.react.stories.d.ts +1 -1
- package/dist/packages/button/button.react.stories.d.ts +1 -1
- package/dist/packages/card/card.react.stories.d.ts +1 -1
- package/dist/packages/combobox/combobox.react.stories.d.ts +1 -1
- package/dist/packages/datepicker/datepicker.js +1 -1
- package/dist/packages/datepicker/datepicker.js.map +2 -2
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +9 -1
- package/dist/packages/datepicker/react.d.ts +4 -0
- package/dist/packages/datepicker/react.js +4 -0
- package/dist/packages/expandable/expandable.react.stories.d.ts +1 -1
- package/dist/packages/link/link.react.stories.d.ts +1 -1
- package/dist/packages/page-indicator/page-indicator.react.stories.d.ts +1 -1
- package/dist/packages/pagination/pagination.react.stories.d.ts +1 -1
- package/dist/packages/pill/pill.react.stories.d.ts +1 -1
- package/dist/packages/select/select.react.stories.d.ts +1 -1
- package/dist/packages/textarea/textarea.react.stories.d.ts +1 -1
- package/dist/packages/textfield/textfield.d.ts +57 -60
- package/dist/packages/textfield/textfield.js +5 -5
- package/dist/packages/textfield/textfield.js.map +2 -2
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/packages/textfield/textfield.stories.d.ts +3 -0
- package/dist/packages/textfield/textfield.stories.js +45 -0
- package/dist/web-types.json +452 -147
- package/package.json +2 -2
|
@@ -4,128 +4,128 @@
|
|
|
4
4
|
|
|
5
5
|
| Name | Type | Default | Summary |
|
|
6
6
|
|-|-|-|-|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
9
|
-
| tooltip | `boolean` | `false` | - |
|
|
7
|
+
| _actualDirection | `unknown` | `-` | - |
|
|
8
|
+
| _initialPlacement | `unknown` | `-` | - |
|
|
10
9
|
| callout | `boolean` | `false` | - |
|
|
11
|
-
| popover | `boolean` | `false` | - |
|
|
12
|
-
| highlight | `boolean` | `false` | - |
|
|
13
10
|
| canClose | `boolean` | `false` | - |
|
|
14
|
-
| noArrow | `boolean` | `false` | - |
|
|
15
|
-
| distance | `number` | `8` | - |
|
|
16
|
-
| skidding | `number` | `0` | - |
|
|
17
|
-
| flip | `boolean` | `false` | - |
|
|
18
11
|
| crossAxis | `boolean` | `false` | - |
|
|
12
|
+
| distance | `number` | `8` | - |
|
|
19
13
|
| fallbackPlacements | `Directions[]` | `-` | - |
|
|
20
|
-
|
|
|
21
|
-
|
|
|
14
|
+
| flip | `boolean` | `false` | - |
|
|
15
|
+
| highlight | `boolean` | `false` | - |
|
|
16
|
+
| noArrow | `boolean` | `false` | - |
|
|
17
|
+
| placement | `Directions` | `'bottom'` | - |
|
|
18
|
+
| popover | `boolean` | `false` | - |
|
|
19
|
+
| show | `boolean` | `false` | - |
|
|
20
|
+
| skidding | `number` | `0` | - |
|
|
21
|
+
| tooltip | `boolean` | `false` | - |
|
|
22
22
|
|
|
23
23
|
### Property Details
|
|
24
24
|
|
|
25
|
-
####
|
|
25
|
+
#### _actualDirection
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
- Type: `
|
|
30
|
-
- Default:
|
|
29
|
+
- Type: `unknown`
|
|
30
|
+
- Default: `-`
|
|
31
31
|
|
|
32
|
-
####
|
|
32
|
+
#### _initialPlacement
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
|
|
36
|
-
- Type: `
|
|
37
|
-
- Default:
|
|
36
|
+
- Type: `unknown`
|
|
37
|
+
- Default: `-`
|
|
38
38
|
|
|
39
|
-
####
|
|
39
|
+
#### callout
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
- Type: `boolean`
|
|
44
44
|
- Default: `false`
|
|
45
45
|
|
|
46
|
-
####
|
|
46
|
+
#### canClose
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
- Type: `boolean`
|
|
51
51
|
- Default: `false`
|
|
52
52
|
|
|
53
|
-
####
|
|
53
|
+
#### crossAxis
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
- Type: `boolean`
|
|
58
58
|
- Default: `false`
|
|
59
59
|
|
|
60
|
-
####
|
|
60
|
+
#### distance
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
-
- Type: `
|
|
65
|
-
- Default: `
|
|
64
|
+
- Type: `number`
|
|
65
|
+
- Default: `8`
|
|
66
66
|
|
|
67
|
-
####
|
|
67
|
+
#### fallbackPlacements
|
|
68
68
|
|
|
69
69
|
|
|
70
70
|
|
|
71
|
-
- Type: `
|
|
72
|
-
- Default:
|
|
71
|
+
- Type: `Directions[]`
|
|
72
|
+
- Default: `-`
|
|
73
73
|
|
|
74
|
-
####
|
|
74
|
+
#### flip
|
|
75
75
|
|
|
76
76
|
|
|
77
77
|
|
|
78
78
|
- Type: `boolean`
|
|
79
79
|
- Default: `false`
|
|
80
80
|
|
|
81
|
-
####
|
|
81
|
+
#### highlight
|
|
82
82
|
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
- Type: `
|
|
86
|
-
- Default: `
|
|
85
|
+
- Type: `boolean`
|
|
86
|
+
- Default: `false`
|
|
87
87
|
|
|
88
|
-
####
|
|
88
|
+
#### noArrow
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
- Type: `
|
|
93
|
-
- Default: `
|
|
92
|
+
- Type: `boolean`
|
|
93
|
+
- Default: `false`
|
|
94
94
|
|
|
95
|
-
####
|
|
95
|
+
#### placement
|
|
96
96
|
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
- Type: `
|
|
100
|
-
- Default: `
|
|
99
|
+
- Type: `Directions`
|
|
100
|
+
- Default: `'bottom'`
|
|
101
101
|
|
|
102
|
-
####
|
|
102
|
+
#### popover
|
|
103
103
|
|
|
104
104
|
|
|
105
105
|
|
|
106
106
|
- Type: `boolean`
|
|
107
107
|
- Default: `false`
|
|
108
108
|
|
|
109
|
-
####
|
|
109
|
+
#### show
|
|
110
110
|
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
- Type: `
|
|
114
|
-
- Default:
|
|
113
|
+
- Type: `boolean`
|
|
114
|
+
- Default: `false`
|
|
115
115
|
|
|
116
|
-
####
|
|
116
|
+
#### skidding
|
|
117
117
|
|
|
118
118
|
|
|
119
119
|
|
|
120
|
-
- Type: `
|
|
121
|
-
- Default:
|
|
120
|
+
- Type: `number`
|
|
121
|
+
- Default: `0`
|
|
122
122
|
|
|
123
|
-
####
|
|
123
|
+
#### tooltip
|
|
124
124
|
|
|
125
125
|
|
|
126
126
|
|
|
127
|
-
- Type: `
|
|
128
|
-
- Default:
|
|
127
|
+
- Type: `boolean`
|
|
128
|
+
- Default: `false`
|
|
129
129
|
|
|
130
130
|
### Types
|
|
131
131
|
|
|
@@ -16,128 +16,128 @@
|
|
|
16
16
|
|
|
17
17
|
| Name | Type | Default | Summary |
|
|
18
18
|
|-|-|-|-|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
| tooltip | `boolean` | `false` | - |
|
|
19
|
+
| _actualDirection | `unknown` | `-` | - |
|
|
20
|
+
| _initialPlacement | `unknown` | `-` | - |
|
|
22
21
|
| callout | `boolean` | `false` | - |
|
|
23
|
-
| popover | `boolean` | `false` | - |
|
|
24
|
-
| highlight | `boolean` | `false` | - |
|
|
25
22
|
| canClose | `boolean` | `false` | - |
|
|
26
|
-
| noArrow | `boolean` | `false` | - |
|
|
27
|
-
| distance | `number` | `8` | - |
|
|
28
|
-
| skidding | `number` | `0` | - |
|
|
29
|
-
| flip | `boolean` | `false` | - |
|
|
30
23
|
| crossAxis | `boolean` | `false` | - |
|
|
24
|
+
| distance | `number` | `8` | - |
|
|
31
25
|
| fallbackPlacements | `Directions[]` | `-` | - |
|
|
32
|
-
|
|
|
33
|
-
|
|
|
26
|
+
| flip | `boolean` | `false` | - |
|
|
27
|
+
| highlight | `boolean` | `false` | - |
|
|
28
|
+
| noArrow | `boolean` | `false` | - |
|
|
29
|
+
| placement | `Directions` | `'bottom'` | - |
|
|
30
|
+
| popover | `boolean` | `false` | - |
|
|
31
|
+
| show | `boolean` | `false` | - |
|
|
32
|
+
| skidding | `number` | `0` | - |
|
|
33
|
+
| tooltip | `boolean` | `false` | - |
|
|
34
34
|
|
|
35
35
|
### Property Details
|
|
36
36
|
|
|
37
|
-
####
|
|
37
|
+
#### _actualDirection
|
|
38
38
|
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
- Type: `
|
|
42
|
-
- Default:
|
|
41
|
+
- Type: `unknown`
|
|
42
|
+
- Default: `-`
|
|
43
43
|
|
|
44
|
-
####
|
|
44
|
+
#### _initialPlacement
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
|
|
48
|
-
- Type: `
|
|
49
|
-
- Default:
|
|
48
|
+
- Type: `unknown`
|
|
49
|
+
- Default: `-`
|
|
50
50
|
|
|
51
|
-
####
|
|
51
|
+
#### callout
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
- Type: `boolean`
|
|
56
56
|
- Default: `false`
|
|
57
57
|
|
|
58
|
-
####
|
|
58
|
+
#### canClose
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
- Type: `boolean`
|
|
63
63
|
- Default: `false`
|
|
64
64
|
|
|
65
|
-
####
|
|
65
|
+
#### crossAxis
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
- Type: `boolean`
|
|
70
70
|
- Default: `false`
|
|
71
71
|
|
|
72
|
-
####
|
|
72
|
+
#### distance
|
|
73
73
|
|
|
74
74
|
|
|
75
75
|
|
|
76
|
-
- Type: `
|
|
77
|
-
- Default: `
|
|
76
|
+
- Type: `number`
|
|
77
|
+
- Default: `8`
|
|
78
78
|
|
|
79
|
-
####
|
|
79
|
+
#### fallbackPlacements
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
|
|
83
|
-
- Type: `
|
|
84
|
-
- Default:
|
|
83
|
+
- Type: `Directions[]`
|
|
84
|
+
- Default: `-`
|
|
85
85
|
|
|
86
|
-
####
|
|
86
|
+
#### flip
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
- Type: `boolean`
|
|
91
91
|
- Default: `false`
|
|
92
92
|
|
|
93
|
-
####
|
|
93
|
+
#### highlight
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
|
|
97
|
-
- Type: `
|
|
98
|
-
- Default: `
|
|
97
|
+
- Type: `boolean`
|
|
98
|
+
- Default: `false`
|
|
99
99
|
|
|
100
|
-
####
|
|
100
|
+
#### noArrow
|
|
101
101
|
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
- Type: `
|
|
105
|
-
- Default: `
|
|
104
|
+
- Type: `boolean`
|
|
105
|
+
- Default: `false`
|
|
106
106
|
|
|
107
|
-
####
|
|
107
|
+
#### placement
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
|
|
111
|
-
- Type: `
|
|
112
|
-
- Default: `
|
|
111
|
+
- Type: `Directions`
|
|
112
|
+
- Default: `'bottom'`
|
|
113
113
|
|
|
114
|
-
####
|
|
114
|
+
#### popover
|
|
115
115
|
|
|
116
116
|
|
|
117
117
|
|
|
118
118
|
- Type: `boolean`
|
|
119
119
|
- Default: `false`
|
|
120
120
|
|
|
121
|
-
####
|
|
121
|
+
#### show
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
|
|
125
|
-
- Type: `
|
|
126
|
-
- Default:
|
|
125
|
+
- Type: `boolean`
|
|
126
|
+
- Default: `false`
|
|
127
127
|
|
|
128
|
-
####
|
|
128
|
+
#### skidding
|
|
129
129
|
|
|
130
130
|
|
|
131
131
|
|
|
132
|
-
- Type: `
|
|
133
|
-
- Default:
|
|
132
|
+
- Type: `number`
|
|
133
|
+
- Default: `0`
|
|
134
134
|
|
|
135
|
-
####
|
|
135
|
+
#### tooltip
|
|
136
136
|
|
|
137
137
|
|
|
138
138
|
|
|
139
|
-
- Type: `
|
|
140
|
-
- Default:
|
|
139
|
+
- Type: `boolean`
|
|
140
|
+
- Default: `false`
|
|
141
141
|
|
|
142
142
|
### Types
|
|
143
143
|
|
|
@@ -1 +1,45 @@
|
|
|
1
1
|
## Accessibility
|
|
2
|
+
|
|
3
|
+
Badge renders slotted text as regular content. It does not add an ARIA role and it is not announced as a live region.
|
|
4
|
+
|
|
5
|
+
### Use Meaningful Text
|
|
6
|
+
|
|
7
|
+
Do not rely on color alone to communicate meaning. The badge text should describe the status or metadata by itself.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
11
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Avoid labels that only make sense visually:
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<!-- Avoid -->
|
|
18
|
+
<w-badge variant="positive">Green</w-badge>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Keep Badges Non-Interactive
|
|
22
|
+
|
|
23
|
+
Do not place interactive elements inside `w-badge`. If the user can click, dismiss, filter, or select the item, use an interactive component instead.
|
|
24
|
+
|
|
25
|
+
The `disabled` variant is visual only. It does not disable related controls or remove anything from the tab order.
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<!-- Avoid -->
|
|
29
|
+
<w-badge>
|
|
30
|
+
<button type="button">New</button>
|
|
31
|
+
</w-badge>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Dynamic Changes
|
|
35
|
+
|
|
36
|
+
If a badge value changes after the page has loaded and users need to be notified, announce that change outside the badge with an appropriate live region or use [Alert](/docs/components/alert/overview) for important feedback.
|
|
37
|
+
|
|
38
|
+
### Duplicate or Decorative Badges
|
|
39
|
+
|
|
40
|
+
If the same information is already available in nearby accessible text and the badge is only a visual duplicate, hide the duplicate badge from assistive technologies.
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<p>Sponsored listing</p>
|
|
44
|
+
<w-badge aria-hidden="true" variant="sponsored">Sponsored</w-badge>
|
|
45
|
+
```
|
package/dist/docs/badge/api.md
CHANGED
|
@@ -4,23 +4,27 @@
|
|
|
4
4
|
|
|
5
5
|
| Name | Type | Default | Summary |
|
|
6
6
|
|-|-|-|-|
|
|
7
|
-
|
|
|
8
|
-
|
|
|
7
|
+
| position | `'top-left' \| 'top-right' \| 'bottom-right' \| 'bottom-left'` | `-` | Positions the badge in a corner of a parent element. |
|
|
8
|
+
| variant | `'neutral' \| 'info' \| 'positive' \| 'warning' \| 'negative' \| 'disabled' \| 'price' \| 'sponsored'` | `-` | Controls the badge color treatment. |
|
|
9
9
|
|
|
10
10
|
### Property Details
|
|
11
11
|
|
|
12
|
-
####
|
|
13
|
-
|
|
12
|
+
#### position
|
|
14
13
|
|
|
14
|
+
Positions the badge in a corner of a parent element.
|
|
15
|
+
Use this with a parent element that has `position: relative`. When set, the badge uses absolute positioning and adjusts its corner radii so it sits flush against the selected corner.
|
|
16
|
+
Use this with a parent element that has `position: relative`. Accepted values are `top-left`, `top-right`, `bottom-right`, and `bottom-left`.
|
|
15
17
|
|
|
16
|
-
- Type: `'
|
|
18
|
+
- Type: `'top-left' \| 'top-right' \| 'bottom-right' \| 'bottom-left'`
|
|
17
19
|
- Default: `-`
|
|
18
20
|
|
|
19
|
-
####
|
|
20
|
-
|
|
21
|
+
#### variant
|
|
21
22
|
|
|
23
|
+
Controls the badge color treatment.
|
|
24
|
+
If omitted, the badge uses neutral styling without reflecting a `variant` attribute.
|
|
25
|
+
Accepted values are `neutral`, `info`, `positive`, `warning`, `negative`, `disabled`, `price`, and `sponsored`. If omitted, the badge uses neutral styling without reflecting a `variant` attribute.
|
|
22
26
|
|
|
23
|
-
- Type: `'
|
|
27
|
+
- Type: `'neutral' \| 'info' \| 'positive' \| 'warning' \| 'negative' \| 'disabled' \| 'price' \| 'sponsored'`
|
|
24
28
|
- Default: `-`
|
|
25
29
|
|
|
26
30
|
### Types
|
package/dist/docs/badge/badge.md
CHANGED
|
@@ -4,37 +4,218 @@
|
|
|
4
4
|
|
|
5
5
|
`w-badge` is used for showing a small amount of non-interactive color-categorized metadata, like a status or count.
|
|
6
6
|
|
|
7
|
-
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/layout-badge--docs)
|
|
8
|
-
|
|
9
7
|
## Usage
|
|
10
8
|
|
|
9
|
+
Badge is a compact, non-interactive label for short metadata such as status, category, count, price, or sponsorship information.
|
|
10
|
+
|
|
11
|
+
Use a badge when the label supports nearby content and does not require user interaction.
|
|
12
|
+
|
|
13
|
+
### Basic Badge
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<w-badge>New</w-badge>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Variants
|
|
20
|
+
|
|
21
|
+
Choose a variant that matches the meaning of the badge text:
|
|
22
|
+
|
|
23
|
+
- `neutral`: default metadata or low-emphasis labels
|
|
24
|
+
- `info`: informational labels
|
|
25
|
+
- `positive`: successful, active, or approved states
|
|
26
|
+
- `warning`: cautionary states
|
|
27
|
+
- `negative`: error, blocked, or rejected states
|
|
28
|
+
- `disabled`: unavailable or inactive states
|
|
29
|
+
- `price`: price labels, especially when placed over media
|
|
30
|
+
- `sponsored`: sponsored or commercial labels
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<w-badge variant="neutral">Neutral</w-badge>
|
|
34
|
+
<w-badge variant="info">Info</w-badge>
|
|
35
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
36
|
+
<w-badge variant="warning">Pending</w-badge>
|
|
37
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
38
|
+
<w-badge variant="disabled">Unavailable</w-badge>
|
|
39
|
+
<w-badge variant="price">1 200 kr</w-badge>
|
|
40
|
+
<w-badge variant="sponsored">Sponsored</w-badge>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
If `variant` is omitted, the badge uses the neutral visual treatment.
|
|
44
|
+
|
|
45
|
+
### Positioned Badges
|
|
46
|
+
|
|
47
|
+
Use `position` when a badge should sit in a corner of a parent element, such as a media thumbnail or listing image. The parent element should establish the positioning context with `position: relative`.
|
|
48
|
+
|
|
49
|
+
Supported positions are `top-left`, `top-right`, `bottom-right`, and `bottom-left`.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<div style="position: relative;">
|
|
53
|
+
<img src="listing.jpg" alt="Living room with large windows" />
|
|
54
|
+
<w-badge variant="price" position="top-right">1 200 kr</w-badge>
|
|
55
|
+
</div>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Content Guidelines
|
|
59
|
+
|
|
60
|
+
Keep badge text short and descriptive. Avoid using badges for full messages, instructions, or actions. Use [Alert](/docs/components/alert/overview) for important feedback messages and an interactive component, such as a button or link, when the user can act on the item.
|
|
61
|
+
|
|
11
62
|
## Accessibility
|
|
12
63
|
|
|
64
|
+
Badge renders slotted text as regular content. It does not add an ARIA role and it is not announced as a live region.
|
|
65
|
+
|
|
66
|
+
### Use Meaningful Text
|
|
67
|
+
|
|
68
|
+
Do not rely on color alone to communicate meaning. The badge text should describe the status or metadata by itself.
|
|
69
|
+
|
|
70
|
+
```html
|
|
71
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
72
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Avoid labels that only make sense visually:
|
|
76
|
+
|
|
77
|
+
```html
|
|
78
|
+
<!-- Avoid -->
|
|
79
|
+
<w-badge variant="positive">Green</w-badge>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Keep Badges Non-Interactive
|
|
83
|
+
|
|
84
|
+
Do not place interactive elements inside `w-badge`. If the user can click, dismiss, filter, or select the item, use an interactive component instead.
|
|
85
|
+
|
|
86
|
+
The `disabled` variant is visual only. It does not disable related controls or remove anything from the tab order.
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<!-- Avoid -->
|
|
90
|
+
<w-badge>
|
|
91
|
+
<button type="button">New</button>
|
|
92
|
+
</w-badge>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Dynamic Changes
|
|
96
|
+
|
|
97
|
+
If a badge value changes after the page has loaded and users need to be notified, announce that change outside the badge with an appropriate live region or use [Alert](/docs/components/alert/overview) for important feedback.
|
|
98
|
+
|
|
99
|
+
### Duplicate or Decorative Badges
|
|
100
|
+
|
|
101
|
+
If the same information is already available in nearby accessible text and the badge is only a visual duplicate, hide the duplicate badge from assistive technologies.
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<p>Sponsored listing</p>
|
|
105
|
+
<w-badge aria-hidden="true" variant="sponsored">Sponsored</w-badge>
|
|
106
|
+
```
|
|
107
|
+
|
|
13
108
|
## Examples
|
|
14
109
|
|
|
110
|
+
### Basic
|
|
111
|
+
|
|
112
|
+
<style-isolate>
|
|
113
|
+
<w-badge>New</w-badge>
|
|
114
|
+
</style-isolate>
|
|
115
|
+
|
|
116
|
+
```html
|
|
117
|
+
<w-badge>New</w-badge>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Status Variants
|
|
121
|
+
|
|
122
|
+
<style-isolate>
|
|
123
|
+
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
124
|
+
<w-badge variant="neutral">Neutral</w-badge>
|
|
125
|
+
<w-badge variant="info">Info</w-badge>
|
|
126
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
127
|
+
<w-badge variant="warning">Pending</w-badge>
|
|
128
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
129
|
+
<w-badge variant="disabled">Unavailable</w-badge>
|
|
130
|
+
</div>
|
|
131
|
+
</style-isolate>
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<w-badge variant="neutral">Neutral</w-badge>
|
|
135
|
+
<w-badge variant="info">Info</w-badge>
|
|
136
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
137
|
+
<w-badge variant="warning">Pending</w-badge>
|
|
138
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
139
|
+
<w-badge variant="disabled">Unavailable</w-badge>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Price
|
|
143
|
+
|
|
144
|
+
<style-isolate>
|
|
145
|
+
<w-badge variant="price">1 200 kr</w-badge>
|
|
146
|
+
</style-isolate>
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<w-badge variant="price">1 200 kr</w-badge>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Sponsored
|
|
153
|
+
|
|
154
|
+
<style-isolate>
|
|
155
|
+
<w-badge variant="sponsored">Sponsored</w-badge>
|
|
156
|
+
</style-isolate>
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<w-badge variant="sponsored">Sponsored</w-badge>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Positioned
|
|
163
|
+
|
|
164
|
+
<style-isolate>
|
|
165
|
+
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
166
|
+
<w-badge variant="price" position="top-right">1 200 kr</w-badge>
|
|
167
|
+
</div>
|
|
168
|
+
</style-isolate>
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<div style="position: relative;">
|
|
172
|
+
<img src="listing.jpg" alt="Living room with large windows" />
|
|
173
|
+
<w-badge variant="price" position="top-right">1 200 kr</w-badge>
|
|
174
|
+
</div>
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Positioned Sponsored Badge
|
|
178
|
+
|
|
179
|
+
<style-isolate>
|
|
180
|
+
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
181
|
+
<w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
|
|
182
|
+
</div>
|
|
183
|
+
</style-isolate>
|
|
184
|
+
|
|
185
|
+
```html
|
|
186
|
+
<div style="position: relative;">
|
|
187
|
+
<img src="listing.jpg" alt="Living room with large windows" />
|
|
188
|
+
<w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
|
|
189
|
+
</div>
|
|
190
|
+
```
|
|
191
|
+
|
|
15
192
|
## API Documentation
|
|
16
193
|
|
|
17
194
|
### Properties
|
|
18
195
|
|
|
19
196
|
| Name | Type | Default | Summary |
|
|
20
197
|
|-|-|-|-|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
198
|
+
| position | `'top-left' \| 'top-right' \| 'bottom-right' \| 'bottom-left'` | `-` | Positions the badge in a corner of a parent element. |
|
|
199
|
+
| variant | `'neutral' \| 'info' \| 'positive' \| 'warning' \| 'negative' \| 'disabled' \| 'price' \| 'sponsored'` | `-` | Controls the badge color treatment. |
|
|
23
200
|
|
|
24
201
|
### Property Details
|
|
25
202
|
|
|
26
|
-
####
|
|
27
|
-
|
|
203
|
+
#### position
|
|
28
204
|
|
|
205
|
+
Positions the badge in a corner of a parent element.
|
|
206
|
+
Use this with a parent element that has `position: relative`. When set, the badge uses absolute positioning and adjusts its corner radii so it sits flush against the selected corner.
|
|
207
|
+
Use this with a parent element that has `position: relative`. Accepted values are `top-left`, `top-right`, `bottom-right`, and `bottom-left`.
|
|
29
208
|
|
|
30
|
-
- Type: `'
|
|
209
|
+
- Type: `'top-left' \| 'top-right' \| 'bottom-right' \| 'bottom-left'`
|
|
31
210
|
- Default: `-`
|
|
32
211
|
|
|
33
|
-
####
|
|
34
|
-
|
|
212
|
+
#### variant
|
|
35
213
|
|
|
214
|
+
Controls the badge color treatment.
|
|
215
|
+
If omitted, the badge uses neutral styling without reflecting a `variant` attribute.
|
|
216
|
+
Accepted values are `neutral`, `info`, `positive`, `warning`, `negative`, `disabled`, `price`, and `sponsored`. If omitted, the badge uses neutral styling without reflecting a `variant` attribute.
|
|
36
217
|
|
|
37
|
-
- Type: `'
|
|
218
|
+
- Type: `'neutral' \| 'info' \| 'positive' \| 'warning' \| 'negative' \| 'disabled' \| 'price' \| 'sponsored'`
|
|
38
219
|
- Default: `-`
|
|
39
220
|
|
|
40
221
|
### Types
|