@reliability-design/web 1.4.5 → 1.4.7
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/CHANGELOG.md +211 -49
- package/dist/components/rel-accordion/README.md +132 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +156 -61
- package/dist/components/rel-avatar/README.md +116 -130
- package/dist/components/rel-badge/README.md +98 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +160 -130
- package/dist/components/rel-calendar/README.md +109 -109
- package/dist/components/rel-card/README.md +75 -94
- package/dist/components/rel-cardmedia/README.md +100 -127
- package/dist/components/rel-carousel/README.md +184 -166
- package/dist/components/rel-checkbox/README.md +93 -75
- package/dist/components/rel-chip/README.md +132 -121
- package/dist/components/rel-container/README.md +107 -99
- package/dist/components/rel-date-picker/README.md +200 -289
- package/dist/components/rel-divider/README.md +78 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-menu/README.md +178 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +170 -440
- package/dist/components/rel-pagination/README.md +100 -424
- package/dist/components/rel-popover/README.md +203 -568
- package/dist/components/rel-progress/README.md +88 -110
- package/dist/components/rel-radio/README.md +131 -135
- package/dist/components/rel-range-picker/README.md +162 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +155 -141
- package/dist/components/rel-select/README.md +154 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +103 -0
- package/dist/components/rel-slider/README.md +130 -135
- package/dist/components/rel-snackbar/README.md +162 -134
- package/dist/components/rel-stepper/README.md +158 -160
- package/dist/components/rel-switch/README.md +108 -102
- package/dist/components/rel-tab/README.md +171 -163
- package/dist/components/rel-textfield/README.md +159 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +157 -148
- package/dist/components/rel-tooltip/README.md +108 -103
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1387 -350
- package/dist/index.d.ts +1387 -350
- package/dist/index.js +5863 -3600
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5864 -3592
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +877 -866
- package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
- package/package.json +4 -3
- package/dist/components/rel-accordion/rel-accordion.ts +0 -336
- package/dist/components/rel-alert/rel-alert.ts +0 -305
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -689
- package/dist/components/rel-avatar/rel-avatar.ts +0 -142
- package/dist/components/rel-badge/rel-badge.ts +0 -170
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
- package/dist/components/rel-button/rel-button.ts +0 -560
- package/dist/components/rel-calendar/index.ts +0 -1
- package/dist/components/rel-calendar/rel-calendar.ts +0 -519
- package/dist/components/rel-card/rel-card.ts +0 -88
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
- package/dist/components/rel-carousel/index.ts +0 -1
- package/dist/components/rel-carousel/rel-carousel.ts +0 -700
- package/dist/components/rel-chart/README.md +0 -286
- package/dist/components/rel-chart/index.ts +0 -1
- package/dist/components/rel-chart/rel-chart.ts +0 -754
- package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
- package/dist/components/rel-chip/rel-chip.ts +0 -472
- package/dist/components/rel-container/rel-container.ts +0 -95
- package/dist/components/rel-date-picker/date-format.test.ts +0 -43
- package/dist/components/rel-date-picker/date-format.ts +0 -47
- package/dist/components/rel-date-picker/index.ts +0 -1
- package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1237
- package/dist/components/rel-divider/rel-divider.ts +0 -54
- package/dist/components/rel-drawer/index.ts +0 -1
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
- package/dist/components/rel-drawer/rel-drawer.ts +0 -604
- package/dist/components/rel-kbd/rel-kbd.ts +0 -188
- package/dist/components/rel-layout/rel-layout.ts +0 -49
- package/dist/components/rel-menu/rel-menu.ts +0 -535
- package/dist/components/rel-menubar/index.ts +0 -2
- package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
- package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
- package/dist/components/rel-menubar/rel-menubar.ts +0 -777
- package/dist/components/rel-nav-menu/README.md +0 -289
- package/dist/components/rel-nav-menu/index.ts +0 -3
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
- package/dist/components/rel-navbar/README.md +0 -126
- package/dist/components/rel-navbar/rel-navbar.ts +0 -105
- package/dist/components/rel-otp/index.ts +0 -1
- package/dist/components/rel-otp/rel-otp.ts +0 -517
- package/dist/components/rel-pagination/index.ts +0 -1
- package/dist/components/rel-pagination/rel-pagination.ts +0 -509
- package/dist/components/rel-popover/index.ts +0 -2
- package/dist/components/rel-popover/rel-popover-content.ts +0 -81
- package/dist/components/rel-popover/rel-popover.ts +0 -444
- package/dist/components/rel-progress/rel-progress.ts +0 -225
- package/dist/components/rel-radio/rel-radio.ts +0 -305
- package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1331
- package/dist/components/rel-resizable/index.ts +0 -3
- package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
- package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
- package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -213
- package/dist/components/rel-select/rel-select.ts +0 -1385
- package/dist/components/rel-sheet/rel-sheet.ts +0 -465
- package/dist/components/rel-sidebar/README.md +0 -209
- package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1185
- package/dist/components/rel-skeleton/rel-skeleton.ts +0 -134
- package/dist/components/rel-slider/rel-slider.ts +0 -670
- package/dist/components/rel-snackbar/rel-snackbar.ts +0 -325
- package/dist/components/rel-stepper/rel-stepper.ts +0 -565
- package/dist/components/rel-switch/rel-switch.ts +0 -197
- package/dist/components/rel-tab/rel-tab.ts +0 -264
- package/dist/components/rel-table/README.md +0 -178
- package/dist/components/rel-table/rel-table-body.ts +0 -22
- package/dist/components/rel-table/rel-table-caption.ts +0 -30
- package/dist/components/rel-table/rel-table-cell.ts +0 -43
- package/dist/components/rel-table/rel-table-footer.ts +0 -24
- package/dist/components/rel-table/rel-table-head.ts +0 -47
- package/dist/components/rel-table/rel-table-header.ts +0 -22
- package/dist/components/rel-table/rel-table-row.ts +0 -37
- package/dist/components/rel-table/rel-table.ts +0 -62
- package/dist/components/rel-textfield/rel-textfield.ts +0 -866
- package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1126
- package/dist/components/rel-toast/rel-toast.ts +0 -204
- package/dist/components/rel-tooltip/rel-tooltip.ts +0 -190
- package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
- package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar.ts +0 -446
- package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
- package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
- package/dist/components/rel-upload/rel-upload.ts +0 -943
|
@@ -1,130 +1,116 @@
|
|
|
1
|
-
# rel-avatar
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!-- Image avatar -->
|
|
9
|
-
<rel-avatar
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
</rel-avatar>
|
|
20
|
-
|
|
21
|
-
<!--
|
|
22
|
-
<rel-avatar type="
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<rel-avatar type="text" text="
|
|
30
|
-
<rel-avatar type="text" text="
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
<rel-avatar type="text" text="
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<!--
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
|
57
|
-
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
| Slot | Description |
|
|
71
|
-
|
|
72
|
-
| (default) |
|
|
73
|
-
|
|
74
|
-
## CSS Parts
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
-
|
|
116
|
-
|
|
117
|
-
- Uses `object-fit: cover` for proper image scaling
|
|
118
|
-
- Image is `width: 100%`, `height: 100%`
|
|
119
|
-
- **text**: Displays the `text` property in a `<span>`
|
|
120
|
-
- Text is automatically uppercased via `text-transform: uppercase`
|
|
121
|
-
- **icon**: Displays slotted content (typically SVG)
|
|
122
|
-
- Slotted SVGs are automatically sized to 50% of the avatar size
|
|
123
|
-
|
|
124
|
-
- The avatar is always circular via `border-radius: 50%`
|
|
125
|
-
- The avatar uses `overflow: hidden` to clip images to circle shape
|
|
126
|
-
- Text and icons are centered using flexbox
|
|
127
|
-
- The avatar is `inline-flex` for easy inline usage with text
|
|
128
|
-
- The `size` and `type` attributes are reflected in HTML
|
|
129
|
-
- The component uses `user-select: none` to prevent text selection
|
|
130
|
-
- If `type` is `image` but `src` is empty, nothing is displayed (no fallback)
|
|
1
|
+
# rel-avatar
|
|
2
|
+
|
|
3
|
+
`<rel-avatar>` is the circular identity mark of the Figma "Avatar" component: a 20–40px disc that shows a photo (`type="image"`), uppercase initials (`type="text"`) or a slotted icon (`type="icon"`), in a solid `fill`, a neutral `subtle` or a bordered `outline` variant. Use it wherever a person, team or account needs a compact visual identity — user menus, comment threads, assignee columns, stacked avatar groups. It is purely presentational: it takes no focus and emits no events, so wrap it in a button or link when it should be clickable, and overlay a `rel-badge` when it needs a status or count.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Image avatar (always pass a meaningful alt) -->
|
|
9
|
+
<rel-avatar type="image" src="./user-photo.jpg" alt="Priya Natarajan"></rel-avatar>
|
|
10
|
+
|
|
11
|
+
<!-- Initials -->
|
|
12
|
+
<rel-avatar type="text" text="PN"></rel-avatar>
|
|
13
|
+
|
|
14
|
+
<!-- Slotted icon -->
|
|
15
|
+
<rel-avatar type="icon">
|
|
16
|
+
<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
|
|
17
|
+
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
|
18
|
+
</svg>
|
|
19
|
+
</rel-avatar>
|
|
20
|
+
|
|
21
|
+
<!-- Sizes: xs 20px, sm 24px, md 32px (default), lg 40px -->
|
|
22
|
+
<rel-avatar type="text" text="XS" size="xs"></rel-avatar>
|
|
23
|
+
<rel-avatar type="text" text="SM" size="sm"></rel-avatar>
|
|
24
|
+
<rel-avatar type="text" text="MD" size="md"></rel-avatar>
|
|
25
|
+
<rel-avatar type="text" text="LG" size="lg"></rel-avatar>
|
|
26
|
+
|
|
27
|
+
<!-- Variants -->
|
|
28
|
+
<rel-avatar type="text" text="AA" variant="fill"></rel-avatar>
|
|
29
|
+
<rel-avatar type="text" text="AA" variant="subtle"></rel-avatar>
|
|
30
|
+
<rel-avatar type="text" text="AA" variant="outline"></rel-avatar>
|
|
31
|
+
|
|
32
|
+
<!-- Inline colour overrides (any CSS colour) -->
|
|
33
|
+
<rel-avatar type="text" text="JD" bg="#1d4ed8" color="#ffffff"></rel-avatar>
|
|
34
|
+
|
|
35
|
+
<!-- Stacked group -->
|
|
36
|
+
<div style="display: flex; padding-left: 8px;">
|
|
37
|
+
<rel-avatar type="text" text="A" style="margin-left: -8px;"></rel-avatar>
|
|
38
|
+
<rel-avatar type="text" text="B" style="margin-left: -8px;"></rel-avatar>
|
|
39
|
+
<rel-avatar type="text" text="C" style="margin-left: -8px;"></rel-avatar>
|
|
40
|
+
</div>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
<!-- readme-gen:start -->
|
|
44
|
+
|
|
45
|
+
<!-- Generated from rel-avatar.ts — do not edit; run readme-generate.mjs -->
|
|
46
|
+
|
|
47
|
+
## API
|
|
48
|
+
|
|
49
|
+
### Attributes / Properties
|
|
50
|
+
|
|
51
|
+
| Property | Attribute | Type | Default | Description |
|
|
52
|
+
| --- | --- | --- | --- | --- |
|
|
53
|
+
| `size` | `size` | `"lg" \| "md" \| "sm" \| "xs"` | `"md"` | Diameter step: `lg` 40px, `md` 32px, `sm` 24px, `xs` 20px; each binds the matching body-*-semibold text role for initials. Reflected. |
|
|
54
|
+
| `type` | `type` | `"image" \| "text" \| "icon"` | `"image"` | What is rendered inside the circle: `image` shows `src`, `text` shows the `text` initials, `icon` shows the default slot. Reflected. |
|
|
55
|
+
| `variant` | `variant` | `"fill" \| "subtle" \| "outline"` | `"fill"` | Fill style: `fill` = solid inverse background with light text, `subtle` = elevated neutral background, `outline` = transparent with a 1px border. Reflected. |
|
|
56
|
+
| `src` | `src` | `string` | `""` | Image URL for `type="image"`; when empty nothing is rendered inside the circle (there is no fallback to initials). |
|
|
57
|
+
| `text` | `text` | `string` | `""` | Initials shown for `type="text"`; rendered uppercase via `text-transform`. |
|
|
58
|
+
| `alt` | `alt` | `string` | `"Avatar"` | Alt text of the `<img>` for `type="image"`; the default is the generic word "Avatar", so pass the person's name. |
|
|
59
|
+
| `bg` | `bg` | `string` | `""` | Any CSS colour applied inline as `background-color` on the circle, overriding the variant background. |
|
|
60
|
+
| `color` | `color` | `string` | `""` | Any CSS colour applied inline as `color` on the circle (initials / icon), overriding the variant text colour. |
|
|
61
|
+
|
|
62
|
+
## Events
|
|
63
|
+
|
|
64
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
65
|
+
| --- | --- | --- | --- |
|
|
66
|
+
| — | — | — | This element emits no custom events. |
|
|
67
|
+
|
|
68
|
+
## Slots
|
|
69
|
+
|
|
70
|
+
| Slot | Description |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| (default) | Icon content rendered when `type="icon"` (typically an inline SVG, sized to 50% of the circle) |
|
|
73
|
+
|
|
74
|
+
## CSS Parts
|
|
75
|
+
|
|
76
|
+
| Part | Description |
|
|
77
|
+
| --- | --- |
|
|
78
|
+
| `base` | The circular wrapper that carries the size, variant and inline `bg` / `color` overrides |
|
|
79
|
+
| `icon` | The `<img>` (`type="image"`) or the icon wrapper span around the slot (`type="icon"`) |
|
|
80
|
+
| `label` | The `<span>` holding the initials when `type="text"` |
|
|
81
|
+
|
|
82
|
+
## Tokens / CSS Variables
|
|
83
|
+
|
|
84
|
+
### Component hooks
|
|
85
|
+
|
|
86
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
87
|
+
|
|
88
|
+
| Custom property | Default | Description |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| `--rel-avatar-bg-fill` | `var(--rel-bg-neutral-inverse-2)` | Background colour of the `fill` variant |
|
|
91
|
+
| `--rel-avatar-bg-subtle` | `var(--rel-bg-neutral-elevated-1)` | Background colour of the `subtle` variant |
|
|
92
|
+
| `--rel-avatar-border-outline` | `var(--rel-border-default)` | 1px border colour of the `outline` variant |
|
|
93
|
+
| `--rel-avatar-color-fill` | `var(--rel-text-inverse)` | Text / icon colour of the `fill` variant |
|
|
94
|
+
| `--rel-avatar-color-outline` | `var(--rel-text-default)` | Text / icon colour of the `outline` variant |
|
|
95
|
+
| `--rel-avatar-color-subtle` | `var(--rel-text-default)` | Text / icon colour of the `subtle` variant |
|
|
96
|
+
| `--rel-avatar-font-size` | `var(--_rel-avatar-font-size)` | Overrides the initials' font-size, for use alongside `--rel-avatar-size`; defaults to the preset's text role |
|
|
97
|
+
| `--rel-avatar-size` | `var(--_rel-avatar-size)` | Overrides the circle's width/height for sizes between (or below) the `size` presets; defaults to the preset's diameter |
|
|
98
|
+
|
|
99
|
+
<!-- readme-gen:end -->
|
|
100
|
+
|
|
101
|
+
## Accessibility
|
|
102
|
+
|
|
103
|
+
- The host has no ARIA role and no keyboard handling, and it is never focusable. Put it inside a `<button>` or `<a>` when it should be interactive and give that element the accessible name.
|
|
104
|
+
- `type="image"` renders a real `<img>` whose alt text comes from the `alt` prop. The default is the generic word "Avatar" — pass the person's name, or an empty string when the avatar sits next to visible text with the same name.
|
|
105
|
+
- `type="text"` renders the initials as plain text in the `label` part, so screen readers read the letters ("P N"). If the initials alone are meaningless, add `aria-hidden="true"` and keep the full name in nearby text.
|
|
106
|
+
- `type="icon"` slots your SVG unchanged; add `aria-hidden="true"` to decorative icons or a `<title>` to meaningful ones.
|
|
107
|
+
- The three variants differ only by colour; every colour used has a dark-mode value in `vars.css`, so no extra theming is needed.
|
|
108
|
+
|
|
109
|
+
## Notes / Edge Cases
|
|
110
|
+
|
|
111
|
+
- The disc is `border-radius: 50%` with `overflow: hidden`; images use `object-fit: cover`, so non-square sources are centre-cropped rather than stretched.
|
|
112
|
+
- `type="image"` with an empty `src` renders an empty circle — there is no automatic fallback to initials. Switch `type` yourself when the photo is missing.
|
|
113
|
+
- Every variant keeps a 1px border (`--rel-stroke-sm`); `fill` and `subtle` make it transparent so the outer size is identical across variants.
|
|
114
|
+
- `bg` and `color` are written as inline styles on the `base` part, so they win over both the `--rel-avatar-*` hooks and the variant tokens.
|
|
115
|
+
- Initials are forced uppercase and `user-select: none`. `size`, `type` and `variant` are reflected, so `rel-avatar[size="lg"]` works as a selector.
|
|
116
|
+
- The `icon` part name is shared by the `<img>` (`type="image"`) and the slot wrapper (`type="icon"`); `::part(icon)` matches whichever one is rendered.
|
|
@@ -1,93 +1,98 @@
|
|
|
1
|
-
# rel-badge
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!-- Number badges -->
|
|
9
|
-
<rel-badge number="5"></rel-badge>
|
|
10
|
-
<rel-badge number="12" size="md"></rel-badge>
|
|
11
|
-
<rel-badge number="99+" size="lg"></rel-badge>
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
<rel-badge variant="dot" size="
|
|
16
|
-
<rel-badge variant="dot" size="
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<rel-badge number="
|
|
27
|
-
<rel-badge
|
|
28
|
-
|
|
29
|
-
<!--
|
|
30
|
-
<rel-badge number="3" color="#7d7d7d"></rel-badge>
|
|
31
|
-
<rel-badge number="3" color="teal" text-color="#1a1a1a"></rel-badge>
|
|
32
|
-
<rel-badge variant="dot" color="
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
-
|
|
1
|
+
# rel-badge
|
|
2
|
+
|
|
3
|
+
`<rel-badge>` is the Figma "Badge" count indicator: a small `number` pill ("5", "99+") or an unlabeled `dot`, in four sizes (S/M/L/XL), filled with the danger token by default and overridable per instance through `color` / `text-color`. Use it to flag unread counts or unseen activity on an icon, tab, avatar or navigation item — you position it over the target yourself. It is not a text tag (use `rel-chip`) and not a status message (use `rel-alert` or `rel-toast`); it only carries a count or a "something is new" signal.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Number badges -->
|
|
9
|
+
<rel-badge number="5"></rel-badge>
|
|
10
|
+
<rel-badge number="12" size="md"></rel-badge>
|
|
11
|
+
<rel-badge number="99+" size="lg"></rel-badge>
|
|
12
|
+
<rel-badge number="120" size="xl"></rel-badge>
|
|
13
|
+
|
|
14
|
+
<!-- Dot badges (no text) -->
|
|
15
|
+
<rel-badge variant="dot" size="sm"></rel-badge>
|
|
16
|
+
<rel-badge variant="dot" size="md"></rel-badge>
|
|
17
|
+
<rel-badge variant="dot" size="lg"></rel-badge>
|
|
18
|
+
|
|
19
|
+
<!-- Positioned over an icon button -->
|
|
20
|
+
<div style="position: relative; display: inline-block;">
|
|
21
|
+
<button aria-label="Notifications">🔔</button>
|
|
22
|
+
<rel-badge number="3" size="sm" style="position: absolute; top: -8px; right: -8px;"></rel-badge>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<!-- Accessible-name control -->
|
|
26
|
+
<rel-badge number="3" suffix="unread messages"></rel-badge>
|
|
27
|
+
<rel-badge variant="dot" arialabel="New activity"></rel-badge>
|
|
28
|
+
|
|
29
|
+
<!-- Colour overrides: any CSS colour, including a token via var() -->
|
|
30
|
+
<rel-badge number="3" color="#7d7d7d"></rel-badge>
|
|
31
|
+
<rel-badge number="3" color="teal" text-color="#1a1a1a"></rel-badge>
|
|
32
|
+
<rel-badge variant="dot" color="seagreen"></rel-badge>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
<!-- readme-gen:start -->
|
|
36
|
+
|
|
37
|
+
<!-- Generated from rel-badge.ts — do not edit; run readme-generate.mjs -->
|
|
38
|
+
|
|
39
|
+
## API
|
|
40
|
+
|
|
41
|
+
### Attributes / Properties
|
|
42
|
+
|
|
43
|
+
| Property | Attribute | Type | Default | Description |
|
|
44
|
+
| --- | --- | --- | --- | --- |
|
|
45
|
+
| `number` | `number` | `string` | `""` | Text shown in the `number` variant (a count such as "5" or "99+"); not rendered by `variant="dot"` but still used to build the accessible name. |
|
|
46
|
+
| `ariaLabel` | `arialabel` | `string` | `""` | Explicit accessible name; when empty it is composed as "<number> <suffix>" or, with no number, "New <suffix>". Attribute is `arialabel`. |
|
|
47
|
+
| `suffix` | `suffix` | `string` | `"notifications"` | Noun appended to the count in the generated accessible name, e.g. "3 notifications". |
|
|
48
|
+
| `size` | `size` | `"sm" \| "md" \| "lg" \| "xl"` | `"md"` | Badge scale (Figma Badge S/M/L/XL): number badges are 20 / 24 / 28 / 40px tall, dot badges 8 / 10 / 12 / 12px. Reflected. |
|
|
49
|
+
| `variant` | `variant` | `"dot" \| "number"` | `"number"` | `number` renders the `number` text in a pill that widens with its content; `dot` renders a small disc with no text. Reflected. |
|
|
50
|
+
| `color` | `color` | `string` | `""` | Direct CSS color override for the badge background. Accepts any valid CSS color value: hex, rgb(...), hsl(...), named color, or var(--token). Clear it (set to `''`) to fall back to the default token. Reflected. |
|
|
51
|
+
| `textColor` | `text-color` | `string` | `""` | Direct CSS color override for the badge text/icon color. Accepts any valid CSS color value: hex, rgb(...), hsl(...), named color, or var(--token). Clear it (set to `''`) to fall back to the default (white). Reflected. |
|
|
52
|
+
|
|
53
|
+
## Events
|
|
54
|
+
|
|
55
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
56
|
+
| --- | --- | --- | --- |
|
|
57
|
+
| — | — | — | This element emits no custom events. |
|
|
58
|
+
|
|
59
|
+
## Slots
|
|
60
|
+
|
|
61
|
+
| Slot | Description |
|
|
62
|
+
| --- | --- |
|
|
63
|
+
| — | This element has no slots. |
|
|
64
|
+
|
|
65
|
+
## CSS Parts
|
|
66
|
+
|
|
67
|
+
| Part | Description |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
| `base` | The `role="status"` pill / dot that carries the size, variant and colour overrides |
|
|
70
|
+
|
|
71
|
+
## Tokens / CSS Variables
|
|
72
|
+
|
|
73
|
+
### Component hooks
|
|
74
|
+
|
|
75
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
76
|
+
|
|
77
|
+
| Custom property | Default | Description |
|
|
78
|
+
| --- | --- | --- |
|
|
79
|
+
| `--rel-badge-bg` | `var(--rel-bg-danger)` | Background colour of the badge; the `color` prop writes this on the host |
|
|
80
|
+
| `--rel-badge-color` | `var(--rel-text-static-light)` | Text colour of the count; the `text-color` prop writes this on the host |
|
|
81
|
+
|
|
82
|
+
<!-- readme-gen:end -->
|
|
83
|
+
|
|
84
|
+
## Accessibility
|
|
85
|
+
|
|
86
|
+
- The pill (`base` part) renders with `role="status"` and an `aria-label`. The label is `ariaLabel` when set; otherwise it is composed as `"<number> <suffix>"` (e.g. "3 notifications") or, when `number` is empty (dot badges), `"New <suffix>"` (e.g. "New notifications"). Set `suffix` so the announcement names the right thing, or `arialabel` for full control.
|
|
87
|
+
- `role="status"` is an implicit polite live region, so a change to `number` may be announced without the badge ever taking focus; verify the behaviour with your target screen reader before relying on it.
|
|
88
|
+
- The host is not focusable and handles no keys. Interactive meaning ("open notifications") belongs to the element the badge decorates — give that element its own accessible name.
|
|
89
|
+
- A dot badge has no visible text; the generated name is the only thing a screen reader gets, and sighted users get colour alone. Pair it with nearby text when the meaning is not obvious from context.
|
|
90
|
+
|
|
91
|
+
## Notes / Edge Cases
|
|
92
|
+
|
|
93
|
+
- Number badge heights are 20 / 24 / 28 / 40px for `sm` / `md` / `lg` / `xl`; dot badges are 8 / 10 / 12 / 12px (`lg` and `xl` dots are the same size). The number badge sets `min-width`, not `width`, so a two-digit count stays a circle while "999+" grows into a pill.
|
|
94
|
+
- The corner radius is a fixed `999px`, not `50%`, which is what lets wide content become a pill instead of clipping.
|
|
95
|
+
- In `variant="dot"` the `number` text is not rendered but still feeds the accessible name ("3 notifications" for a dot with `number="3"`).
|
|
96
|
+
- `color` and `text-color` are applied by writing `--rel-badge-bg` / `--rel-badge-color` as inline custom properties on the host; clearing the prop removes the inline value and falls back to whatever the hook resolves to (the danger / static-light tokens unless you set the hook in your own CSS).
|
|
97
|
+
- The accessible-name property is `ariaLabel` with the attribute `arialabel` (no hyphen). A plain `aria-label` attribute on the host is not read by the component, and because the host has no role it does not reach the `role="status"` element either — use `arialabel`.
|
|
98
|
+
- The host is `display: inline-flex`; the usual pattern is an absolutely positioned badge inside a `position: relative` wrapper around the decorated element.
|