material-inspired-component-library 1.3.0 → 2.0.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 +9 -1
- package/components/badge/README.md +65 -0
- package/components/badge/index.scss +68 -0
- package/components/button/index.scss +10 -12
- package/components/button/index.ts +5 -0
- package/components/card/index.scss +2 -2
- package/components/checkbox/index.scss +1 -1
- package/components/iconbutton/index.scss +2 -2
- package/components/iconbutton/index.ts +5 -0
- package/components/list/index.scss +2 -2
- package/components/navigationrail/README.md +110 -59
- package/components/navigationrail/index.scss +399 -88
- package/components/{checkbox → navigationrail}/index.ts +12 -7
- package/components/radio/index.scss +2 -2
- package/dist/badge.css +1 -0
- package/dist/badge.js +1 -0
- package/dist/button.css +1 -1
- package/dist/card.css +1 -1
- package/dist/checkbox.css +1 -1
- package/dist/components/navigationrail/index.d.ts +5 -0
- package/dist/iconbutton.css +1 -1
- package/dist/list.css +1 -1
- package/dist/micl.css +1 -1
- package/dist/micl.js +1 -1
- package/dist/navigationrail.css +1 -1
- package/dist/radio.css +1 -1
- package/docs/button.html +5 -5
- package/docs/docs.css +2 -1
- package/docs/index.html +32 -1
- package/docs/micl.css +1 -1
- package/docs/micl.js +1 -1
- package/docs/navigationrail.html +48 -42
- package/micl.ts +20 -27
- package/package.json +4 -1
- package/styles.scss +17 -0
- package/dist/components/checkbox/index.d.ts +0 -5
package/README.md
CHANGED
|
@@ -79,6 +79,7 @@ This will initialize all MICL components, including those that will be added to
|
|
|
79
79
|
## Available components ✅
|
|
80
80
|
The library currently consists of the following components:
|
|
81
81
|
- [x] [Accordion](components/accordion/README.md)
|
|
82
|
+
- [x] [Badge](components/badge/README.md)
|
|
82
83
|
- [x] [Bottom sheet](components/bottomsheet/README.md)
|
|
83
84
|
- [x] [Button](components/button/README.md)
|
|
84
85
|
- [x] [Card](components/card/README.md)
|
|
@@ -88,7 +89,7 @@ The library currently consists of the following components:
|
|
|
88
89
|
- [x] [Icon button](components/iconbutton/README.md)
|
|
89
90
|
- [x] [List](components/list/README.md)
|
|
90
91
|
- [x] [Menu](components/menu/README.md)
|
|
91
|
-
- [
|
|
92
|
+
- [x] [Navigation rail](components/navigationrail/README.md)
|
|
92
93
|
- [x] [Radio button](components/radio/README.md)
|
|
93
94
|
- [x] [Select](components/select/README.md)
|
|
94
95
|
- [x] [Side sheet](components/sidesheet/README.md)
|
|
@@ -98,6 +99,13 @@ The library currently consists of the following components:
|
|
|
98
99
|
|
|
99
100
|
## Change Log
|
|
100
101
|
|
|
102
|
+
### 2.0.0 (04.09.2025)
|
|
103
|
+
**Features**
|
|
104
|
+
|
|
105
|
+
- **Navigation rail**: New component.
|
|
106
|
+
- **Badge**: New component.
|
|
107
|
+
- **Ripple**: Now uses custom CSS properties.
|
|
108
|
+
|
|
101
109
|
### 1.3.0 (23.08.2025)
|
|
102
110
|
**Features**
|
|
103
111
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Badge
|
|
2
|
+
This component implements the the [Material Design 3 Expressive Badge](https://m3.material.io/components/badges/overview) design. Badges are small status indicators that can show a count or simply signal new information.
|
|
3
|
+
|
|
4
|
+
## Basic Usage
|
|
5
|
+
|
|
6
|
+
### HTML
|
|
7
|
+
To add a large badge, use a `<span>` element with the `micl-badge-large` class and add a short text inside. For a small badge, which is a simple dot, use a `<span>` with the `micl-badge-small` class and leave the element empty.
|
|
8
|
+
|
|
9
|
+
```HTML
|
|
10
|
+
<span class="micl-badge-large">57</span>
|
|
11
|
+
|
|
12
|
+
<span class="micl-badge-small"></span>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### CSS
|
|
16
|
+
Import the badge styles into your project:
|
|
17
|
+
|
|
18
|
+
```CSS
|
|
19
|
+
@use "material-inspired-component-library/dist/badge";
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### JavaScript
|
|
23
|
+
No custom JavaScript is required for the core functionality of this component.
|
|
24
|
+
|
|
25
|
+
### Demo
|
|
26
|
+
A live example of the [Badge component](https://henkpb.github.io/micl/index.html) is available for you to interact with.
|
|
27
|
+
|
|
28
|
+
## Anchoring
|
|
29
|
+
Badges are typically placed on top of other elements, like icons. To anchor a badge to a specific element, use CSS `anchor positioning`.
|
|
30
|
+
|
|
31
|
+
1. Assign a unique `anchor-name` to the element you want to anchor the badge to. The value should start with `--`.
|
|
32
|
+
2. Use the `position-anchor` CSS property on the badge and set its value to the `anchor-name` of the target element.
|
|
33
|
+
|
|
34
|
+
```HTML
|
|
35
|
+
<span class="material-symbols-outlined" style="anchor-name:--inbox">inbox</span>
|
|
36
|
+
<span class="micl-badge-large" style="position-anchor:--inbox">57</span>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
You can fine-tune the badge's position relative to its anchor using the following CSS variables:
|
|
40
|
+
|
|
41
|
+
| Variable name | Default Value | Description |
|
|
42
|
+
| ------------- | ------------- | ----------- |
|
|
43
|
+
| --md-sys-badge-inline-offset | 0px | Adjusts the horizontal position of the badge |
|
|
44
|
+
| --md-sys-badge-block-offset | 0px | Adjusts the vertical position of the badge |
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
## Customizations
|
|
48
|
+
You can customize the appearance of the Badge component by overriding its global CSS variables. These variables are declared on the `:root` pseudo-class and can be changed on any appropriate parent element to affect its child badges.
|
|
49
|
+
|
|
50
|
+
| Variable name | Default Value | Description |
|
|
51
|
+
| ------------- | ------------- | ----------- |
|
|
52
|
+
| --md-sys-badge-small-size | 6px | The height and width of the small badge |
|
|
53
|
+
| --md-sys-badge-large-size | 16px | The height and minimum width of the large badge |
|
|
54
|
+
| --md-sys-badge-large-padding | 4px | The horizontal padding used for the large badge |
|
|
55
|
+
|
|
56
|
+
**Example: Changing the size of the small badge**
|
|
57
|
+
|
|
58
|
+
```HTML
|
|
59
|
+
<div style="--md-sys-badge-small-size:8px">
|
|
60
|
+
<span class="micl-badge-small"></span>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Compatibility
|
|
65
|
+
This component uses **anchor positioning**, a modern CSS feature that may not be fully supported in all browsers. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/anchor#browser_compatibility) for details.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright © 2025 Hermana AS
|
|
3
|
+
//
|
|
4
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
// in the Software without restriction, including without limitation the rights
|
|
7
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
// furnished to do so, subject to the following conditions:
|
|
10
|
+
//
|
|
11
|
+
// The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
// copies or substantial portions of the Software.
|
|
13
|
+
//
|
|
14
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
// SOFTWARE.
|
|
21
|
+
|
|
22
|
+
@use '../../styles/typography';
|
|
23
|
+
|
|
24
|
+
:root {
|
|
25
|
+
--md-sys-badge-small-size: 6px;
|
|
26
|
+
--md-sys-badge-large-size: 16px;
|
|
27
|
+
--md-sys-badge-large-padding: 4px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.micl-badge-small {
|
|
31
|
+
--md-sys-badge-inline-offset: 0px;
|
|
32
|
+
--md-sys-badge-block-offset: 0px;
|
|
33
|
+
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
position: fixed;
|
|
36
|
+
inline-size: var(--md-sys-badge-small-size);
|
|
37
|
+
block-size: var(--md-sys-badge-small-size);
|
|
38
|
+
inset: unset;
|
|
39
|
+
inset-block-start: calc(anchor(start) + var(--md-sys-badge-block-offset));
|
|
40
|
+
inset-inline-start: calc(anchor(end) - var(--md-sys-badge-small-size) - var(--md-sys-badge-inline-offset));
|
|
41
|
+
border-radius: calc(var(--md-sys-badge-small-size) / 2);
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
44
|
+
background-color: var(--md-sys-color-error);
|
|
45
|
+
color: var(--md-sys-color-on-error);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.micl-badge-large {
|
|
49
|
+
--md-sys-badge-inline-offset: 0px;
|
|
50
|
+
--md-sys-badge-block-offset: 0px;
|
|
51
|
+
|
|
52
|
+
@include typography.label-small;
|
|
53
|
+
|
|
54
|
+
box-sizing: border-box;
|
|
55
|
+
position: fixed;
|
|
56
|
+
inline-size: fit-content;
|
|
57
|
+
max-inline-size: 34px;
|
|
58
|
+
min-inline-size: var(--md-sys-badge-large-size);
|
|
59
|
+
block-size: var(--md-sys-badge-large-size);
|
|
60
|
+
inset: unset;
|
|
61
|
+
inset-block-start: calc(anchor(start) - 2px + var(--md-sys-badge-block-offset));
|
|
62
|
+
inset-inline-start: calc(anchor(end) - 12px - var(--md-sys-badge-inline-offset));
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding-inline: var(--md-sys-badge-large-padding);
|
|
65
|
+
border-radius: calc(var(--md-sys-badge-large-size) / 2);
|
|
66
|
+
background-color: var(--md-sys-color-error);
|
|
67
|
+
color: var(--md-sys-color-on-error);
|
|
68
|
+
}
|
|
@@ -53,12 +53,15 @@ button.micl-button-outlined-xl {
|
|
|
53
53
|
--md-sys-button-motion-effects: #{motion.$md-sys-motion-expressive-fast-spatial};
|
|
54
54
|
--md-sys-button-motion-duration: #{motion.$md-sys-motion-expressive-fast-spatial-duration};
|
|
55
55
|
--md-sys-button-motion-duration-reverse: #{motion.$md-sys-motion-expressive-fast-spatial-duration};
|
|
56
|
-
--
|
|
56
|
+
--micl-ripple: 1;
|
|
57
57
|
|
|
58
|
+
position: relative;
|
|
59
|
+
display: inline-flex;
|
|
60
|
+
align-items: center;
|
|
58
61
|
padding: 0;
|
|
59
62
|
border: none;
|
|
60
63
|
background-image:
|
|
61
|
-
radial-gradient(circle at var(--x, center) var(--y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
64
|
+
radial-gradient(circle at var(--micl-x, center) var(--micl-y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
62
65
|
linear-gradient(rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)));
|
|
63
66
|
background-repeat: no-repeat;
|
|
64
67
|
background-size: 10000%, 100%;
|
|
@@ -97,6 +100,7 @@ button.micl-button-tonal-xs,
|
|
|
97
100
|
button.micl-button-outlined-xs {
|
|
98
101
|
@include typography.label-large;
|
|
99
102
|
|
|
103
|
+
column-gap: 8px;
|
|
100
104
|
min-width: var(--md-sys-target-size);
|
|
101
105
|
height: var(--md-sys-target-size);
|
|
102
106
|
padding-inline: 12px;
|
|
@@ -134,8 +138,6 @@ button.micl-button-outlined-xs {
|
|
|
134
138
|
.micl-button__icon {
|
|
135
139
|
font-size: 20px;
|
|
136
140
|
width: 20px;
|
|
137
|
-
margin-right: 8px;
|
|
138
|
-
vertical-align: text-bottom;
|
|
139
141
|
}
|
|
140
142
|
}
|
|
141
143
|
|
|
@@ -146,6 +148,7 @@ button.micl-button-tonal-s,
|
|
|
146
148
|
button.micl-button-outlined-s {
|
|
147
149
|
@include typography.label-large;
|
|
148
150
|
|
|
151
|
+
column-gap: 8px;
|
|
149
152
|
min-width: var(--md-sys-target-size);
|
|
150
153
|
height: var(--md-sys-target-size);
|
|
151
154
|
padding-inline: 16px;
|
|
@@ -183,8 +186,6 @@ button.micl-button-outlined-s {
|
|
|
183
186
|
.micl-button__icon {
|
|
184
187
|
font-size: 20px;
|
|
185
188
|
width: 20px;
|
|
186
|
-
margin-right: 8px;
|
|
187
|
-
vertical-align: text-bottom;
|
|
188
189
|
}
|
|
189
190
|
}
|
|
190
191
|
|
|
@@ -195,6 +196,7 @@ button.micl-button-tonal-m,
|
|
|
195
196
|
button.micl-button-outlined-m {
|
|
196
197
|
@include typography.title-medium;
|
|
197
198
|
|
|
199
|
+
column-gap: 8px;
|
|
198
200
|
min-width: 56px;
|
|
199
201
|
height: 56px;
|
|
200
202
|
padding-inline: 24px;
|
|
@@ -218,8 +220,6 @@ button.micl-button-outlined-m {
|
|
|
218
220
|
.micl-button__icon {
|
|
219
221
|
font-size: 24px;
|
|
220
222
|
width: 24px;
|
|
221
|
-
margin-right: 8px;
|
|
222
|
-
vertical-align: text-bottom;
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|
|
@@ -230,6 +230,7 @@ button.micl-button-tonal-l,
|
|
|
230
230
|
button.micl-button-outlined-l {
|
|
231
231
|
@include typography.headline-small;
|
|
232
232
|
|
|
233
|
+
column-gap: 12px;
|
|
233
234
|
min-width: 96px;
|
|
234
235
|
height: 96px;
|
|
235
236
|
padding-inline: 48px;
|
|
@@ -253,8 +254,6 @@ button.micl-button-outlined-l {
|
|
|
253
254
|
.micl-button__icon {
|
|
254
255
|
font-size: 32px;
|
|
255
256
|
width: 32px;
|
|
256
|
-
margin-right: 12px;
|
|
257
|
-
vertical-align: text-bottom;
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
|
|
@@ -265,6 +264,7 @@ button.micl-button-tonal-xl,
|
|
|
265
264
|
button.micl-button-outlined-xl {
|
|
266
265
|
@include typography.headline-large;
|
|
267
266
|
|
|
267
|
+
column-gap: 16px;
|
|
268
268
|
min-width: 136px;
|
|
269
269
|
height: 136px;
|
|
270
270
|
padding-inline: 64px;
|
|
@@ -288,8 +288,6 @@ button.micl-button-outlined-xl {
|
|
|
288
288
|
.micl-button__icon {
|
|
289
289
|
font-size: 40px;
|
|
290
290
|
width: 40px;
|
|
291
|
-
margin-right: 16px;
|
|
292
|
-
vertical-align: text-bottom;
|
|
293
291
|
}
|
|
294
292
|
}
|
|
295
293
|
|
|
@@ -37,7 +37,12 @@ export default (() =>
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (event.target.classList.contains('micl-button--toggle')) {
|
|
40
|
+
event.target.classList.add('micl-button--toggled');
|
|
40
41
|
event.target.classList.toggle('micl-button--selected');
|
|
42
|
+
if (!!event.target.dataset.miclalt) {
|
|
43
|
+
[event.target.textContent, event.target.dataset.miclalt] =
|
|
44
|
+
[event.target.dataset.miclalt, event.target.textContent];
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
};
|
|
43
48
|
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
interpolate-size: allow-keywords;
|
|
44
44
|
|
|
45
45
|
&[tabindex='0']:not(.micl-card--disabled) {
|
|
46
|
-
--
|
|
46
|
+
--micl-ripple: 1;
|
|
47
47
|
--statelayer-color: var(--md-sys-color-on-surface);
|
|
48
48
|
|
|
49
49
|
background-image:
|
|
50
|
-
radial-gradient(circle at var(--x, center) var(--y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
50
|
+
radial-gradient(circle at var(--micl-x, center) var(--micl-y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
51
51
|
linear-gradient(rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)));
|
|
52
52
|
background-repeat: no-repeat;
|
|
53
53
|
background-size: 10000%, 100%;
|
|
@@ -47,14 +47,14 @@ button.micl-iconbutton-outlined-xl {
|
|
|
47
47
|
--md-sys-iconbutton-motion-effects: #{motion.$md-sys-motion-expressive-fast-spatial};
|
|
48
48
|
--md-sys-iconbutton-motion-duration: #{motion.$md-sys-motion-expressive-fast-spatial-duration};
|
|
49
49
|
--md-sys-iconbutton-motion-duration-reverse: #{motion.$md-sys-motion-expressive-fast-spatial-duration};
|
|
50
|
-
--
|
|
50
|
+
--micl-ripple: 1;
|
|
51
51
|
|
|
52
52
|
padding: 0;
|
|
53
53
|
border: none;
|
|
54
54
|
border-radius: var(--md-sys-shape-corner-full);
|
|
55
55
|
background-color: transparent;
|
|
56
56
|
background-image:
|
|
57
|
-
radial-gradient(circle at var(--x, center) var(--y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
57
|
+
radial-gradient(circle at var(--micl-x, center) var(--micl-y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
58
58
|
linear-gradient(rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)));
|
|
59
59
|
background-repeat: no-repeat;
|
|
60
60
|
background-size: 10000%, 100%;
|
|
@@ -37,7 +37,12 @@ export default (() =>
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (event.target.classList.contains('micl-button--toggle')) {
|
|
40
|
+
event.target.classList.add('micl-button--toggled');
|
|
40
41
|
event.target.classList.toggle('micl-button--selected');
|
|
42
|
+
if (!!event.target.dataset.miclalt) {
|
|
43
|
+
[event.target.textContent, event.target.dataset.miclalt] =
|
|
44
|
+
[event.target.dataset.miclalt, event.target.textContent];
|
|
45
|
+
}
|
|
41
46
|
}
|
|
42
47
|
};
|
|
43
48
|
|
|
@@ -107,7 +107,7 @@
|
|
|
107
107
|
border-radius: var(--md-sys-shape-corner-none);
|
|
108
108
|
background-color: var(--md-sys-list-item-container-color);
|
|
109
109
|
background-image:
|
|
110
|
-
radial-gradient(circle at var(--x, center) var(--y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
110
|
+
radial-gradient(circle at var(--micl-x, center) var(--micl-y, center), transparent 0%, rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)) 10%, transparent 10%),
|
|
111
111
|
linear-gradient(rgb(from var(--statelayer-color) r g b / var(--statelayer-opacity)));
|
|
112
112
|
background-repeat: no-repeat;
|
|
113
113
|
background-size: 10000%, 100%;
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
--statelayer-opacity var(--md-sys-list-motion-duration) linear;
|
|
118
118
|
|
|
119
119
|
&:not(:has(> button)) {
|
|
120
|
-
--
|
|
120
|
+
--micl-ripple: 1;
|
|
121
121
|
}
|
|
122
122
|
&> a,
|
|
123
123
|
&> button,
|
|
@@ -1,98 +1,149 @@
|
|
|
1
|
-
#
|
|
2
|
-
This component implements the the [Material Design 3 Expressive
|
|
1
|
+
# Navigation rail
|
|
2
|
+
This component implements the the [Material Design 3 Expressive Navigation rail](https://m3.material.io/components/navigation-rail/overview) design.
|
|
3
3
|
|
|
4
4
|
## Basic Usage
|
|
5
5
|
|
|
6
6
|
### HTML
|
|
7
|
-
To create a
|
|
7
|
+
To create a simple navigation rail, use a `<div>` element with the `micl-navigationrail` class. Inside, use an `input type="radio"` group to create the selectable navigation items. The `input` elements must share the same `name` attribute to ensure that only one item can be selected at a time. The `label` elements are associated with their respective inputs using the `for` attribute.
|
|
8
8
|
|
|
9
9
|
```HTML
|
|
10
|
-
<
|
|
11
|
-
<div class="micl-
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
class="micl-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
<div id="mynavigationrail" class="micl-navigationrail">
|
|
11
|
+
<div class="micl-navigationrail__content">
|
|
12
|
+
<input type="radio" id="item1" name="navitem" value="email_inbox" checked>
|
|
13
|
+
<label for="item1" class="micl-navigationrail__item" tabindex="0">
|
|
14
|
+
<span class="micl-navigationrail__icon material-symbols-outlined" aria-hidden="true">inbox</span>
|
|
15
|
+
<span class="micl-navigationrail__text">Inbox</span>
|
|
16
|
+
</label>
|
|
17
|
+
<input type="radio" id="item2" name="navitem" value="email_outbox">
|
|
18
|
+
<label for="item2" class="micl-navigationrail__item" tabindex="0">
|
|
19
|
+
<span class="micl-navigationrail__icon material-symbols-outlined" aria-hidden="true">outbox</span>
|
|
20
|
+
<span class="micl-navigationrail__text">Outbox</span>
|
|
21
|
+
</label>
|
|
22
22
|
</div>
|
|
23
|
-
</
|
|
23
|
+
</div>
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
### CSS
|
|
27
|
-
Import the
|
|
27
|
+
Import the navigation rail styles into your project:
|
|
28
28
|
|
|
29
29
|
```CSS
|
|
30
|
-
@use "material-inspired-component-library/dist/
|
|
30
|
+
@use "material-inspired-component-library/dist/navigationrail";
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### JavaScript
|
|
34
|
-
|
|
34
|
+
This component requires JavaScript to support keyboard navigation. The library will automatically initialize new components as they're added to the DOM.
|
|
35
|
+
|
|
36
|
+
```JavaScript
|
|
37
|
+
import micl from "material-inspired-component-library/dist/micl";
|
|
38
|
+
```
|
|
35
39
|
|
|
36
40
|
### Demo
|
|
37
|
-
A live example of the [
|
|
41
|
+
A live example of the [Navigation rail component](https://henkpb.github.io/micl/navigationrail.html) is available for you to interact with.
|
|
38
42
|
|
|
39
43
|
## Variants
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
To create a modal side sheet, use the `<dialog>` element without the `popover` attribute. Use `closedby="closerequest"` to prevent the side sheet from being dismissed by clicking outside of it. You'll also need a button or other control with popovertarget to close it.
|
|
44
|
+
The basic example creates a **collapsed** navigation rail. Add a menu button to allow the user to toggle between a **collapsed** and an **expanded** view.
|
|
43
45
|
|
|
44
46
|
```HTML
|
|
45
|
-
<
|
|
46
|
-
<div class="micl-
|
|
47
|
+
<div id="mynavigationrail" class="micl-navigationrail">
|
|
48
|
+
<div class="micl-navigationrail__headline">
|
|
47
49
|
<button
|
|
48
50
|
type="button"
|
|
49
|
-
class="micl-iconbutton-s material-symbols-outlined"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined"
|
|
52
|
+
data-miclalt="menu_open"
|
|
53
|
+
aria-label="Toggle navigation rail"
|
|
54
|
+
>menu</button>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="micl-navigationrail__content">
|
|
57
|
+
...
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
When the user clicks the menu button, the navigation rail is expanded and the toggle button is given the `micl-button--selected` class and the `micl-button--toggled` class that indicates that the toggle button has been clicked at least once.
|
|
63
|
+
|
|
64
|
+
### Popover expanded navigation rail
|
|
65
|
+
|
|
66
|
+
Add the `popover` attribute to the navigation rail, and the `popovertarget` attribute to the menu button. The value of the `popovertarget` attribute must be the `id` of the navigation rail.
|
|
67
|
+
|
|
68
|
+
```HTML
|
|
69
|
+
<div id="mynavigationrail" class="micl-navigationrail" popover="manual">
|
|
70
|
+
<div class="micl-navigationrail__headline">
|
|
53
71
|
<button
|
|
54
72
|
type="button"
|
|
55
|
-
class="micl-iconbutton-s material-symbols-outlined"
|
|
56
|
-
popovertarget="
|
|
57
|
-
|
|
58
|
-
|
|
73
|
+
class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined"
|
|
74
|
+
popovertarget="mynavigationrail"
|
|
75
|
+
data-miclalt="menu_open"
|
|
76
|
+
aria-label="Toggle navigation rail"
|
|
77
|
+
>menu</button>
|
|
59
78
|
</div>
|
|
60
|
-
<div class="micl-
|
|
61
|
-
...
|
|
79
|
+
<div class="micl-navigationrail__content">
|
|
80
|
+
...
|
|
62
81
|
</div>
|
|
63
|
-
|
|
64
|
-
<button type="button" class="micl-button">Save</button>
|
|
65
|
-
</div>
|
|
66
|
-
</dialog>
|
|
82
|
+
</div>
|
|
67
83
|
```
|
|
68
84
|
|
|
69
|
-
|
|
85
|
+
[!WARNING]
|
|
86
|
+
The **popover** navigation rail component adds CSS rules to the `<body>` element to properly resize the main content area when the navigation rail is collapsed. Overriding these rules may cause the component to behave unexpectedly. The rules that are applied are:
|
|
87
|
+
|
|
88
|
+
```CSS
|
|
89
|
+
margin-inline-start: var(--md-sys-navigationrail-collapsed-width);
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Modal navigation rail
|
|
93
|
+
|
|
94
|
+
A **modal** navigation rail is hidden until the user clicks a menu button. When shown, the **expanded** navigation rail is displayed on top of other page content. Use a `<dialog>` element instead of a `<div>`.
|
|
95
|
+
|
|
70
96
|
```HTML
|
|
71
|
-
<
|
|
72
|
-
|
|
97
|
+
<dialog id="mynavigationrail" class="micl-navigationrail" closedby="closerequest">
|
|
98
|
+
<div class="micl-navigationrail__headline">
|
|
99
|
+
<button
|
|
100
|
+
type="button"
|
|
101
|
+
class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined"
|
|
102
|
+
popovertarget="mynavigationrail"
|
|
103
|
+
data-miclalt="menu_open"
|
|
104
|
+
aria-label="Toggle navigation rail"
|
|
105
|
+
>menu</button>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="micl-navigationrail__content">
|
|
108
|
+
...
|
|
109
|
+
</div>
|
|
110
|
+
</dialog>
|
|
73
111
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
112
|
+
<button
|
|
113
|
+
type="button"
|
|
114
|
+
class="micl-iconbutton-standard-s micl-button--toggle material-symbols-outlined"
|
|
115
|
+
popovertarget="mynavigationrail"
|
|
116
|
+
aria-label="Toggle navigation rail"
|
|
117
|
+
>menu</button>
|
|
79
118
|
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
119
|
+
|
|
120
|
+
The button inside the navigation rail is used to hide the navigation rail, while the button outside is responsible for opening it.
|
|
121
|
+
|
|
122
|
+
## Customizations
|
|
123
|
+
You can customize the appearance of the Navigation rail component by overriding its global CSS variables. These variables are declared on the `:root` pseudo-class and can be changed on any appropriate parent element to affect its child navigation rails.
|
|
124
|
+
|
|
125
|
+
| Variable name | Default Value | Description |
|
|
126
|
+
| ------------- | ------------- | ----------- |
|
|
127
|
+
| --md-sys-navigationrail-collapsed-width | 96px | The width of the collapsed navigation rail |
|
|
128
|
+
| --md-sys-navigationrail-expanded-maxwidth | 360px | The largest allowed width of the expanded navigation rail |
|
|
129
|
+
| --md-sys-navigationrail-expanded-minwidth | 220px | The smallest allowed width of the expanded navigation rail |
|
|
130
|
+
|
|
131
|
+
**Example: Changing the width of the collapsed navigation rail**
|
|
132
|
+
|
|
133
|
+
```HTML
|
|
134
|
+
<div style="--md-sys-navigationrail-collapsed-width:80px">
|
|
135
|
+
<div id="mynavigationrail" class="micl-navigationrail">
|
|
136
|
+
...
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
85
139
|
```
|
|
86
140
|
|
|
87
|
-
|
|
88
|
-
The **standard** side sheet component adds CSS rules to the `<body>` element to properly resize the main content area when the side sheet is open. Overriding these rules may cause the component to behave unexpectedly. The rules that are applied are:
|
|
141
|
+
To add a vertical divider of the to the navigation rail, assign one to the following CSS variable:
|
|
89
142
|
|
|
90
143
|
```CSS
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
max-width: ...varies depending on if the side sheet is opened...
|
|
95
|
-
transition: ...transition on max-width...
|
|
144
|
+
#mynavigationrail {
|
|
145
|
+
--md-sys-divider-thickness: 1;
|
|
146
|
+
}
|
|
96
147
|
```
|
|
97
148
|
|
|
98
149
|
## Compatibility
|