euv-ui 0.34.0

Reusable UI component library for the euv framework, providing buttons, cards, modals, inputs, and more.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
use super::*;

// Design tokens shared by every UI scheme.
//
// The two classes below carry the **semantic mapping** — the scheme's role
// primitives selected for the active mode — plus the **universal structure
// scale** (spacing, motion, layout) that every mainstream design system
// agrees on: they all space on a four-pixel base.
//
// A scheme owns the tokens that genuinely differ between design languages:
// the colour roles, the radius scale, the shadow ramp, the type ramp, the
// tracking and case treatments, and the control heights. The two sets are
// disjoint by construction, so a scheme class and a mode class can sit on
// the same root element without either shadowing the other.
//
// The role primitives are read through `var!("role-…")` so the generated CSS
// is `var(--role-background-light)` rather than a literal.
vars! {
    pub c_theme_light {
        // ═══════════════════════════════════════════════════════════════════════
        // Surfaces
        // ═══════════════════════════════════════════════════════════════════════

        background: var!("role-background-light");
        foreground: var!("role-foreground-light");
        bg-overlay: "rgba(0, 0, 0, 0.45)";
        card: var!("role-card-light");
        card-foreground: var!("role-card-foreground-light");
        popover: var!("role-popover-light");
        popover-foreground: var!("role-popover-foreground-light");

        // ═══════════════════════════════════════════════════════════════════════
        // Brand and Neutrals
        // ═══════════════════════════════════════════════════════════════════════

        primary: var!("role-primary-light");
        primary-foreground: var!("role-primary-foreground-light");
        primary-hover: var!("role-primary-hover-light");
        secondary: var!("role-secondary-light");
        secondary-foreground: var!("role-secondary-foreground-light");
        muted: var!("role-muted-light");
        muted-foreground: var!("role-muted-foreground-light");
        accent: var!("role-accent-light");
        accent-foreground: var!("role-accent-foreground-light");

        // ═══════════════════════════════════════════════════════════════════════
        // Status
        // ═══════════════════════════════════════════════════════════════════════

        destructive: var!("role-destructive-light");
        destructive-foreground: var!("role-destructive-foreground-light");
        success: var!("role-success-light");
        success-foreground: var!("role-success-foreground-light");
        success-container: var!("role-success-container-light");
        warning: var!("role-warning-light");
        warning-foreground: var!("role-warning-foreground-light");
        warning-container: var!("role-warning-container-light");
        error-container: var!("role-error-container-light");

        // ═══════════════════════════════════════════════════════════════════════
        // Lines and Focus
        // ═══════════════════════════════════════════════════════════════════════

        border: var!("role-border-light");
        input: var!("role-input-light");
        ring: var!("role-ring-light");

        // ═══════════════════════════════════════════════════════════════════════
        // Scrollbar
        // ═══════════════════════════════════════════════════════════════════════

        scrollbar-track: "transparent";
        scrollbar-thumb: var!("role-scrollbar-thumb-light");
        scrollbar-thumb-hover: var!("role-scrollbar-thumb-hover-light");
        scrollbar-thumb-active: var!("role-scrollbar-thumb-active-light");

        // ═══════════════════════════════════════════════════════════════════════
        // Spacing Scale — four pixels, the base every mainstream system uses.
        // ═══════════════════════════════════════════════════════════════════════

        space-2xs: "2px";
        space-xs: "4px";
        space-sm: "8px";
        space-md: "12px";
        space-lg: "16px";
        space-xl: "20px";
        space-2xl: "24px";
        space-3xl: "32px";
        space-4xl: "40px";
        space-7xl: "80px";

        // ═══════════════════════════════════════════════════════════════════════
        // Component Spacing Scale
        // ═══════════════════════════════════════════════════════════════════════

        gap-section: "16px";
        gap-section-mobile: "12px";
        gap-component: "12px";
        gap-component-mobile: "10px";
        gap-element: "8px";
        gap-inline: "8px";
        gap-page-header: "16px";
        gap-page-title: "6px";

        // ═══════════════════════════════════════════════════════════════════════
        // Page Block Vertical Spacing
        // ═══════════════════════════════════════════════════════════════════════

        page-block-gap: "24px";
        page-block-gap-mobile: "20px";
        side-indent: "9px";
        side-indent-num: "9";

        // ═══════════════════════════════════════════════════════════════════════
        // Transition Durations
        // ═══════════════════════════════════════════════════════════════════════

        duration-fast: "0.15s";
        duration-normal: "0.2s";
        duration-slower: "0.4s";
        duration-overlay: "0.2s";
        duration-modal-overlay: "0.15s";
        duration-modal-content: "0.3s";

        // ═══════════════════════════════════════════════════════════════════════
        // Easing Functions
        // ═══════════════════════════════════════════════════════════════════════

        ease-out: "cubic-bezier(0.4, 0, 0.2, 1)";
        ease-in: "cubic-bezier(0.4, 0, 1, 1)";
        ease-in-out: "cubic-bezier(0.4, 0, 0.2, 1)";
        ease-bounce: "cubic-bezier(0.34, 1.56, 0.64, 1)";

        // ═══════════════════════════════════════════════════════════════════════
        // Layout
        // ═══════════════════════════════════════════════════════════════════════

        safe-area-inset-top: "var(--euv-mobile-safe-top, 0px)";
        safe-area-inset-right: "var(--euv-safe-right, 0px)";
        safe-area-inset-bottom: "var(--euv-safe-bottom, 0px)";
        safe-area-inset-left: "var(--euv-safe-left, 0px)";
        padding-shell-top: var!(safe-area-inset-top);
        padding-shell-bottom: var!(safe-area-inset-bottom);
        padding-main-top: "24px";
        padding-main-top-mobile: "16px";
        // Edge Gutter — distance from a viewport/shell edge to the chrome
        // anchored there. Every edge-anchored element (mobile header left and
        // right, drawer header, desktop navbar, main column, vconsole FAB)
        // reads one of these tokens, so left/right offsets can never drift
        // apart. `edge-gutter-nav` is the nav column's own inner gutter
        // (desktop sidebar and mobile drawer share it).
        edge-gutter: "28px";
        edge-gutter-mobile: "16px";
        edge-gutter-nav: "20px";
        edge-gutter-bottom: "20px";
        padding-main-horizontal: var!(edge-gutter);
        padding-main-horizontal-mobile: var!(edge-gutter-mobile);
        // Desktop sidebar adaptive width:
        //   `clamp(min, 22%, max)` lets the column grow with the available
        //   width up to a comfortable cap so long English titles (e.g.
        //   "Internationalization") no longer wrap. On the mobile drawer the
        //   same var is consumed with `min(100%, max)` instead — see
        //   `c_app_nav` / drawer classes.
        //   A percentage is used rather than a viewport width: the nav's
        //   containing block is the app root row, which is the full window
        //   width, so the two agree — but the percentage stays correct if a
        //   future shell constrains that row (e.g. a split view), and it
        //   keeps viewport units out of the codebase.
        nav-width: format!("clamp({}, 22%, {})", var!(nav-width-min), var!(nav-width-max));
        nav-width-min: "248px";
        nav-width-max: "320px";
        content-max-width: "820px";
        // The measure a body of text is set to — the line length a reader
        // can take in without losing the line. Narrower than the content
        // column, so prose stays readable inside a full-width card.
        text-measure: "360px";
        mobile-header-height: "52px";
    }

    pub c_theme_dark {
        // ═══════════════════════════════════════════════════════════════════════
        // Surfaces
        // ═══════════════════════════════════════════════════════════════════════

        background: var!("role-background-dark");
        foreground: var!("role-foreground-dark");
        bg-overlay: "rgba(0, 0, 0, 0.65)";
        card: var!("role-card-dark");
        card-foreground: var!("role-card-foreground-dark");
        popover: var!("role-popover-dark");
        popover-foreground: var!("role-popover-foreground-dark");

        // ═══════════════════════════════════════════════════════════════════════
        // Brand and Neutrals
        // ═══════════════════════════════════════════════════════════════════════

        primary: var!("role-primary-dark");
        primary-foreground: var!("role-primary-foreground-dark");
        primary-hover: var!("role-primary-hover-dark");
        secondary: var!("role-secondary-dark");
        secondary-foreground: var!("role-secondary-foreground-dark");
        muted: var!("role-muted-dark");
        muted-foreground: var!("role-muted-foreground-dark");
        accent: var!("role-accent-dark");
        accent-foreground: var!("role-accent-foreground-dark");

        // ═══════════════════════════════════════════════════════════════════════
        // Status
        // ═══════════════════════════════════════════════════════════════════════

        destructive: var!("role-destructive-dark");
        destructive-foreground: var!("role-destructive-foreground-dark");
        success: var!("role-success-dark");
        success-foreground: var!("role-success-foreground-dark");
        success-container: var!("role-success-container-dark");
        warning: var!("role-warning-dark");
        warning-foreground: var!("role-warning-foreground-dark");
        warning-container: var!("role-warning-container-dark");
        error-container: var!("role-error-container-dark");

        // ═══════════════════════════════════════════════════════════════════════
        // Lines and Focus
        // ═══════════════════════════════════════════════════════════════════════

        border: var!("role-border-dark");
        input: var!("role-input-dark");
        ring: var!("role-ring-dark");

        // ═══════════════════════════════════════════════════════════════════════
        // Scrollbar
        // ═══════════════════════════════════════════════════════════════════════

        scrollbar-track: "transparent";
        scrollbar-thumb: var!("role-scrollbar-thumb-dark");
        scrollbar-thumb-hover: var!("role-scrollbar-thumb-hover-dark");
        scrollbar-thumb-active: var!("role-scrollbar-thumb-active-dark");

        // ═══════════════════════════════════════════════════════════════════════
        // Spacing Scale (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        space-2xs: "2px";
        space-xs: "4px";
        space-sm: "8px";
        space-md: "12px";
        space-lg: "16px";
        space-xl: "20px";
        space-2xl: "24px";
        space-3xl: "32px";
        space-4xl: "40px";
        space-7xl: "80px";

        // ═══════════════════════════════════════════════════════════════════════
        // Component Spacing Scale (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        gap-section: "16px";
        gap-section-mobile: "12px";
        gap-component: "12px";
        gap-component-mobile: "10px";
        gap-element: "8px";
        gap-inline: "8px";
        gap-page-header: "16px";
        gap-page-title: "6px";

        // ═══════════════════════════════════════════════════════════════════════
        // Page Block Vertical Spacing (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        page-block-gap: "24px";
        page-block-gap-mobile: "20px";

        // ═══════════════════════════════════════════════════════════════════════
        // Transition Durations (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        duration-fast: "0.15s";
        duration-normal: "0.2s";
        duration-slower: "0.4s";
        duration-overlay: "0.2s";
        duration-modal-overlay: "0.15s";
        duration-modal-content: "0.3s";

        // ═══════════════════════════════════════════════════════════════════════
        // Easing Functions (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        ease-out: "cubic-bezier(0.4, 0, 0.2, 1)";
        ease-in: "cubic-bezier(0.4, 0, 1, 1)";
        ease-in-out: "cubic-bezier(0.4, 0, 0.2, 1)";
        ease-bounce: "cubic-bezier(0.34, 1.56, 0.64, 1)";

        // ═══════════════════════════════════════════════════════════════════════
        // Layout (same as light)
        // ═══════════════════════════════════════════════════════════════════════

        safe-area-inset-top: "var(--euv-mobile-safe-top, 0px)";
        safe-area-inset-right: "var(--euv-safe-right, 0px)";
        safe-area-inset-bottom: "var(--euv-safe-bottom, 0px)";
        safe-area-inset-left: "var(--euv-safe-left, 0px)";
        padding-shell-top: var!(safe-area-inset-top);
        padding-shell-bottom: var!(safe-area-inset-bottom);
        padding-main-top: "24px";
        padding-main-top-mobile: "16px";
        edge-gutter: "28px";
        edge-gutter-mobile: "16px";
        edge-gutter-nav: "20px";
        edge-gutter-bottom: "20px";
        padding-main-horizontal: var!(edge-gutter);
        padding-main-horizontal-mobile: var!(edge-gutter-mobile);
        nav-width: format!("clamp({}, 22%, {})", var!(nav-width-min), var!(nav-width-max));
        nav-width-min: "248px";
        nav-width-max: "320px";
        content-max-width: "820px";
        text-measure: "360px";
        mobile-header-height: "52px";
    }
}

/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(feature = "theme-shadcn")]
fn selected_scheme_class() -> &'static str {
    c_scheme_shadcn().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), feature = "theme-monochrome"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_monochrome().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), feature = "theme-antdesign"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_antdesign().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), feature = "theme-material"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_material().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), feature = "theme-bootstrap"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_bootstrap().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), feature = "theme-cupertino"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_cupertino().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), feature = "theme-fluent"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_fluent().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), feature = "theme-radix"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_radix().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), not(feature = "theme-radix"), feature = "theme-mantine"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_mantine().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), not(feature = "theme-radix"), not(feature = "theme-mantine"), feature = "theme-daisyui"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_daisyui().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), not(feature = "theme-radix"), not(feature = "theme-mantine"), not(feature = "theme-daisyui"), feature = "theme-heroui"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_heroui().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), not(feature = "theme-radix"), not(feature = "theme-mantine"), not(feature = "theme-daisyui"), not(feature = "theme-heroui"), feature = "theme-park"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_park().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(all(not(feature = "theme-shadcn"), not(feature = "theme-monochrome"), not(feature = "theme-antdesign"), not(feature = "theme-material"), not(feature = "theme-bootstrap"), not(feature = "theme-cupertino"), not(feature = "theme-fluent"), not(feature = "theme-radix"), not(feature = "theme-mantine"), not(feature = "theme-daisyui"), not(feature = "theme-heroui"), not(feature = "theme-park"), feature = "theme-geist"))]
fn selected_scheme_class() -> &'static str {
    c_scheme_geist().get_name()
}
/// Returns the CSS class name of the scheme this build selects.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
#[rustfmt::skip]
#[cfg(not(any(feature = "theme-shadcn", feature = "theme-monochrome", feature = "theme-antdesign", feature = "theme-material", feature = "theme-bootstrap", feature = "theme-cupertino", feature = "theme-fluent", feature = "theme-radix", feature = "theme-mantine", feature = "theme-daisyui", feature = "theme-heroui", feature = "theme-park", feature = "theme-geist")))]
fn selected_scheme_class() -> &'static str {
    c_scheme_shadcn().get_name()
}

/// Returns the CSS class name of the UI scheme compiled into this build.
///
/// The scheme is picked at compile time from the `theme-*` Cargo features.
/// More than one feature may be on at once — a workspace-wide `--all-features`
/// build turns them all on — so the order above decides which one wins.
///
/// # Returns
///
/// - `&'static str` - The class name that carries the scheme's tokens.
pub fn scheme_class_name() -> &'static str {
    selected_scheme_class()
}

/// Returns the name of the UI scheme compiled into this build.
///
/// # Returns
///
/// - `&'static str` - The scheme name, without its class prefix.
pub fn scheme_name() -> &'static str {
    let class: &str = scheme_class_name();
    class.strip_prefix(SCHEME_CLASS_PREFIX).unwrap_or(class)
}