@digicreon/mucss 1.0.0 → 1.2.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 +60 -11
- package/dist/mu.amber.css +2 -2
- package/dist/mu.azure.css +2 -2
- package/dist/mu.blue.css +2 -2
- package/dist/mu.css +2 -2
- package/dist/mu.cyan.css +2 -2
- package/dist/mu.fuchsia.css +2 -2
- package/dist/mu.green.css +2 -2
- package/dist/mu.grey.css +2 -2
- package/dist/mu.indigo.css +2 -2
- package/dist/mu.jade.css +2 -2
- package/dist/mu.lime.css +2 -2
- package/dist/mu.orange.css +2 -2
- package/dist/mu.pink.css +2 -2
- package/dist/mu.pumpkin.css +2 -2
- package/dist/mu.purple.css +2 -2
- package/dist/mu.red.css +2 -2
- package/dist/mu.sand.css +2 -2
- package/dist/mu.slate.css +2 -2
- package/dist/mu.violet.css +2 -2
- package/dist/mu.yellow.css +2 -2
- package/dist/mu.zinc.css +2 -2
- package/documentation/mu.accordion.md +4 -2
- package/documentation/mu.alert.md +22 -14
- package/documentation/mu.badge.md +35 -15
- package/documentation/mu.breadcrumb.md +8 -6
- package/documentation/mu.button.md +39 -28
- package/documentation/mu.card.md +35 -19
- package/documentation/mu.checkbox-radio.md +4 -2
- package/documentation/mu.code.md +85 -0
- package/documentation/mu.colors.md +307 -0
- package/documentation/mu.container.md +87 -0
- package/documentation/mu.dark-mode.md +96 -0
- package/documentation/mu.dropdown.md +32 -27
- package/documentation/mu.embedded.md +101 -0
- package/documentation/mu.figure.md +82 -0
- package/documentation/mu.forms-advanced.md +6 -4
- package/documentation/mu.forms.md +11 -9
- package/documentation/mu.grid.md +7 -1
- package/documentation/mu.group.md +29 -27
- package/documentation/mu.hero.md +200 -0
- package/documentation/mu.link.md +108 -0
- package/documentation/mu.loading.md +4 -2
- package/documentation/mu.modal.md +9 -7
- package/documentation/mu.nav.md +191 -0
- package/documentation/mu.pagination.md +3 -1
- package/documentation/mu.progress.md +31 -14
- package/documentation/mu.range.md +4 -2
- package/documentation/mu.skeleton.md +111 -0
- package/documentation/mu.spinner.md +20 -12
- package/documentation/mu.switch.md +4 -2
- package/documentation/mu.table.md +20 -6
- package/documentation/mu.tabs.md +5 -3
- package/documentation/mu.toast.md +134 -0
- package/documentation/mu.tooltip.md +30 -28
- package/documentation/mu.typography.md +44 -42
- package/documentation/mu.utilities.md +83 -0
- package/documentation/mu.variables.md +276 -0
- package/package.json +5 -3
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
# µColors
|
|
2
|
+
|
|
3
|
+
**µColors** describes the color system in [µCSS](.). The framework provides 11 semantic color roles, each with 7 CSS variable variants, color classes for the main visual components, and utility classes for text, background, and border colors.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Color roles
|
|
8
|
+
|
|
9
|
+
µCSS defines 11 color roles. Each role is mapped to a color family via the theme file (`build/mu.theme.json`).
|
|
10
|
+
|
|
11
|
+
| Role | Purpose |
|
|
12
|
+
|------|---------|
|
|
13
|
+
| `primary` | Main action color — links, buttons, active states |
|
|
14
|
+
| `secondary` | Supporting color — secondary buttons, muted elements |
|
|
15
|
+
| `tertiary` | Accent color — additional highlights |
|
|
16
|
+
| `contrast` | High-contrast color — strong emphasis |
|
|
17
|
+
| `accent` | Eye-catching color — chromatically distant from primary |
|
|
18
|
+
| `success` | Positive feedback — validation, confirmations |
|
|
19
|
+
| `info` | Informational — notices, tips |
|
|
20
|
+
| `warning` | Caution — alerts requiring attention |
|
|
21
|
+
| `error` | Negative feedback — errors, destructive actions |
|
|
22
|
+
| `pop` | Lighter variant of accent — derived from the accent color family with brighter shades |
|
|
23
|
+
| `spark` | Lighter variant of contrast — derived from the contrast color family with brighter shades |
|
|
24
|
+
|
|
25
|
+
> **Note:** `pop` and `spark` are derived roles — `pop` uses the same color family as `accent`, and `spark` uses the same color family as `contrast`, both with lighter shade values. They do not appear in the theme JSON.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## CSS variables per role
|
|
30
|
+
|
|
31
|
+
Each role generates 7 CSS variables, automatically adapted for light and dark modes:
|
|
32
|
+
|
|
33
|
+
| Variable | Description |
|
|
34
|
+
|----------|-------------|
|
|
35
|
+
| `--mu-{role}` | Base color |
|
|
36
|
+
| `--mu-{role}-background` | Tinted background (light tint in light mode, dark tint in dark mode) |
|
|
37
|
+
| `--mu-{role}-hover` | Hover state color |
|
|
38
|
+
| `--mu-{role}-hover-background` | Hover background |
|
|
39
|
+
| `--mu-{role}-focus` | Focus ring color (semi-transparent) |
|
|
40
|
+
| `--mu-{role}-inverse` | Text color on a filled background (`#fff` or `#000`) |
|
|
41
|
+
| `--mu-{role}-underline` | Semi-transparent underline |
|
|
42
|
+
|
|
43
|
+
### Example
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
.custom-banner {
|
|
47
|
+
color: var(--mu-info);
|
|
48
|
+
background-color: var(--mu-info-background);
|
|
49
|
+
border-left: 4px solid var(--mu-info);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.custom-banner:hover {
|
|
53
|
+
color: var(--mu-info-hover);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Utility classes
|
|
60
|
+
|
|
61
|
+
µCSS provides 34 utility classes in `css/mu.colors.css`:
|
|
62
|
+
|
|
63
|
+
### Text color
|
|
64
|
+
|
|
65
|
+
| Class | Effect |
|
|
66
|
+
|-------|--------|
|
|
67
|
+
| `.c-primary` … `.c-spark` | Sets `color` to the role's base color |
|
|
68
|
+
|
|
69
|
+
### Text color (inverse)
|
|
70
|
+
|
|
71
|
+
| Class | Effect |
|
|
72
|
+
|-------|--------|
|
|
73
|
+
| `.c-inverse` | Sets `color` to the primary inverse color (white or black, for readable text on filled backgrounds) |
|
|
74
|
+
|
|
75
|
+
### Background color
|
|
76
|
+
|
|
77
|
+
| Class | Effect |
|
|
78
|
+
|-------|--------|
|
|
79
|
+
| `.bg-primary` … `.bg-spark` | Sets `background-color` to the role's base color, `color` to inverse (white/black), and links inherit the inverse color |
|
|
80
|
+
|
|
81
|
+
### Border color
|
|
82
|
+
|
|
83
|
+
| Class | Effect |
|
|
84
|
+
|-------|--------|
|
|
85
|
+
| `.border-primary` … `.border-spark` | Sets `border-color` to the role's base color |
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<p class="c-error">Red text</p>
|
|
89
|
+
<div class="bg-accent">Accent background — text and links are automatically white</div>
|
|
90
|
+
<div class="border-success" style="border:2px solid">Green border</div>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
> **Note:** On `<nav>` or on a parent of `<nav>` (e.g. `<header>`), `.bg-*` classes also apply a gradient (same as [µHero](mu.hero.md)). See [µNav](mu.nav.md#colored-navbars).
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Color classes by component
|
|
98
|
+
|
|
99
|
+
The following components accept color classes for all 11 roles:
|
|
100
|
+
|
|
101
|
+
### Button
|
|
102
|
+
|
|
103
|
+
Filled buttons use the role color as background. Outline buttons use it as text and border only.
|
|
104
|
+
|
|
105
|
+
| Class | Style |
|
|
106
|
+
|-------|-------|
|
|
107
|
+
| `.btn-primary` … `.btn-spark` | Filled background with inverse text |
|
|
108
|
+
| `.btn-outline.btn-primary` … `.btn-outline.btn-spark` | Transparent background, colored text and border |
|
|
109
|
+
| `.btn-link` | Link appearance using primary color |
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<button class="btn btn-success">Save</button>
|
|
113
|
+
<button class="btn btn-outline btn-error">Delete</button>
|
|
114
|
+
<button class="btn btn-accent">Highlight</button>
|
|
115
|
+
<button class="btn btn-pop">Pop action</button>
|
|
116
|
+
<button class="btn btn-spark">Spark action</button>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Alert
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<div class="alert alert-warning">Caution: this action cannot be undone.</div>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
| Class | Style |
|
|
126
|
+
|-------|-------|
|
|
127
|
+
| `.alert-primary` … `.alert-spark` | Colored text, tinted background |
|
|
128
|
+
|
|
129
|
+
### Badge
|
|
130
|
+
|
|
131
|
+
Solid badges use the role color as background. Outline badges use it as text and border only.
|
|
132
|
+
|
|
133
|
+
```html
|
|
134
|
+
<span class="badge badge-success">Active</span>
|
|
135
|
+
<span class="badge badge-outline badge-error">Expired</span>
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| Class | Style |
|
|
139
|
+
|-------|-------|
|
|
140
|
+
| `.badge-primary` … `.badge-spark` | Filled background with inverse text |
|
|
141
|
+
| `.badge-outline.badge-primary` … `.badge-outline.badge-spark` | Transparent background, colored text and border |
|
|
142
|
+
|
|
143
|
+
### Card
|
|
144
|
+
|
|
145
|
+
```html
|
|
146
|
+
<article class="card-info">
|
|
147
|
+
<header>Note</header>
|
|
148
|
+
<p>Card content with a colored left border and tinted background.</p>
|
|
149
|
+
</article>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
| Class | Style |
|
|
153
|
+
|-------|-------|
|
|
154
|
+
| `.card-primary` … `.card-spark` | Tinted background, shaded header/footer |
|
|
155
|
+
|
|
156
|
+
### Hero
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<section class="hero hero-primary">
|
|
160
|
+
<h1>Welcome</h1>
|
|
161
|
+
</section>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Class | Style |
|
|
165
|
+
|-------|-------|
|
|
166
|
+
| `.hero-primary` … `.hero-spark` | Gradient background with inverse text |
|
|
167
|
+
|
|
168
|
+
### Spinner
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<div class="spinner spinner-success"></div>
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
| Class | Style |
|
|
175
|
+
|-------|-------|
|
|
176
|
+
| `.spinner-primary` … `.spinner-spark` | Colored spinning border |
|
|
177
|
+
|
|
178
|
+
### Progress
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<progress class="progress-success" value="75" max="100"></progress>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
| Class | Style |
|
|
185
|
+
|-------|-------|
|
|
186
|
+
| `.progress-primary` … `.progress-spark` | Colored progress bar |
|
|
187
|
+
|
|
188
|
+
### Forms
|
|
189
|
+
|
|
190
|
+
Form validation uses a subset of roles:
|
|
191
|
+
|
|
192
|
+
| Class | Style |
|
|
193
|
+
|-------|-------|
|
|
194
|
+
| `.input-success` | Green border and focus ring |
|
|
195
|
+
| `.input-warning` | Amber border and focus ring |
|
|
196
|
+
| `aria-invalid="true"` | Red border and focus ring (built-in) |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Link color variants
|
|
201
|
+
|
|
202
|
+
Links support 3 color variants via CSS classes:
|
|
203
|
+
|
|
204
|
+
```html
|
|
205
|
+
<a href="#">Primary link (default)</a>
|
|
206
|
+
<a href="#" class="secondary">Secondary link</a>
|
|
207
|
+
<a href="#" class="contrast">Contrast link</a>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
| Class | Color variable |
|
|
211
|
+
|-------|----------------|
|
|
212
|
+
| *(default)* | `--mu-primary` |
|
|
213
|
+
| `.secondary` | `--mu-secondary` |
|
|
214
|
+
| `.contrast` | `--mu-contrast` |
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Components with implicit colors
|
|
219
|
+
|
|
220
|
+
These components use color roles internally but do not expose color classes:
|
|
221
|
+
|
|
222
|
+
| Component | Colors used |
|
|
223
|
+
|-----------|-------------|
|
|
224
|
+
| Pagination | `--mu-primary` (active), `--mu-secondary` (borders, disabled) |
|
|
225
|
+
| Tabs | `--mu-primary` (active tab), `--mu-secondary` (inactive) |
|
|
226
|
+
| Breadcrumb | `--mu-primary` (links), `--mu-secondary` (dividers, last item) |
|
|
227
|
+
| Accordion | `--mu-secondary-background` (borders) |
|
|
228
|
+
| Table | `--mu-secondary-background` (stripes, hover, borders) |
|
|
229
|
+
| Skeleton | `--mu-secondary-background` (placeholder background) |
|
|
230
|
+
| Modal | `--mu-secondary` (close button) |
|
|
231
|
+
| Toast | Inherits alert colors via `.alert-{role}` |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Base theme colors
|
|
236
|
+
|
|
237
|
+
These variables define the overall page appearance and adapt between light and dark modes:
|
|
238
|
+
|
|
239
|
+
| Variable | Light | Dark |
|
|
240
|
+
|----------|-------|------|
|
|
241
|
+
| `--mu-background-color` | `#fff` | `rgb(19, 22.5, 30.5)` |
|
|
242
|
+
| `--mu-color` | `#373c44` | `#c2c7d0` |
|
|
243
|
+
| `--mu-muted-color` | `#646b79` | `#8891a4` |
|
|
244
|
+
| `--mu-muted-border-color` | `rgb(231, 234, 239.5)` | `rgb(48, 54.5, 69)` |
|
|
245
|
+
| `--mu-mark-background-color` | `rgb(252.5, 230.5, 191.5)` | `rgb(252.5, 230.5, 191.5)` |
|
|
246
|
+
| `--mu-h1-color` … `--mu-h6-color` | Graded shades from dark to muted | Graded shades from light to muted |
|
|
247
|
+
|
|
248
|
+
The full variable reference is available in [µVariables](mu.variables.md).
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Pre-built themes
|
|
253
|
+
|
|
254
|
+
µCSS includes 20 pre-built color themes, each generating a dedicated CSS file (`mu.{name}.css`). The default theme is **azure** (`mu.css`).
|
|
255
|
+
|
|
256
|
+
Each theme is named after its `primary` color family and remaps the 11 roles accordingly. Most themes share the same defaults for secondary (slate), tertiary (sand), success (green), info (cyan), warning (amber), and error (red) — the `primary`, `contrast`, and `accent` roles vary per theme. The `pop` role always derives from `accent` with lighter shades, and the `spark` role always derives from `contrast` with lighter shades.
|
|
257
|
+
|
|
258
|
+
Available themes: **azure** (default), **red**, **pink**, **fuchsia**, **purple**, **violet**, **indigo**, **blue**, **cyan**, **jade**, **green**, **lime**, **yellow**, **amber**, **pumpkin**, **orange**, **sand**, **grey**, **zinc**, **slate**.
|
|
259
|
+
|
|
260
|
+
To use a theme, load its CSS file instead of the default:
|
|
261
|
+
|
|
262
|
+
```html
|
|
263
|
+
<link rel="stylesheet" href="dist/mu.pink.css">
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Themes are defined in `build/mu.theme.json`. Each entry maps the 9 configurable roles (all except `pop` and `spark`) to color families from a palette of 20 colors.
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
## Customization
|
|
271
|
+
|
|
272
|
+
Override role colors on `:root` to change them globally:
|
|
273
|
+
|
|
274
|
+
```css
|
|
275
|
+
:root {
|
|
276
|
+
--mu-primary: #e63946;
|
|
277
|
+
--mu-primary-hover: #c5303b;
|
|
278
|
+
--mu-primary-focus: rgba(230, 57, 70, 0.375);
|
|
279
|
+
--mu-primary-inverse: #fff;
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
For theme-based color generation, edit `build/mu.theme.json` and rebuild:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"primary": "red",
|
|
288
|
+
"secondary": "slate",
|
|
289
|
+
"tertiary": "sand",
|
|
290
|
+
"contrast": "indigo",
|
|
291
|
+
"accent": "jade",
|
|
292
|
+
"success": "green",
|
|
293
|
+
"info": "azure",
|
|
294
|
+
"warning": "amber",
|
|
295
|
+
"error": "pink"
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
php build/mu-build.php
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
> See also : [µVariables](mu.variables.md) · [µDark Mode](mu.dark-mode.md) · [µButton](mu.button.md) · [µAlert](mu.alert.md)
|
|
306
|
+
|
|
307
|
+
→ [See example](../examples/colors.html)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# µContainer
|
|
2
|
+
|
|
3
|
+
**µContainer** provides the `.container` and `.container-fluid` layout classes in [µCSS](.). The container centers content horizontally and applies a responsive maximum width adapted to each breakpoint.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
Wrap the main content in an element with the `.container` class:
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<main class="container">
|
|
13
|
+
<h1>Mon contenu</h1>
|
|
14
|
+
<p>Centre et contraint en largeur.</p>
|
|
15
|
+
</main>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## `.container` — Constrained width
|
|
21
|
+
|
|
22
|
+
The container is fluid (100%) on mobile, then constrained to a maximum width at each breakpoint:
|
|
23
|
+
|
|
24
|
+
| Breakpoint | Minimum width | `max-width` |
|
|
25
|
+
|------------|---------------|-------------|
|
|
26
|
+
| XS | < 576px | 100% (fluid) |
|
|
27
|
+
| SM | ≥ 576px | 510px |
|
|
28
|
+
| MD | ≥ 768px | 700px |
|
|
29
|
+
| LG | ≥ 1024px | 950px |
|
|
30
|
+
| XL | ≥ 1280px | 1200px |
|
|
31
|
+
| XXL | ≥ 1536px | 1450px |
|
|
32
|
+
|
|
33
|
+
In fluid mode (< 576px), a horizontal padding of `var(--mu-spacing)` (1rem) is applied. From 576px onward, the padding is removed and the maximum width takes over.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## `.container-fluid` — Full width
|
|
38
|
+
|
|
39
|
+
The fluid container always occupies 100% of the width, with constant horizontal padding:
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<section class="container-fluid">
|
|
43
|
+
<p>Contenu pleine largeur avec marges laterales.</p>
|
|
44
|
+
</section>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Typical page structure
|
|
50
|
+
|
|
51
|
+
µCSS recommends the `<body> > <header> + <main> + <footer>` structure, each containing a `.container`:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<body>
|
|
55
|
+
<header>
|
|
56
|
+
<nav class="container">
|
|
57
|
+
<ul><li><strong>Mon site</strong></li></ul>
|
|
58
|
+
<ul><li><a href="#">Lien</a></li></ul>
|
|
59
|
+
</nav>
|
|
60
|
+
</header>
|
|
61
|
+
<main class="container">
|
|
62
|
+
<h1>Titre</h1>
|
|
63
|
+
<p>Contenu principal.</p>
|
|
64
|
+
</main>
|
|
65
|
+
<footer class="container">
|
|
66
|
+
<p>Pied de page</p>
|
|
67
|
+
</footer>
|
|
68
|
+
</body>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The `<body> > header`, `<body> > main`, and `<body> > footer` elements receive a vertical padding of `var(--mu-block-spacing-vertical)`.
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## Customization
|
|
76
|
+
|
|
77
|
+
The `--mu-spacing` variable (default: `1rem`) controls the horizontal padding of the container in fluid mode:
|
|
78
|
+
|
|
79
|
+
```css
|
|
80
|
+
:root {
|
|
81
|
+
--mu-spacing: 1.5rem;
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
> See also : [µGrid](mu.grid.md)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# µDark Mode
|
|
2
|
+
|
|
3
|
+
**µDark Mode** manages the toggle between light and dark themes in [µCSS](.). Dark mode is activated either automatically via the user's system preference (`prefers-color-scheme`), or manually via the `data-theme` attribute on the root element.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
No configuration is required for automatic mode. µCSS detects the system preference and adapts colors accordingly.
|
|
10
|
+
|
|
11
|
+
To force a theme, add `data-theme` on `<html>`:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<html data-theme="dark">
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Available modes
|
|
20
|
+
|
|
21
|
+
| Mode | Trigger | CSS Selector |
|
|
22
|
+
|------|---------|--------------|
|
|
23
|
+
| Light (default) | System preference or `data-theme="light"` | `:root:not([data-theme="dark"])` |
|
|
24
|
+
| Auto dark | `prefers-color-scheme: dark` without `data-theme` | `@media (prefers-color-scheme: dark) { :root:not([data-theme]) }` |
|
|
25
|
+
| Forced dark | `data-theme="dark"` | `[data-theme="dark"]` |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Manual toggle
|
|
30
|
+
|
|
31
|
+
A JavaScript button allows the user to toggle between themes:
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<button id="theme-toggle">Basculer le theme</button>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
const btn = document.getElementById('theme-toggle');
|
|
38
|
+
btn.addEventListener('click', () => {
|
|
39
|
+
const html = document.documentElement;
|
|
40
|
+
const current = html.getAttribute('data-theme');
|
|
41
|
+
html.setAttribute('data-theme', current === 'dark' ? 'light' : 'dark');
|
|
42
|
+
});
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Affected color variables
|
|
49
|
+
|
|
50
|
+
All µCSS color variables adapt to the theme. The main ones:
|
|
51
|
+
|
|
52
|
+
| Variable | Light theme | Dark theme |
|
|
53
|
+
|----------|-------------|------------|
|
|
54
|
+
| `--mu-background-color` | `#fff` | `rgb(19, 22.5, 30.5)` |
|
|
55
|
+
| `--mu-color` | `#373c44` | `#c2c7d0` |
|
|
56
|
+
| `--mu-primary` | `#0172ad` | `#01aaff` |
|
|
57
|
+
| `--mu-muted-color` | `#646b79` | `#8891a4` |
|
|
58
|
+
| `--mu-card-background-color` | `#fff` | `rgb(24, 28.5, 38)` |
|
|
59
|
+
|
|
60
|
+
The full list is available in [mu.variables.md](mu.variables.md).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## `color-scheme` property
|
|
65
|
+
|
|
66
|
+
µCSS sets `color-scheme: light` or `color-scheme: dark` depending on the active theme. This native CSS property informs the browser of the color scheme, which affects scrollbars, native form fields, and other browser UI elements.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Color customization
|
|
71
|
+
|
|
72
|
+
To override the colors of a theme, target the corresponding selector:
|
|
73
|
+
|
|
74
|
+
```css
|
|
75
|
+
/* Surcharge du fond en mode sombre */
|
|
76
|
+
[data-theme="dark"] {
|
|
77
|
+
--mu-background-color: #1a1a2e;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Surcharge en mode clair */
|
|
81
|
+
:root:not([data-theme="dark"]) {
|
|
82
|
+
--mu-primary: #e63946;
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Accessibility
|
|
89
|
+
|
|
90
|
+
- Theme toggling must not modify the content or structure of the page.
|
|
91
|
+
- Color contrasts comply with WCAG AA recommendations in both themes.
|
|
92
|
+
- Using `prefers-color-scheme` as the default mode respects user preferences.
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
> See also : [µVariables](mu.variables.md)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# µDropdown
|
|
2
2
|
|
|
3
|
-
**µDropdown**
|
|
3
|
+
**µDropdown** provides pure CSS dropdown menus via the `<details class="dropdown">` element, styled by [µCSS](.). No JavaScript is required: opening and closing are handled natively by the browser.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Basic usage
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
A dropdown is built with `<details class="dropdown">`. The `<summary>` serves as the trigger and the `<ul>` list contains the options.
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
12
|
<details class="dropdown">
|
|
@@ -21,9 +21,9 @@ Un dropdown est construit avec `<details class="dropdown">`. Le `<summary>` sert
|
|
|
21
21
|
|
|
22
22
|
---
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Button style
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
Add `role="button"` to the `<summary>` to give it the appearance of a button.
|
|
27
27
|
|
|
28
28
|
```html
|
|
29
29
|
<details class="dropdown">
|
|
@@ -39,13 +39,13 @@ Ajoutez `role="button"` sur le `<summary>` pour lui donner l'apparence d'un bout
|
|
|
39
39
|
|
|
40
40
|
---
|
|
41
41
|
|
|
42
|
-
##
|
|
42
|
+
## Native variants
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
µCSS provides style variants via classes on the `<summary role="button">`:
|
|
45
45
|
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
| *(
|
|
46
|
+
| Class | Appearance |
|
|
47
|
+
|-------|------------|
|
|
48
|
+
| *(none)* | Primary (default) |
|
|
49
49
|
| `.secondary` | Secondary |
|
|
50
50
|
| `.contrast` | Contrast |
|
|
51
51
|
| `.outline` | Outline |
|
|
@@ -86,20 +86,23 @@ PicoCSS fournit des variantes de style via des classes sur le `<summary role="bu
|
|
|
86
86
|
|
|
87
87
|
---
|
|
88
88
|
|
|
89
|
-
##
|
|
89
|
+
## µCSS color variants
|
|
90
90
|
|
|
91
|
-
µCSS
|
|
91
|
+
µCSS extends dropdowns with `.btn-*` classes on the `<summary>` for the 11 color roles:
|
|
92
92
|
|
|
93
|
-
|
|
|
94
|
-
|
|
93
|
+
| Class | Color |
|
|
94
|
+
|-------|-------|
|
|
95
95
|
| `.btn-primary` | Primary |
|
|
96
96
|
| `.btn-secondary` | Secondary |
|
|
97
97
|
| `.btn-tertiary` | Tertiary |
|
|
98
98
|
| `.btn-contrast` | Contrast |
|
|
99
|
+
| `.btn-accent` | Accent |
|
|
99
100
|
| `.btn-success` | Success |
|
|
100
101
|
| `.btn-info` | Info |
|
|
101
102
|
| `.btn-warning` | Warning |
|
|
102
103
|
| `.btn-error` | Error |
|
|
104
|
+
| `.btn-pop` | Pop |
|
|
105
|
+
| `.btn-spark` | Spark |
|
|
103
106
|
|
|
104
107
|
```html
|
|
105
108
|
<details class="dropdown">
|
|
@@ -129,9 +132,9 @@ PicoCSS fournit des variantes de style via des classes sur le `<summary role="bu
|
|
|
129
132
|
|
|
130
133
|
---
|
|
131
134
|
|
|
132
|
-
##
|
|
135
|
+
## Select replacement
|
|
133
136
|
|
|
134
|
-
|
|
137
|
+
A dropdown can serve as a styled alternative to a native `<select>` by placing it inside a `<label>`.
|
|
135
138
|
|
|
136
139
|
```html
|
|
137
140
|
<label>Choose a fruit
|
|
@@ -148,7 +151,7 @@ Un dropdown peut servir d'alternative stylee a un `<select>` natif en le placant
|
|
|
148
151
|
</label>
|
|
149
152
|
```
|
|
150
153
|
|
|
151
|
-
**Note
|
|
154
|
+
**Note:** unlike a native `<select>`, the selected value is not managed automatically. A minimum of application JavaScript is required to update the `<summary>` text after selection.
|
|
152
155
|
|
|
153
156
|
---
|
|
154
157
|
|
|
@@ -166,18 +169,20 @@ Un dropdown peut servir d'alternative stylee a un `<select>` natif en le placant
|
|
|
166
169
|
|
|
167
170
|
| Element | Role |
|
|
168
171
|
|---------|------|
|
|
169
|
-
| `<details class="dropdown">` |
|
|
170
|
-
| `<summary>` |
|
|
171
|
-
| `<summary role="button">` |
|
|
172
|
-
| `<ul>` |
|
|
173
|
-
| `<li><a>` |
|
|
172
|
+
| `<details class="dropdown">` | Dropdown container |
|
|
173
|
+
| `<summary>` | Trigger (text or button) |
|
|
174
|
+
| `<summary role="button">` | Trigger with button appearance |
|
|
175
|
+
| `<ul>` | Options list |
|
|
176
|
+
| `<li><a>` | Clickable menu item |
|
|
174
177
|
|
|
175
178
|
---
|
|
176
179
|
|
|
177
|
-
##
|
|
180
|
+
## Accessibility
|
|
178
181
|
|
|
179
|
-
-
|
|
180
|
-
-
|
|
181
|
-
-
|
|
182
|
+
- The component relies on the native `<details>`/`<summary>` element, which is keyboard accessible by default (opens via `Enter` or `Space`).
|
|
183
|
+
- The `role="button"` attribute on `<summary>` informs assistive technologies that the element acts as a button.
|
|
184
|
+
- The menu closes automatically when the user clicks outside (native `<details>` behavior).
|
|
182
185
|
|
|
183
|
-
|
|
186
|
+
> See also : [µNav](mu.nav.md) · [µButton](mu.button.md)
|
|
187
|
+
|
|
188
|
+
> [See example](../examples/dropdown.html)
|