material-inspired-component-library 3.0.1 → 3.1.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 -14
- package/components/alert/index.scss +120 -0
- package/components/appbar/index.scss +2 -2
- package/components/badge/index.scss +22 -7
- package/components/button/index.scss +2 -2
- package/components/card/README.md +9 -5
- package/components/card/index.scss +49 -22
- package/components/checkbox/README.md +49 -11
- package/components/checkbox/index.scss +145 -182
- package/components/checkbox/index.ts +148 -0
- package/components/dialog/index.scss +3 -3
- package/components/divider/README.md +3 -3
- package/components/divider/index.scss +18 -27
- package/components/iconbutton/index.scss +2 -2
- package/components/list/index.scss +2 -2
- package/components/list/index.ts +2 -3
- package/components/menu/index.ts +2 -2
- package/components/navigationrail/index.scss +5 -3
- package/components/radio/README.md +1 -1
- package/components/radio/index.scss +6 -24
- package/components/select/index.scss +5 -2
- package/components/slider/index.scss +4 -4
- package/components/slider/index.ts +9 -10
- package/components/stepper/index.scss +85 -0
- package/components/stepper/index.ts +226 -0
- package/components/switch/README.md +26 -4
- package/components/switch/index.scss +24 -23
- package/components/textfield/index.scss +1 -0
- package/components/textfield/index.ts +56 -23
- package/dist/alert.css +1 -0
- package/dist/alert.js +1 -0
- package/dist/appbar.css +1 -1
- package/dist/badge.css +1 -1
- package/dist/button.css +1 -1
- package/dist/card.css +1 -1
- package/dist/checkbox.css +1 -1
- package/dist/components/checkbox/index.d.ts +5 -0
- package/dist/components/stepper/index.d.ts +5 -0
- package/dist/components/textfield/index.d.ts +2 -1
- package/dist/dialog.css +1 -1
- package/dist/divider.css +1 -1
- package/dist/iconbutton.css +1 -1
- package/dist/layout.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/dist/select.css +1 -1
- package/dist/slider.css +1 -1
- package/dist/stepper.css +1 -0
- package/dist/stepper.js +1 -0
- package/dist/switch.css +1 -1
- package/dist/textfield.css +1 -1
- package/docs/alert.html +181 -0
- package/docs/card.html +25 -7
- package/docs/checkbox.html +31 -7
- package/docs/divider.html +7 -1
- package/docs/index.html +9 -10
- package/docs/micl.css +1 -1
- package/docs/micl.js +1 -1
- package/docs/navigationrail.html +2 -3
- package/docs/radio.html +1 -1
- package/docs/switch.html +41 -26
- package/layout/index.scss +9 -2
- package/micl.ts +24 -26
- package/package.json +2 -1
- package/styles.scss +2 -0
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ Copy the main `micl.js` file to your distribution folder and include it in your
|
|
|
76
76
|
```
|
|
77
77
|
This will initialize all MICL components, including those that will be added to the DOM later on.
|
|
78
78
|
|
|
79
|
-
## Foundations
|
|
79
|
+
## Foundations 🪟
|
|
80
80
|
A separate CSS file, based on the [Material Design Layout Foundation](https://m3.material.io/foundations/layout/understanding-layout/overview), provides styles for an adaptive layout. It includes styles for the **window frame**, **body region** and **panes** that adjust to the available screen space, ensuring your layout follows Material Design's responsive guidelines.
|
|
81
81
|
|
|
82
82
|
- [x] [Layout](layout/README.md)
|
|
@@ -84,6 +84,7 @@ A separate CSS file, based on the [Material Design Layout Foundation](https://m3
|
|
|
84
84
|
## Available components ✅
|
|
85
85
|
The library currently consists of the following components:
|
|
86
86
|
- [x] [Accordion](components/accordion/README.md)
|
|
87
|
+
- [ ] [Alert](README.md)
|
|
87
88
|
- [x] [App Bar](components/appbar/README.md)
|
|
88
89
|
- [x] [Badge](components/badge/README.md)
|
|
89
90
|
- [x] [Bottom sheet](components/bottomsheet/README.md)
|
|
@@ -100,39 +101,33 @@ The library currently consists of the following components:
|
|
|
100
101
|
- [x] [Select](components/select/README.md)
|
|
101
102
|
- [x] [Side sheet](components/sidesheet/README.md)
|
|
102
103
|
- [x] [Slider](components/slider/README.md)
|
|
104
|
+
- [ ] [Stepper](README.md)
|
|
103
105
|
- [x] [Switch](components/switch/README.md)
|
|
104
106
|
- [x] [Text field](components/textfield/README.md)
|
|
105
107
|
|
|
106
|
-
## Change Log
|
|
108
|
+
## Change Log ↪️
|
|
107
109
|
|
|
108
|
-
### 3.
|
|
109
|
-
**
|
|
110
|
+
### 3.1.0 (19.10.2025)
|
|
111
|
+
- **Checkbox**: Refactoring + add support for checkbox groups.
|
|
110
112
|
|
|
113
|
+
### 3.0.0 (24.09.2025)
|
|
114
|
+
- **BREAKING:** Use `<nav>` instead of `<div>` for Navigation rail.
|
|
111
115
|
- **App Bar**: New component.
|
|
112
116
|
- **Layout**: Support for adaptive layout.
|
|
113
|
-
- Improved handling of target area for small buttons.
|
|
114
|
-
- **BREAKING:** Use `<nav>` instead of `<div>` for Navigation rail.
|
|
117
|
+
- **Buttons**: Improved handling of target area for small buttons.
|
|
115
118
|
|
|
116
119
|
### 2.0.0 (04.09.2025)
|
|
117
|
-
**Features**
|
|
118
|
-
|
|
119
120
|
- **Navigation rail**: New component.
|
|
120
121
|
- **Badge**: New component.
|
|
121
122
|
- **Ripple**: Now uses custom CSS properties.
|
|
122
123
|
|
|
123
124
|
### 1.3.0 (23.08.2025)
|
|
124
|
-
**Features**
|
|
125
|
-
|
|
126
125
|
- **Menu**: Added support for submenus.
|
|
127
126
|
- **Ripple**: The ripple-effect does not use a pseudo-element anymore.
|
|
128
127
|
- **State layer**: Rewrite for simpler styling.
|
|
129
128
|
|
|
130
129
|
### 1.2.0 (17.08.2025)
|
|
131
|
-
**Features**
|
|
132
|
-
|
|
133
130
|
- **List**: Added support for switches inside list items.
|
|
134
131
|
|
|
135
132
|
### 1.1.0 (12.08.2025)
|
|
136
|
-
**Features**
|
|
137
|
-
|
|
138
133
|
- **Text field**: Added support for multi-line text fields.
|
|
@@ -0,0 +1,120 @@
|
|
|
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/shapes';
|
|
23
|
+
@use '../../styles/typography';
|
|
24
|
+
|
|
25
|
+
:root {
|
|
26
|
+
--md-sys-alert-padding: 16px;
|
|
27
|
+
--md-sys-alert-space: 16px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.micl-alert-filled,
|
|
31
|
+
.micl-alert-tonal,
|
|
32
|
+
.micl-alert-outlined {
|
|
33
|
+
--md-sys-alert-background-color: inherit;
|
|
34
|
+
--md-sys-alert-color: inherit;
|
|
35
|
+
|
|
36
|
+
box-sizing: border-box;
|
|
37
|
+
display: flex;
|
|
38
|
+
inline-size: 100%;
|
|
39
|
+
padding: var(--md-sys-alert-padding, 16px);
|
|
40
|
+
column-gap: var(--md-sys-alert-space, 8px);
|
|
41
|
+
border: none;
|
|
42
|
+
outline: none;
|
|
43
|
+
border-radius: var(--md-sys-shape-corner-small, 8px);
|
|
44
|
+
background-color: var(--md-sys-alert-background-color);
|
|
45
|
+
color: var(--md-sys-alert-color);
|
|
46
|
+
|
|
47
|
+
.micl-alert__icon {
|
|
48
|
+
block-size: var(--md-sys-layout-icon-size, 24px);
|
|
49
|
+
inline-size: var(--md-sys-layout-icon-size, 24px);
|
|
50
|
+
font-size: var(--md-sys-layout-icon-size, 24px);
|
|
51
|
+
}
|
|
52
|
+
.micl-alert__text {
|
|
53
|
+
display: flex;
|
|
54
|
+
flex-direction: column;
|
|
55
|
+
row-gap: 8px;
|
|
56
|
+
|
|
57
|
+
h1, h2, h3, h4, h5, h6, .micl-heading {
|
|
58
|
+
@include typography.title-medium;
|
|
59
|
+
|
|
60
|
+
margin: 0;
|
|
61
|
+
}
|
|
62
|
+
.micl-alert__supporting-text {
|
|
63
|
+
@include typography.body-medium;
|
|
64
|
+
|
|
65
|
+
margin: 0;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.micl-alert-filled {
|
|
71
|
+
--md-sys-alert-background-color: var(--md-sys-color-error);
|
|
72
|
+
--md-sys-alert-color: var(--md-sys-color-on-error);
|
|
73
|
+
|
|
74
|
+
&.micl-alert--primary {
|
|
75
|
+
--md-sys-alert-background-color: var(--md-sys-color-primary);
|
|
76
|
+
--md-sys-alert-color: var(--md-sys-color-on-primary);
|
|
77
|
+
}
|
|
78
|
+
&.micl-alert--secondary {
|
|
79
|
+
--md-sys-alert-background-color: var(--md-sys-color-secondary);
|
|
80
|
+
--md-sys-alert-color: var(--md-sys-color-on-secondary);
|
|
81
|
+
}
|
|
82
|
+
&.micl-alert--tertiary {
|
|
83
|
+
--md-sys-alert-background-color: var(--md-sys-color-tertiary);
|
|
84
|
+
--md-sys-alert-color: var(--md-sys-color-on-tertiary);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.micl-alert-tonal {
|
|
89
|
+
--md-sys-alert-background-color: var(--md-sys-color-error-container);
|
|
90
|
+
--md-sys-alert-color: var(--md-sys-color-on-error-container);
|
|
91
|
+
|
|
92
|
+
&.micl-alert--primary {
|
|
93
|
+
--md-sys-alert-background-color: var(--md-sys-color-primary-container);
|
|
94
|
+
--md-sys-alert-color: var(--md-sys-color-on-primary-container);
|
|
95
|
+
}
|
|
96
|
+
&.micl-alert--secondary {
|
|
97
|
+
--md-sys-alert-background-color: var(--md-sys-color-secondary-container);
|
|
98
|
+
--md-sys-alert-color: var(--md-sys-color-on-secondary-container);
|
|
99
|
+
}
|
|
100
|
+
&.micl-alert--tertiary {
|
|
101
|
+
--md-sys-alert-background-color: var(--md-sys-color-tertiary-container);
|
|
102
|
+
--md-sys-alert-color: var(--md-sys-color-on-tertiary-container);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.micl-alert-outlined {
|
|
107
|
+
--md-sys-alert-color: var(--md-sys-color-error);
|
|
108
|
+
|
|
109
|
+
border: 1px solid var(--md-sys-alert-color);
|
|
110
|
+
|
|
111
|
+
&.micl-alert--primary {
|
|
112
|
+
--md-sys-alert-color: var(--md-sys-color-primary);
|
|
113
|
+
}
|
|
114
|
+
&.micl-alert--secondary {
|
|
115
|
+
--md-sys-alert-color: var(--md-sys-color-secondary);
|
|
116
|
+
}
|
|
117
|
+
&.micl-alert--tertiary {
|
|
118
|
+
--md-sys-alert-color: var(--md-sys-color-tertiary);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
.micl-appbar__leading-icon {
|
|
68
68
|
grid-area: appbar-leading;
|
|
69
|
-
margin-inline-start: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (24px / 2) - var(--md-sys-appbar-padding-inline));
|
|
69
|
+
margin-inline-start: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (var(--md-sys-layout-icon-size, 24px) / 2) - var(--md-sys-appbar-padding-inline));
|
|
70
70
|
color: var(--md-sys-color-on-surface);
|
|
71
71
|
}
|
|
72
72
|
.micl-appbar__headline {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
}
|
|
104
104
|
.micl-appbar__trailing-icon {
|
|
105
105
|
grid-area: appbar-trailing;
|
|
106
|
-
margin-inline-end: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (24px / 2) - var(--md-sys-appbar-padding-inline));
|
|
106
|
+
margin-inline-end: calc(var(--md-sys-layout-window-margin) - (var(--micl-width, statelayer.$md-sys-target-size) / 2) + (var(--md-sys-layout-icon-size, 24px) / 2) - var(--md-sys-appbar-padding-inline));
|
|
107
107
|
color: var(--md-sys-color-on-surface-variant);
|
|
108
108
|
}
|
|
109
109
|
&.micl-appbar--medium {
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
--md-sys-badge-small-size: 6px;
|
|
26
26
|
--md-sys-badge-large-size: 16px;
|
|
27
27
|
--md-sys-badge-large-padding: 4px;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.micl-badge {
|
|
31
28
|
--md-sys-badge-inline-offset: 0px;
|
|
32
29
|
--md-sys-badge-block-offset: 0px;
|
|
30
|
+
}
|
|
33
31
|
|
|
32
|
+
.micl-badge {
|
|
34
33
|
box-sizing: border-box;
|
|
35
34
|
position: fixed;
|
|
36
|
-
inset:
|
|
35
|
+
inset: 0;
|
|
37
36
|
margin: 0;
|
|
37
|
+
overflow-x: hidden;
|
|
38
38
|
background-color: var(--md-sys-color-error);
|
|
39
39
|
color: var(--md-sys-color-on-error);
|
|
40
40
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
inline-size: var(--md-sys-badge-small-size);
|
|
43
43
|
block-size: var(--md-sys-badge-small-size);
|
|
44
44
|
inset-block-start: calc(anchor(start) + var(--md-sys-badge-block-offset));
|
|
45
|
-
inset-inline-start: calc(anchor(end) - var(--md-sys-badge-small-size)
|
|
45
|
+
inset-inline-start: calc(anchor(end) - var(--md-sys-badge-small-size) + var(--md-sys-badge-inline-offset));
|
|
46
46
|
padding: 0;
|
|
47
47
|
border-radius: calc(var(--md-sys-badge-small-size) / 2);
|
|
48
48
|
}
|
|
@@ -53,9 +53,24 @@
|
|
|
53
53
|
max-inline-size: 34px;
|
|
54
54
|
min-inline-size: var(--md-sys-badge-large-size);
|
|
55
55
|
block-size: var(--md-sys-badge-large-size);
|
|
56
|
-
inset-block-start: calc(anchor(start) -
|
|
57
|
-
inset-inline-start: calc(anchor(end) - 12px
|
|
56
|
+
inset-block-start: calc(anchor(start) - (var(--md-sys-badge-large-size) - 14px) + var(--md-sys-badge-block-offset));
|
|
57
|
+
inset-inline-start: calc(anchor(end) - 12px + var(--md-sys-badge-inline-offset));
|
|
58
58
|
padding-inline: var(--md-sys-badge-large-padding);
|
|
59
59
|
border-radius: calc(var(--md-sys-badge-large-size) / 2);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
@supports not (top: anchor(bottom)) {
|
|
64
|
+
.micl-badge {
|
|
65
|
+
position: absolute;
|
|
66
|
+
inset: 0 !important;
|
|
67
|
+
margin-block: calc(12px + var(--md-sys-badge-block-offset)) auto;
|
|
68
|
+
|
|
69
|
+
&.micl-badge--small {
|
|
70
|
+
margin-inline-start: calc(var(--md-sys-layout-icon-size) - var(--md-sys-badge-small-size) - var(--md-sys-badge-inline-offset));
|
|
71
|
+
}
|
|
72
|
+
&:not(.micl-badge--small) {
|
|
73
|
+
margin-inline-start: calc(12px - var(--md-sys-badge-inline-offset));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Card
|
|
2
|
-
This component implements the the [Material Design 3 Expressive Card](https://m3.material.io/components/cards/overview) design.
|
|
2
|
+
This component implements the the [Material Design 3 Expressive Card](https://m3.material.io/components/cards/overview) design. Cards display content and actions about a single subject.
|
|
3
3
|
|
|
4
4
|
## Basic Usage
|
|
5
5
|
|
|
@@ -40,7 +40,6 @@ Cards come in **three distinct styles**:
|
|
|
40
40
|
- `micl-card-outlined`: A card with a clear border, often used for less prominent content or to indicate interactivity.
|
|
41
41
|
|
|
42
42
|
### Card Content Structure
|
|
43
|
-
|
|
44
43
|
While the card container is the only required element, the Card component provides several optional utility classes to help structure your card's content:
|
|
45
44
|
```HTML
|
|
46
45
|
<div class="micl-card-outlined" tabindex="0">
|
|
@@ -64,7 +63,7 @@ While the card container is the only required element, the Card component provid
|
|
|
64
63
|
- `micl-card__headline-m` (medium) - *Used in the example above*
|
|
65
64
|
- `micl-card__headline-l` (large)
|
|
66
65
|
|
|
67
|
-
- `micl-card__image`: Applies styling to an `<img>` element used as the primary image for the card.
|
|
66
|
+
- `micl-card__image`: Applies styling to an `<img>` element or an element with a `background-image` style used as the primary image for the card.
|
|
68
67
|
|
|
69
68
|
- `micl-card__subhead`: For secondary headings, displayed with a smaller font than the main headline.
|
|
70
69
|
|
|
@@ -93,18 +92,23 @@ Cards can also serve as containers for expandable detail areas using the `<detai
|
|
|
93
92
|
</details>
|
|
94
93
|
```
|
|
95
94
|
|
|
95
|
+
### Compact Cards
|
|
96
|
+
Add the `micl-card--compact` to the main `<div>` element (or, the `<summary>` element for expandable cards) to create a compact version of the card header.
|
|
97
|
+
|
|
96
98
|
### States
|
|
97
99
|
- **Disabled Cards**: To visually indicate a disabled card (e.g., non-interactive), add the `micl-card--disabled` class to the card container.
|
|
98
100
|
|
|
99
101
|
- **Dragging State**: When implementing drag-and-drop functionality for cards, apply the `micl-card--dragging` class to the card container to provide visual feedback during the drag operation.
|
|
100
102
|
|
|
101
103
|
## Customizations
|
|
102
|
-
You can customize the appearance of the Card 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
|
|
104
|
+
You can customize the appearance of the Card 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 cards.
|
|
103
105
|
|
|
104
106
|
| Variable name | Default Value | Description |
|
|
105
107
|
| ------------- | ----- | ----------- |
|
|
106
108
|
| --md-sys-card-margin | 8px | Sets the spacing between adjacent cards both horizontally and vertically |
|
|
107
109
|
| --md-sys-card-padding-inline | 16px | Defines the amount of space between the left and right edges of a card and its content |
|
|
110
|
+
| --md-sys-card-content-padding-block | 16px | The amount of vertical padding reserved for the content area |
|
|
111
|
+
| --md-sys-card-outlined-border-width | 1px | The width of the border of **outlined** cards |
|
|
108
112
|
|
|
109
113
|
**Example: Changing the card margins**
|
|
110
114
|
|
|
@@ -120,6 +124,6 @@ You can customize the appearance of the Card component by overriding its global
|
|
|
120
124
|
```
|
|
121
125
|
|
|
122
126
|
## Compatibility
|
|
123
|
-
This component
|
|
127
|
+
This component utilizes relative RGB color values, which may not be fully supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#browser_compatibility) for details.
|
|
124
128
|
|
|
125
129
|
The Card component uses the `interpolate-size` CSS property to smoothly open and close the detail area of a Details disclosure element, which might not be supported in your browser. Please check [Browser compatibility](https://developer.mozilla.org/en-US/docs/Web/CSS/interpolate-size#browser_compatibility) for details.
|
|
@@ -28,6 +28,8 @@
|
|
|
28
28
|
:root {
|
|
29
29
|
--md-sys-card-margin: 8px;
|
|
30
30
|
--md-sys-card-padding-inline: 16px;
|
|
31
|
+
--md-sys-card-content-padding-block: 16px;
|
|
32
|
+
--md-sys-card-outlined-border-width: 1px;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
.micl-card-elevated,
|
|
@@ -36,9 +38,12 @@
|
|
|
36
38
|
--md-sys-card-motion-spatial: #{motion.$md-sys-motion-expressive-default-spatial};
|
|
37
39
|
--md-sys-card-motion-duration: #{motion.$md-sys-motion-expressive-default-spatial-duration};
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
display: block;
|
|
42
|
+
block-size: fit-content;
|
|
40
43
|
margin: 0;
|
|
44
|
+
padding-block-end: var(--md-sys-card-content-padding-block);
|
|
41
45
|
border-radius: var(--md-sys-shape-corner-medium);
|
|
46
|
+
outline: none;
|
|
42
47
|
overflow: hidden;
|
|
43
48
|
interpolate-size: allow-keywords;
|
|
44
49
|
|
|
@@ -66,7 +71,6 @@
|
|
|
66
71
|
|
|
67
72
|
outline: var(--md-sys-state-focus-indicator-thickness) solid var(--md-sys-color-secondary);
|
|
68
73
|
outline-offset: var(--md-sys-state-focus-indicator-outer-offset);
|
|
69
|
-
box-shadow: var(--md-sys-elevation-level1);
|
|
70
74
|
}
|
|
71
75
|
&:active {
|
|
72
76
|
--statelayer-opacity: var(--md-sys-state-pressed-state-layer-opacity);
|
|
@@ -89,21 +93,23 @@
|
|
|
89
93
|
outline-offset: var(--md-sys-state-focus-indicator-outer-offset);
|
|
90
94
|
}
|
|
91
95
|
&::details-content {
|
|
92
|
-
|
|
96
|
+
block-size: 0;
|
|
93
97
|
overflow: hidden;
|
|
94
98
|
transition:
|
|
95
|
-
|
|
99
|
+
block-size var(--md-sys-card-motion-duration) var(--md-sys-card-motion-spatial),
|
|
96
100
|
content-visibility var(--md-sys-card-motion-duration) linear allow-discrete;
|
|
97
101
|
}
|
|
98
102
|
&[open]::details-content {
|
|
99
|
-
|
|
103
|
+
block-size: auto;
|
|
100
104
|
}
|
|
101
105
|
&> summary {
|
|
102
|
-
padding-block-end: 8px;
|
|
103
106
|
outline: none;
|
|
104
107
|
list-style: none;
|
|
105
108
|
cursor: pointer
|
|
106
109
|
}
|
|
110
|
+
&:not([open]):has(> summary.micl-card--compact) {
|
|
111
|
+
padding-block-end: 0;
|
|
112
|
+
}
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
.micl-card-elevated {
|
|
@@ -114,9 +120,6 @@
|
|
|
114
120
|
&:hover {
|
|
115
121
|
box-shadow: var(--md-sys-elevation-level2);
|
|
116
122
|
}
|
|
117
|
-
&:active {
|
|
118
|
-
box-shadow: var(--md-sys-elevation-level1);
|
|
119
|
-
}
|
|
120
123
|
&.micl-card--dragging {
|
|
121
124
|
box-shadow: var(--md-sys-elevation-level4);
|
|
122
125
|
}
|
|
@@ -125,29 +128,18 @@
|
|
|
125
128
|
.micl-card-filled {
|
|
126
129
|
background-color: var(--md-sys-color-surface-container-highest);
|
|
127
130
|
box-shadow: var(--md-sys-elevation-level0);
|
|
128
|
-
|
|
129
|
-
&[tabindex='0']:not(.micl-card--disabled) {
|
|
130
|
-
&:focus-visible {
|
|
131
|
-
box-shadow: var(--md-sys-elevation-level0);
|
|
132
|
-
}
|
|
133
|
-
&:active {
|
|
134
|
-
box-shadow: var(--md-sys-elevation-level0);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
131
|
}
|
|
138
132
|
.micl-card-outlined {
|
|
139
133
|
background-color: var(--md-sys-color-surface);
|
|
140
134
|
box-shadow: var(--md-sys-elevation-level0);
|
|
141
|
-
border:
|
|
135
|
+
border: var(--md-sys-card-outlined-border-width) solid var(--md-sys-color-outline-variant);
|
|
142
136
|
|
|
143
137
|
&[tabindex='0']:not(.micl-card--disabled) {
|
|
144
138
|
&:focus-visible {
|
|
145
139
|
border-color: var(--md-sys-color-on-surface);
|
|
146
|
-
box-shadow: var(--md-sys-elevation-level0);
|
|
147
140
|
}
|
|
148
141
|
&:active {
|
|
149
142
|
border-color: var(--md-sys-color-outline-variant);
|
|
150
|
-
box-shadow: var(--md-sys-elevation-level0);
|
|
151
143
|
}
|
|
152
144
|
}
|
|
153
145
|
}
|
|
@@ -167,10 +159,44 @@
|
|
|
167
159
|
border-color: rgb(from var(--md-sys-color-outline) r g b / 12%);
|
|
168
160
|
}
|
|
169
161
|
}
|
|
162
|
+
.micl-card--compact {
|
|
163
|
+
display: grid;
|
|
164
|
+
grid-template-areas:
|
|
165
|
+
"card-media card-headline"
|
|
166
|
+
"card-media card-subhead"
|
|
167
|
+
"card-media card-supporting"
|
|
168
|
+
"card-content card-content";
|
|
169
|
+
grid-template-columns: 20% 1fr;
|
|
170
|
+
|
|
171
|
+
.micl-card__image {
|
|
172
|
+
grid-area: card-media;
|
|
173
|
+
block-size: 100%;
|
|
174
|
+
object-fit: cover;
|
|
175
|
+
background-size: cover;
|
|
176
|
+
}
|
|
177
|
+
.micl-card__headline-s,
|
|
178
|
+
.micl-card__headline-m,
|
|
179
|
+
.micl-card__headline-l {
|
|
180
|
+
grid-area: card-headline;
|
|
181
|
+
}
|
|
182
|
+
.micl-card__subhead {
|
|
183
|
+
grid-area: card-subhead;
|
|
184
|
+
}
|
|
185
|
+
.micl-card__supporting-text {
|
|
186
|
+
grid-area: card-supporting;
|
|
187
|
+
}
|
|
188
|
+
.micl-card__content {
|
|
189
|
+
grid-area: card-content;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
170
192
|
|
|
171
193
|
.micl-card__image {
|
|
172
|
-
|
|
194
|
+
display: block;
|
|
195
|
+
inline-size: 100%;
|
|
173
196
|
border-radius: var(--md-sys-shape-corner-medium);
|
|
197
|
+
background-position: center;
|
|
198
|
+
background-repeat: no-repeat;
|
|
199
|
+
background-size: contain;
|
|
174
200
|
}
|
|
175
201
|
|
|
176
202
|
.micl-card__headline-s,
|
|
@@ -260,6 +286,7 @@
|
|
|
260
286
|
|
|
261
287
|
.micl-card__content {
|
|
262
288
|
box-sizing: border-box;
|
|
289
|
+
padding-block: var(--md-sys-card-content-padding-block) 0;
|
|
263
290
|
padding-inline: var(--md-sys-card-padding-inline);
|
|
264
291
|
background-color: inherit;
|
|
265
292
|
overflow: hidden;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Checkbox
|
|
2
|
-
This component implements the the [Material Design 3 Expressive Checkbox](https://m3.material.io/components/checkbox/overview) design.
|
|
2
|
+
This component implements the the [Material Design 3 Expressive Checkbox](https://m3.material.io/components/checkbox/overview) design. A checkbox allows a user to select one or more options from a number of choices.
|
|
3
3
|
|
|
4
4
|
## Basic Usage
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ This component implements the the [Material Design 3 Expressive Checkbox](https:
|
|
|
7
7
|
To add a basic checkbox, use the `<input type="checkbox">` element with the `micl-checkbox` class, paired with a `<label>` element:
|
|
8
8
|
|
|
9
9
|
```HTML
|
|
10
|
-
<input type="checkbox" id="mycheckbox" class="micl-checkbox"
|
|
10
|
+
<input type="checkbox" id="mycheckbox" class="micl-checkbox">
|
|
11
11
|
<label for="mycheckbox">Bar</label>
|
|
12
12
|
```
|
|
13
13
|
|
|
@@ -19,13 +19,11 @@ Import the checkbox styles into your project:
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
### JavaScript
|
|
22
|
-
This component requires JavaScript to support
|
|
22
|
+
This component requires JavaScript to support checkbox groups:
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
import micl from "material-inspired-component-library/dist/micl";
|
|
26
|
-
```
|
|
24
|
+
`import micl from "material-inspired-component-library/dist/micl";`
|
|
27
25
|
|
|
28
|
-
This will initialize any
|
|
26
|
+
This will initialize any checkbox group, including those that will be added to the DOM later on.
|
|
29
27
|
|
|
30
28
|
### Demo
|
|
31
29
|
A live example of the [Checkbox component](https://henkpb.github.io/micl/checkbox.html) is available for you to interact with.
|
|
@@ -37,20 +35,60 @@ A checkbox can be disabled by adding the `disabled` attribute to the `<input>` e
|
|
|
37
35
|
|
|
38
36
|
The Checkbox component respects the `dir` global attribute, automatically adjusting its layout for right-to-left (RTL) languages when `dir="rtl"` is applied to an ancestor element.
|
|
39
37
|
|
|
38
|
+
The component applies `cursor: pointer` and the color role **on surface** to the `<label>` element immediately preceding or following an `<input type="checkbox">` with the `micl-checkbox` class. You are encouraged to customize these CSS settings to match your design system.
|
|
39
|
+
|
|
40
|
+
## Checkbox group
|
|
41
|
+
You can establish a parent-child relationship among checkboxes. To do this, wrap the entire set of related checkboxes in an element using the `micl-checkbox-group` class. The designated parent checkbox must also include the `micl-checkbox__parent` class.
|
|
42
|
+
|
|
43
|
+
```HTML
|
|
44
|
+
<div class="micl-checkbox-group">
|
|
45
|
+
<input type="checkbox" id="cb0" class="micl-checkbox micl-checkbox__parent" value="c0">
|
|
46
|
+
<label for="cb0">Choices</label>
|
|
47
|
+
<input type="checkbox" id="cb1" class="micl-checkbox" value="c1">
|
|
48
|
+
<label for="cb1">First Choice</label>
|
|
49
|
+
<input type="checkbox" id="cb2" class="micl-checkbox" checked value="c2">
|
|
50
|
+
<label for="cb2">Second Choice</label>
|
|
51
|
+
...
|
|
52
|
+
</div>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To visually improve the layout, such as by indenting child checkboxes, use wrapper elements and utility classes:
|
|
56
|
+
|
|
57
|
+
```HTML
|
|
58
|
+
<div class="micl-checkbox-group">
|
|
59
|
+
<div class="micl-flex--vcenter">
|
|
60
|
+
<input type="checkbox" id="cb0" class="micl-checkbox micl-checkbox__parent" value="c0">
|
|
61
|
+
<label for="cb0">Choices</label>
|
|
62
|
+
</div>
|
|
63
|
+
<div style="padding-inline-start:16px">
|
|
64
|
+
<div class="micl-flex--vcenter">
|
|
65
|
+
<input type="checkbox" id="cb1" class="micl-checkbox" value="c1">
|
|
66
|
+
<label for="cb1">First Choice</label>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="micl-flex--vcenter">
|
|
69
|
+
<input type="checkbox" id="cb2" class="micl-checkbox" checked value="c2">
|
|
70
|
+
<label for="cb2">Second Choice</label>
|
|
71
|
+
</div>
|
|
72
|
+
...
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Note that checkbox groups support **nesting**, allowing a `micl-checkbox-group` to contain other `micl-checkbox-group` elements for multi-level hierarchies.
|
|
78
|
+
|
|
40
79
|
## Customizations
|
|
41
80
|
You can customize the appearance of the Checkbox 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 checkboxes.
|
|
42
81
|
|
|
43
82
|
| Variable name | Default Value | Description |
|
|
44
83
|
| ------------- | ------------- | ----------- |
|
|
45
84
|
| --md-sys-checkbox-border-width | 2px | Controls the thickness of the checkbox's border |
|
|
85
|
+
| --md-sys-checkbox-check-thickness | 2px | The thickness of the checkmark |
|
|
46
86
|
| --md-sys-checkbox-container-size | 18px | Defines the size of the checkbox itself |
|
|
47
|
-
| --md-sys-checkbox-selected-icon | \2A3D | The character used as the checkmark for the checkbox |
|
|
48
|
-
| --md-sys-checkbox-state-layer-radius | 20px | Sets the radius of the interactive area that indicates the component's current state (e.g., hover, focus, press) |
|
|
49
87
|
|
|
50
|
-
**Example: Changing the
|
|
88
|
+
**Example: Changing the border width of a checkbox**
|
|
51
89
|
|
|
52
90
|
```HTML
|
|
53
|
-
<div style="--md-sys-checkbox-
|
|
91
|
+
<div style="--md-sys-checkbox-border-width:1px">
|
|
54
92
|
<input type="checkbox" id="mycheckbox" class="micl-checkbox">
|
|
55
93
|
<label for="mycheckbox">Checkbox</label>
|
|
56
94
|
</div>
|