@codenhub/styles 0.1.0 → 0.1.1
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 +7 -69
- package/dist/aesthetics/chunky-tile.css +1 -1
- package/dist/aesthetics/index.css +1 -1
- package/dist/components.css +1 -1
- package/dist/index.css +1 -1
- package/dist/native.css +1 -1
- package/dist/theme.css +1 -1
- package/dist/tw/aesthetics/chunky-tile.css +4 -2
- package/dist/tw/box.css +21 -0
- package/dist/tw/components/button.css +23 -3
- package/dist/tw/components/form.css +0 -2
- package/dist/tw/components/index.css +16 -6
- package/dist/tw/components/surface.css +29 -5
- package/dist/tw/elevation.css +14 -7
- package/dist/tw/index.css +20 -5
- package/dist/tw/intent.css +20 -0
- package/dist/tw/native.css +4 -20
- package/dist/tw/reset.css +20 -33
- package/dist/tw/theme.css +12 -7
- package/dist/tw/utilities/content.css +14 -2
- package/docs/accessibility.md +58 -48
- package/docs/changelog/0.1.0.md +37 -0
- package/docs/changelog/0.1.1.md +10 -0
- package/docs/changelog/index.md +10 -0
- package/docs/concepts.md +20 -46
- package/docs/index.md +18 -45
- package/docs/integrating/astro.md +13 -7
- package/docs/integrating/index.md +25 -16
- package/docs/integrating/nextjs.md +31 -8
- package/docs/integrating/svelte.md +14 -8
- package/docs/integrating/tailwind.md +31 -15
- package/docs/integrating/vue.md +13 -7
- package/docs/setup.md +35 -55
- package/docs/usage/aesthetics.md +30 -107
- package/docs/usage/buttons.md +19 -35
- package/docs/usage/composing.md +25 -100
- package/docs/usage/content-and-layout.md +56 -81
- package/docs/usage/customizing.md +25 -90
- package/docs/usage/feedback.md +11 -49
- package/docs/usage/forms.md +16 -58
- package/docs/usage/index.md +9 -17
- package/docs/usage/theming.md +25 -81
- package/docs/usage/tooltips.md +15 -21
- package/llms-full.txt +1060 -1506
- package/package.json +121 -44
package/llms-full.txt
CHANGED
|
@@ -12,8 +12,7 @@ pnpm add @codenhub/styles
|
|
|
12
12
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
|
-
Import the compiled stylesheet for the complete token, reset, utility, and
|
|
16
|
-
component-class surface:
|
|
15
|
+
Import the compiled stylesheet for the complete token, reset, utility, and component-class surface:
|
|
17
16
|
|
|
18
17
|
```css
|
|
19
18
|
@import "@codenhub/styles";
|
|
@@ -27,71 +26,15 @@ component-class surface:
|
|
|
27
26
|
</main>
|
|
28
27
|
```
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```css
|
|
33
|
-
@import "tailwindcss";
|
|
34
|
-
@import "@codenhub/styles/tw";
|
|
35
|
-
|
|
36
|
-
@source "./src";
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
The root follows the system color-scheme preference. Apply `.light` or `.dark`
|
|
40
|
-
to force a theme for the root or a subtree.
|
|
41
|
-
|
|
42
|
-
```html
|
|
43
|
-
<html class="dark">
|
|
44
|
-
<body>
|
|
45
|
-
<button class="btn primary">Dark themed button</button>
|
|
46
|
-
</body>
|
|
47
|
-
</html>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The aliases `.theme-light`, `.theme-dark`, and `data-theme="light|dark"` are
|
|
51
|
-
also supported. See [Concepts](./docs/concepts.md#theme-selection) for
|
|
52
|
-
precedence details.
|
|
53
|
-
|
|
54
|
-
`.solid`, `.soft`, and `.ghost` set how much intent fills a component; `.edged`
|
|
55
|
-
and `.edgeless` set whether it draws a boundary. Both axes cascade, so a
|
|
56
|
-
container sets the look below it and any element can still override it.
|
|
57
|
-
`.solid` also takes the boundary away, because a filled box ringed in another
|
|
58
|
-
color is what the blend behind `.edged` exists to prevent; `.solid.edged` is the
|
|
59
|
-
way back to a line.
|
|
60
|
-
|
|
61
|
-
```html
|
|
62
|
-
<div class="soft">
|
|
63
|
-
<button class="btn primary">Soft</button>
|
|
64
|
-
<span class="badge success">Soft</span>
|
|
65
|
-
<button class="btn primary ghost edged">Outlined</button>
|
|
66
|
-
</div>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
Aesthetics decide what a component is made of. They are opt-in, so import the
|
|
70
|
-
stylesheet after the base one to make `.neobrutalism`, `.glass`, `.pixel`, and
|
|
71
|
-
`.chunky-tile` available. They cascade to any subtree the same way, and each is
|
|
72
|
-
also importable on its own from `@codenhub/styles/aesthetics/<name>`.
|
|
73
|
-
|
|
74
|
-
```css
|
|
75
|
-
@import "@codenhub/styles";
|
|
76
|
-
@import "@codenhub/styles/aesthetics";
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
```html
|
|
80
|
-
<section class="neobrutalism">
|
|
81
|
-
<button class="btn primary">Thick ink and a hard shadow</button>
|
|
82
|
-
</section>
|
|
83
|
-
```
|
|
29
|
+
For the Tailwind CSS v4 entrypoint, theme selection, the intent/presentation axes, and opt-in aesthetics, see [Setup](./docs/setup.md), [Concepts](./docs/concepts.md), and [Usage](./docs/usage/index.md).
|
|
84
30
|
|
|
85
31
|
## Documentation
|
|
86
32
|
|
|
87
|
-
- [Documentation overview](./docs/index.md): What the package is, what it
|
|
88
|
-
does and does not do, and where to go next.
|
|
33
|
+
- [Documentation overview](./docs/index.md): What the package is, what it does and does not do, and where to go next.
|
|
89
34
|
- [Setup](./docs/setup.md): Installation, entrypoints, and configuration.
|
|
90
35
|
- [Concepts](./docs/concepts.md): The three-axis model and the token system.
|
|
91
|
-
- [Usage](./docs/usage/index.md): Composing, theming, customizing,
|
|
92
|
-
|
|
93
|
-
- [Integrating](./docs/integrating/index.md): Wiring the stylesheet into
|
|
94
|
-
Next.js, Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
36
|
+
- [Usage](./docs/usage/index.md): Composing, theming, customizing, aesthetics, and each component family.
|
|
37
|
+
- [Integrating](./docs/integrating/index.md): Wiring the stylesheet into Next.js, Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
95
38
|
- [Accessibility](./docs/accessibility.md): CSS accessibility hooks and non-goals.
|
|
96
39
|
|
|
97
40
|
## Requirements
|
|
@@ -105,169 +48,147 @@ also importable on its own from `@codenhub/styles/aesthetics/<name>`.
|
|
|
105
48
|
|
|
106
49
|
## Notes
|
|
107
50
|
|
|
108
|
-
This package has no JavaScript behavior. `--layout-gap` replaces the removed
|
|
109
|
-
`--layout-stack-gap` and `--layout-cluster-gap` tokens; no compatibility aliases
|
|
110
|
-
are provided.
|
|
51
|
+
This package has no JavaScript behavior. `--layout-gap` replaces the removed `--layout-stack-gap` and `--layout-cluster-gap` tokens, and `--color-text-subtle` is removed because nothing read it; no compatibility aliases are provided.
|
|
111
52
|
|
|
112
53
|
## License
|
|
113
54
|
|
|
114
|
-
Licensed under Apache-2.0. Embedded SVG icons derived from
|
|
115
|
-
[Lucide](https://lucide.dev) are ISC-licensed, and loaders derived from
|
|
116
|
-
[svg-spinners](https://github.com/n3r4zzurr0/svg-spinners) are MIT-licensed.
|
|
117
|
-
See [NOTICE](NOTICE) for the required notices.
|
|
55
|
+
Licensed under Apache-2.0. Embedded SVG icons derived from [Lucide](https://lucide.dev) are ISC-licensed, and loaders derived from [svg-spinners](https://github.com/n3r4zzurr0/svg-spinners) are MIT-licensed. See [NOTICE](NOTICE) for the required notices.
|
|
118
56
|
|
|
119
57
|
<!-- Source: docs/index.md -->
|
|
120
58
|
|
|
121
59
|
# @codenhub/styles
|
|
122
60
|
|
|
123
|
-
`@codenhub/styles` is a CSS-only design system: tokens, a reset, typography and
|
|
124
|
-
layout utilities, and composable classes for buttons, forms, feedback,
|
|
125
|
-
surfaces, and tooltips. Every component separates three independent choices —
|
|
126
|
-
which color, how much of it, and what it's made of — so changing one never
|
|
127
|
-
requires a component-specific variant. Four optional aesthetics
|
|
128
|
-
(`.neobrutalism`, `.glass`, `.pixel`, `.chunky-tile`) restyle that same
|
|
129
|
-
component set without touching markup.
|
|
61
|
+
`@codenhub/styles` is a CSS-only design system: tokens, a reset, typography and layout utilities, and composable classes for buttons, forms, feedback, surfaces, and tooltips. Every component separates three independent choices — which color, how much of it, and what it's made of — so changing one never requires a component-specific variant. Four optional aesthetics (`.neobrutalism`, `.glass`, `.pixel`, `.chunky-tile`) restyle that same component set without touching markup.
|
|
130
62
|
|
|
131
|
-
The package ships as ready-to-import compiled CSS, or as Tailwind CSS v4
|
|
132
|
-
source entrypoints for a project that already runs Tailwind. Both cover the
|
|
133
|
-
same classes; the difference is which build processes them.
|
|
63
|
+
The package ships as ready-to-import compiled CSS, or as Tailwind CSS v4 source entrypoints for a project that already runs Tailwind. Both cover the same classes; the difference is which build processes them.
|
|
134
64
|
|
|
135
65
|
## What it does
|
|
136
66
|
|
|
137
|
-
- Publishes color, foundation, intent, presentation, and material design
|
|
138
|
-
|
|
139
|
-
- Provides
|
|
140
|
-
|
|
141
|
-
- Provides
|
|
142
|
-
badges, loaders, progress, cards/panels, tables, quotes, code, and
|
|
143
|
-
tooltips.
|
|
144
|
-
- Provides four opt-in aesthetics that restyle the same components by setting
|
|
145
|
-
material tokens, not by adding component variants.
|
|
146
|
-
- Provides classless mappings so plain HTML elements pick up base styling
|
|
147
|
-
without added classes, from a dedicated entrypoint.
|
|
67
|
+
- Publishes color, foundation, intent, presentation, and material design tokens as CSS custom properties, themed with `light-dark()`.
|
|
68
|
+
- Provides a reset, focus-visible handling, and responsive layout/content utilities.
|
|
69
|
+
- Provides composable classes for buttons, form controls and toggles, alerts, badges, loaders, progress, cards/panels, tables, quotes, code, and tooltips.
|
|
70
|
+
- Provides four opt-in aesthetics that restyle the same components by setting material tokens, not by adding component variants.
|
|
71
|
+
- Provides classless mappings so plain HTML elements pick up base styling without added classes, from a dedicated entrypoint.
|
|
148
72
|
- Publishes Tailwind CSS v4 source entrypoints alongside the compiled output.
|
|
149
73
|
|
|
150
74
|
## What it does not do
|
|
151
75
|
|
|
152
|
-
- No JavaScript. There is no runtime, no framework bindings, and no build-time
|
|
153
|
-
|
|
154
|
-
- No
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
- No theme-toggling logic. Theme selection is a class or attribute a consumer
|
|
158
|
-
applies; wiring a toggle to system preference, storage, or a user setting is
|
|
159
|
-
outside this package. The `@codenhub/theme` package covers that need for
|
|
160
|
-
consumers who want it.
|
|
161
|
-
- No shipped font binaries. `.pixel` and `.chunky-tile` accept a
|
|
162
|
-
consumer-supplied font and fall back to a system stack when none is given.
|
|
163
|
-
- No compatibility layer for removed tokens or classes. Breaking changes are
|
|
164
|
-
documented, not silently aliased.
|
|
76
|
+
- No JavaScript. There is no runtime, no framework bindings, and no build-time code generation beyond the CSS itself.
|
|
77
|
+
- No semantic HTML, ARIA, keyboard behavior, focus management, validation, or announcement timing. See [Accessibility](docs/accessibility.md) for the exact line between what the CSS provides and what an application must still add.
|
|
78
|
+
- No theme-toggling logic. Theme selection is a class or attribute a consumer applies; wiring a toggle to system preference, storage, or a user setting is outside this package. The `@codenhub/theme` package covers that need for consumers who want it.
|
|
79
|
+
- No shipped font binaries. `.pixel` and `.chunky-tile` accept a consumer-supplied font and fall back to a system stack when none is given.
|
|
80
|
+
- No compatibility layer for removed tokens or classes. Breaking changes are documented, not silently aliased.
|
|
165
81
|
|
|
166
82
|
## Next steps
|
|
167
83
|
|
|
168
|
-
- [Setup](docs/setup.md): Install the package, choose an entrypoint, and render a
|
|
169
|
-
|
|
170
|
-
- [
|
|
171
|
-
|
|
172
|
-
- [
|
|
173
|
-
aesthetics, and each component family.
|
|
174
|
-
- [Integrating](docs/integrating/index.md): Wiring the stylesheet into Next.js,
|
|
175
|
-
Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
176
|
-
- [Accessibility](docs/accessibility.md): CSS accessibility hooks and what
|
|
177
|
-
remains an application responsibility.
|
|
84
|
+
- [Setup](docs/setup.md): Install the package, choose an entrypoint, and render a first component.
|
|
85
|
+
- [Concepts](docs/concepts.md): The three-axis model, the token system, and how theme selection works — read this before the usage guides.
|
|
86
|
+
- [Usage](docs/usage/index.md): Guides for composing axes, theming, customizing, aesthetics, and each component family.
|
|
87
|
+
- [Integrating](docs/integrating/index.md): Wiring the stylesheet into Next.js, Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
88
|
+
- [Accessibility](docs/accessibility.md): CSS accessibility hooks and what remains an application responsibility.
|
|
178
89
|
|
|
179
|
-
<!-- Source: docs/
|
|
90
|
+
<!-- Source: docs/setup.md -->
|
|
180
91
|
|
|
181
|
-
#
|
|
92
|
+
# Setup
|
|
182
93
|
|
|
183
|
-
|
|
94
|
+
## Installation
|
|
184
95
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
189
|
-
| `:focus-visible` | Global focus-visible outline using `--focus-ring`, `--focus-ring-width`, and `--focus-ring-offset`. |
|
|
190
|
-
| Form control focus | `.ipt`, `.textarea`, and `.select` draw the global focus ring and move their line to the intent color. |
|
|
191
|
-
| Control boundaries | Text controls rest at `--_line-rest` of their intent, under 3:1 by choice; hover and focus take the tone whole. |
|
|
192
|
-
| Toggle boundaries | `.checkbox`, `.radio`, and `.switch` draw their line whole, because it is the only thing marking an unchecked box. |
|
|
193
|
-
| Cascaded `.edgeless` | Floored on every text control: a container cannot erase the line of a field or toggle nobody classed. |
|
|
194
|
-
| Own `.edgeless` | On the element, `.ipt`, `.textarea`, `.select`, and `.switch` do drop their line and do not meet 1.4.11 at rest. |
|
|
195
|
-
| `.checkbox`/`.radio` | Never drop their line, on the element or from a container. `.edgeless` on them is unsupported, not merely discouraged. |
|
|
196
|
-
| Invalid controls | `[aria-invalid="true"]` applies destructive border/focus color on form controls. |
|
|
197
|
-
| Disabled controls | `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]`, and `.disabled` apply disabled cursor/opacity where supported. |
|
|
198
|
-
| Current page | `[aria-current="page"]` applies primary color and stronger font weight. |
|
|
199
|
-
| Open state | `[data-state="open"]` styles supported surfaces and tooltips. |
|
|
200
|
-
| Reduced-motion loaders | Loader variants use animated embedded SVGs normally and static masks when `prefers-reduced-motion: reduce` matches. |
|
|
201
|
-
| Reduced-motion document | The reset additionally shortens document animations and transitions when `prefers-reduced-motion: reduce` matches. |
|
|
202
|
-
| Reduced transparency | `.glass` drops its blur and becomes an opaque surface when `prefers-reduced-transparency: reduce` matches. |
|
|
203
|
-
| Filled labels | Every intent's `.solid` label meets 1.4.3 (4.5:1) as normal text, in both themes. Lowest is success at 5.14:1. |
|
|
204
|
-
| Warning ink | `--color-warning-contrast` is the near-black tone, not the page tone. Amber dark enough to carry white is not amber. |
|
|
205
|
-
| Partial fills | Contrast ink appears only past a half fill, so a capped plate keeps `--intent-strong` rather than walking toward the page. |
|
|
206
|
-
| Intent hue in dark | `--intent-strong` is the `-300` shade in dark, so a soft or ghost label keeps its own hue instead of reading white. |
|
|
207
|
-
| Toggle marks | A checked mark meets 3:1 as a state indicator on every plate its fill class can paint, in both themes. |
|
|
208
|
-
| Forced colors | `forced-colors: active` preserves visible borders and checked states using system colors. |
|
|
209
|
-
| Text direction | Quote bar, alert icon, progress fill, vertical divider, and switch knob mirror under `dir="rtl"`. No class needed. |
|
|
210
|
-
|
|
211
|
-
The loader fallback is embedded in loader CSS, so focused imports that include
|
|
212
|
-
loaders honor reduced motion without the reset. This includes
|
|
213
|
-
`@codenhub/styles/components`, `@codenhub/styles/tw/components`,
|
|
214
|
-
`@codenhub/styles/tw/button`, and `@codenhub/styles/tw/loader`. The complete and
|
|
215
|
-
native entrypoints include both that fallback and the reset's broader animation
|
|
216
|
-
and transition shortening.
|
|
217
|
-
|
|
218
|
-
In forced colors, class-based form controls including `.text-control` receive a
|
|
219
|
-
2px `Highlight` system-color focus outline. The native entrypoint provides the
|
|
220
|
-
same visible system outline for unclassed text inputs, selects, textareas,
|
|
221
|
-
checkboxes, and radios.
|
|
222
|
-
|
|
223
|
-
Custom checkboxes and radios use the system `Canvas`, `CanvasText`, `Highlight`,
|
|
224
|
-
and `HighlightText` colors in forced-colors mode so checked and unchecked states
|
|
225
|
-
remain distinct. Shape, size, and spacing remain unchanged.
|
|
226
|
-
|
|
227
|
-
## Required Outside CSS
|
|
96
|
+
```sh
|
|
97
|
+
pnpm add @codenhub/styles
|
|
98
|
+
```
|
|
228
99
|
|
|
229
|
-
|
|
100
|
+
## Quick start
|
|
230
101
|
|
|
231
|
-
|
|
232
|
-
| ----------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
233
|
-
| Buttons | Use `<button>` for actions or accessible links for navigation. Add accessible names for `.btn.icon`. |
|
|
234
|
-
| Forms | Use labels, `type`, validation logic, `aria-describedby`, and error message relationships. |
|
|
235
|
-
| Alerts | Add `role="status"` or `role="alert"` based on announcement urgency. |
|
|
236
|
-
| Toasts | Add live-region behavior, dismissal behavior, focus rules, and pause/timeout logic when needed. |
|
|
237
|
-
| Tooltips | Provide accessible names/descriptions. CSS pseudo-element content is not enough for all assistive tech. |
|
|
238
|
-
| Progress | Use semantic progress elements or ARIA values when numeric progress must be announced. |
|
|
239
|
-
| Skeletons/loaders | Mark decorative loading visuals with `aria-hidden="true"` and expose loading state elsewhere when needed. |
|
|
240
|
-
| Popovers/modals | Provide focus trapping, escape handling, inert background behavior, labels, and roles outside this CSS package. |
|
|
102
|
+
Import the compiled stylesheet for the complete token, reset, utility, and component-class surface, then compose helper classes in markup:
|
|
241
103
|
|
|
242
|
-
|
|
104
|
+
```css
|
|
105
|
+
@import "@codenhub/styles";
|
|
106
|
+
```
|
|
243
107
|
|
|
244
|
-
|
|
108
|
+
```html
|
|
109
|
+
<main class="stack">
|
|
110
|
+
<p class="text-label">Status</p>
|
|
111
|
+
<h1 class="text-title">Ready to publish</h1>
|
|
112
|
+
<button class="btn primary">Continue</button>
|
|
113
|
+
</main>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The full stylesheet applies global reset and focus-visible rules, but does not apply the optional classless native-element mappings, and does not include aesthetics. Import focused entrypoints when global rules are not appropriate; see [Import paths](#import-paths) below.
|
|
117
|
+
|
|
118
|
+
Aesthetics are opt-in. Import the combined aesthetics stylesheet, or one aesthetic on its own, after the base stylesheet so its rules win:
|
|
119
|
+
|
|
120
|
+
```css
|
|
121
|
+
@import "@codenhub/styles";
|
|
122
|
+
@import "@codenhub/styles/aesthetics";
|
|
123
|
+
```
|
|
245
124
|
|
|
246
125
|
```html
|
|
247
|
-
<
|
|
248
|
-
<
|
|
126
|
+
<section class="neobrutalism">
|
|
127
|
+
<button class="btn primary">Thick ink and a hard shadow</button>
|
|
128
|
+
</section>
|
|
249
129
|
```
|
|
250
130
|
|
|
251
|
-
|
|
131
|
+
A project already running Tailwind CSS v4 imports the source entrypoint instead; see [Integrating → Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
132
|
+
|
|
133
|
+
## Configuration
|
|
134
|
+
|
|
135
|
+
The root follows the operating-system color-scheme preference. Apply `.light` or `.dark` to the root or any ancestor to force token values for that subtree. `.theme-light`, `.theme-dark`, and `data-theme="light|dark"` are aliases.
|
|
252
136
|
|
|
253
137
|
```html
|
|
254
|
-
<
|
|
255
|
-
<
|
|
138
|
+
<html class="dark">
|
|
139
|
+
<body>
|
|
140
|
+
<button class="btn primary">Dark themed button</button>
|
|
141
|
+
</body>
|
|
142
|
+
</html>
|
|
256
143
|
```
|
|
257
144
|
|
|
258
|
-
|
|
145
|
+
See [Concepts → Theme selection](docs/concepts.md#theme-selection) for how selectors resolve and [Usage → Theming](docs/usage/theming.md) for the full color token reference.
|
|
146
|
+
|
|
147
|
+
## Import paths
|
|
148
|
+
|
|
149
|
+
Compiled entrypoints are ready-to-import CSS and require only tooling that can resolve package CSS imports. `/tw` entrypoints publish copied, uncompiled source from `dist/tw`; a Tailwind v4 build must still process their `@theme`, `@utility`, `@apply`, and related directives. Focused source component entrypoints include theme tokens so their classes can work independently.
|
|
150
|
+
|
|
151
|
+
| Import path | Composition and effects |
|
|
152
|
+
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
|
+
| `@codenhub/styles` | Compiled complete surface: Tailwind base/theme output, tokens, typography, utilities, components, and reset. Applies global reset, root theme, and focus rules. |
|
|
154
|
+
| `@codenhub/styles/theme` | Compiled Tailwind theme variables, Codenhub tokens, and the presentation classes. Sets root theme properties and system/explicit theme selectors; no reset or component classes. |
|
|
155
|
+
| `@codenhub/styles/components` | Compiled theme tokens, typography utilities, and every component class. Includes static reduced-motion loader masks; no reset, layout/content utilities, or native mappings. |
|
|
156
|
+
| `@codenhub/styles/native` | Compiled complete surface plus classless mappings for headings, text, content elements, form controls, and buttons. Applies the reset and broad element selectors. |
|
|
157
|
+
| `@codenhub/styles/aesthetics` | Compiled `.neobrutalism`, `.glass`, `.pixel`, and `.chunky-tile` classes. Adds no tokens or components of its own; import after the base stylesheet. |
|
|
158
|
+
| `@codenhub/styles/aesthetics/*` | One compiled aesthetic: `/neobrutalism`, `/glass`, `/pixel`, or `/chunky-tile`. Same rules and ordering as the combined file. |
|
|
159
|
+
| `@codenhub/styles/tw` | Source equivalent of the complete stylesheet. Imports Tailwind itself, theme, typography, utilities, components, and reset; applies the same global rules. |
|
|
160
|
+
| `@codenhub/styles/tw/theme` | Source theme, tokens, and presentation classes. Imports Tailwind's theme layer; emits root/system/explicit theme selectors and defines the package's custom `dark:` variant. |
|
|
161
|
+
| `@codenhub/styles/tw/components` | Published Tailwind source for theme, typography, buttons, feedback, forms, loaders, surfaces, and tooltips, including static reduced-motion loader masks. No reset, layout/content utilities, or native mappings. |
|
|
162
|
+
| `@codenhub/styles/tw/surface` | Source theme plus `.surface`, `.card`, and `.panel`. |
|
|
163
|
+
| `@codenhub/styles/tw/button` | Published Tailwind source for theme and `.btn`, including its `.loading` state's mask application. Pair it with `/tw/loader` for `--loader-art` — the spinner artwork and its reduced-motion fallback — to resolve. |
|
|
164
|
+
| `@codenhub/styles/tw/form` | Source theme plus field, public `text-control`, input, textarea, select, checkbox, radio, and switch utilities. |
|
|
165
|
+
| `@codenhub/styles/tw/feedback` | Source theme plus alert, badge, skeleton, and progress utilities and their keyframes. |
|
|
166
|
+
| `@codenhub/styles/tw/loader` | Published Tailwind source for activity indicators and loaders, including static reduced-motion masks. It has no theme or reset side effects and uses `currentColor`. |
|
|
167
|
+
| `@codenhub/styles/tw/tooltip` | Source theme plus tooltip utilities. |
|
|
168
|
+
| `@codenhub/styles/tw/reset` | Source theme, typography utilities, and global reset/accessibility rules. It changes root/body/elements and selection, motion, focus, scrollbar, and forced colors. |
|
|
169
|
+
| `@codenhub/styles/tw/native` | Source complete surface plus reset and classless native-element mappings; broadest global effects. |
|
|
170
|
+
| `@codenhub/styles/tw/typography` | Source theme plus typography utilities; sets theme selectors but no reset or classless mappings. |
|
|
171
|
+
| `@codenhub/styles/tw/utilities` | Source theme and typography composition plus layout and content utilities; safelists the package utility names. |
|
|
172
|
+
| `@codenhub/styles/tw/aesthetics` | Source aesthetics, combined. `/tw/aesthetics/neobrutalism`, `/glass`, `/pixel`, and `/chunky-tile` publish one apiece. Plain CSS with no theme or reset side effects. |
|
|
173
|
+
|
|
174
|
+
Avoid importing overlapping entrypoints in the same build unless duplicate generated CSS is acceptable; pick the narrowest entrypoint that covers what a page needs.
|
|
175
|
+
|
|
176
|
+
## Requirements
|
|
177
|
+
|
|
178
|
+
- Consumer tooling must resolve package CSS imports.
|
|
179
|
+
- Chrome 123, Safari 17.5, or Firefox 121 and newer. Color tokens are declared with `light-dark()` and selected by `color-scheme` (Firefox 120), and `.input-group` propagates a nested control's invalid and disabled state with `:has()` (Firefox 121).
|
|
180
|
+
- Tailwind CSS 4 or newer is required only for `/tw` source entrypoints.
|
|
181
|
+
- The package has no JavaScript runtime. Apps must provide semantic HTML, ARIA, keyboard behavior, focus management, validation, and announcements; see [Accessibility](docs/accessibility.md).
|
|
259
182
|
|
|
260
183
|
<!-- Source: docs/concepts.md -->
|
|
261
184
|
|
|
262
185
|
# Concepts
|
|
263
186
|
|
|
264
|
-
Read this before the usage guides. It explains the mental model every
|
|
265
|
-
component, token, and class in this package shares.
|
|
187
|
+
Read this before the usage guides. It explains the mental model every component, token, and class in this package shares.
|
|
266
188
|
|
|
267
189
|
## The three axes
|
|
268
190
|
|
|
269
|
-
Every component separates three independent choices, so each can change
|
|
270
|
-
without a component-specific variant:
|
|
191
|
+
Every component separates three independent choices, so each can change without a component-specific variant:
|
|
271
192
|
|
|
272
193
|
| Axis | Question | Classes | Inheritance |
|
|
273
194
|
| ------------ | --------------- | ----------------------------------------------------------------------------------------- | ------------ |
|
|
@@ -282,25 +203,16 @@ without a component-specific variant:
|
|
|
282
203
|
</section>
|
|
283
204
|
```
|
|
284
205
|
|
|
285
|
-
Intent stays on the component so a semantic container cannot accidentally
|
|
286
|
-
recolor nested controls. Presentation and aesthetic cascade from a container;
|
|
287
|
-
putting either class directly on a component overrides the inherited choice.
|
|
288
|
-
Components apply documented clamps when an axis would remove an essential edge
|
|
289
|
-
or overwhelm compact geometry.
|
|
206
|
+
Intent stays on the component so a semantic container cannot accidentally recolor nested controls. Presentation and aesthetic cascade from a container; putting either class directly on a component overrides the inherited choice. Components apply documented clamps when an axis would remove an essential edge or overwhelm compact geometry.
|
|
290
207
|
|
|
291
|
-
The maintained contract is the intersection of the combinations documented in
|
|
292
|
-
[Usage](docs/usage/index.md) and demonstrated by the playground. Undocumented and
|
|
293
|
-
undemonstrated combinations may produce CSS but are not supported behavior.
|
|
208
|
+
The maintained contract is the intersection of the combinations documented in [Usage](docs/usage/index.md) and demonstrated by the playground. Undocumented and undemonstrated combinations may produce CSS but are not supported behavior.
|
|
294
209
|
|
|
295
|
-
- [Usage → Composing](docs/usage/composing.md) shows how the three axes combine
|
|
296
|
-
|
|
297
|
-
- [Usage → Aesthetics](docs/usage/aesthetics.md) covers each aesthetic and its
|
|
298
|
-
documented exceptions in depth.
|
|
210
|
+
- [Usage → Composing](docs/usage/composing.md) shows how the three axes combine on each component, with the full axis-support matrix.
|
|
211
|
+
- [Usage → Aesthetics](docs/usage/aesthetics.md) covers each aesthetic and its documented exceptions in depth.
|
|
299
212
|
|
|
300
213
|
## The token system
|
|
301
214
|
|
|
302
|
-
Tokens are CSS custom properties, grouped by what they control rather than
|
|
303
|
-
where they're used:
|
|
215
|
+
Tokens are CSS custom properties, grouped by what they control rather than where they're used:
|
|
304
216
|
|
|
305
217
|
| Category | Controls | Reference |
|
|
306
218
|
| ------------ | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
@@ -311,369 +223,496 @@ where they're used:
|
|
|
311
223
|
| Material | What a component is made of — radius, border width, shadow geometry, translucency. | [Usage → Customizing](docs/usage/customizing.md#material-tokens) |
|
|
312
224
|
| Aesthetic | Per-aesthetic knobs such as `--pixel-unit` or `--tile-lift`. | [Usage → Customizing](docs/usage/customizing.md#aesthetic-tokens) |
|
|
313
225
|
|
|
314
|
-
Color and foundation tokens are the ones most apps touch first, to match a
|
|
315
|
-
brand palette or spacing scale. Intent, presentation, and material tokens are
|
|
316
|
-
lower-level: components read them, and only presentation classes, aesthetic
|
|
317
|
-
classes, or a consumer override should set them.
|
|
226
|
+
Color and foundation tokens are the ones most apps touch first, to match a brand palette or spacing scale. Intent, presentation, and material tokens are lower-level: components read them, and only presentation classes, aesthetic classes, or a consumer override should set them.
|
|
318
227
|
|
|
319
228
|
## Theme selection
|
|
320
229
|
|
|
321
|
-
The root follows the operating-system `color-scheme` preference until an
|
|
322
|
-
explicit selector overrides it.
|
|
230
|
+
The root follows the operating-system `color-scheme` preference until an explicit selector overrides it.
|
|
323
231
|
|
|
324
232
|
| Theme | Equivalent selectors |
|
|
325
233
|
| ----- | ------------------------------------------------ |
|
|
326
234
|
| Light | `.light`, `.theme-light`, `[data-theme="light"]` |
|
|
327
235
|
| Dark | `.dark`, `.theme-dark`, `[data-theme="dark"]` |
|
|
328
236
|
|
|
329
|
-
- Theme selectors set `color-scheme` and nothing else. Because `color-scheme`
|
|
330
|
-
|
|
331
|
-
-
|
|
332
|
-
|
|
333
|
-
-
|
|
334
|
-
|
|
335
|
-
- A nested explicit selector overrides an inherited theme, so the nearest
|
|
336
|
-
themed ancestor controls that subtree at any depth.
|
|
337
|
-
- If conflicting light and dark selectors are placed on the same element, the
|
|
338
|
-
dark declaration wins because it appears later with equal specificity. Do
|
|
339
|
-
not rely on this conflict behavior; apply one theme per element.
|
|
340
|
-
- Component colors resolve from tokens or `currentColor`, so they follow the
|
|
341
|
-
theme without separate dark-variant rules, with no exception: every glyph
|
|
342
|
-
the package draws is a `currentColor` mask. Icon artwork a consumer brings
|
|
343
|
-
is theirs to theme.
|
|
344
|
-
|
|
345
|
-
Setting `color-scheme` yourself on an element also re-themes the tokens below
|
|
346
|
-
it, because that is the only signal the palette reads. This also themes native
|
|
347
|
-
UI such as scrollbars and form-control internals to match.
|
|
348
|
-
|
|
349
|
-
This mechanism works from Chrome 123, Safari 17.5, and Firefox 120; the package
|
|
350
|
-
overall requires Firefox 121 for `:has()` (see [Setup](docs/setup.md#requirements)).
|
|
351
|
-
|
|
352
|
-
<!-- Source: docs/integrating/astro.md -->
|
|
237
|
+
- Theme selectors set `color-scheme` and nothing else. Because `color-scheme` inherits, a selector themes its entire subtree.
|
|
238
|
+
- With no explicit selector, `:root` uses `color-scheme: light dark`, so the system preference decides.
|
|
239
|
+
- A theme selector on `:root` overrides the system preference in either direction.
|
|
240
|
+
- A nested explicit selector overrides an inherited theme, so the nearest themed ancestor controls that subtree at any depth.
|
|
241
|
+
- If conflicting light and dark selectors are placed on the same element, the dark declaration wins because it appears later with equal specificity. Do not rely on this conflict behavior; apply one theme per element.
|
|
242
|
+
- Component colors resolve from tokens or `currentColor`, so they follow the theme without separate dark-variant rules, with no exception: every glyph the package draws is a `currentColor` mask. Icon artwork a consumer brings is theirs to theme.
|
|
353
243
|
|
|
354
|
-
|
|
244
|
+
Setting `color-scheme` yourself on an element also re-themes the tokens below it, because that is the only signal the palette reads. This also themes native UI such as scrollbars and form-control internals to match.
|
|
355
245
|
|
|
356
|
-
|
|
357
|
-
uses that layout loads it once:
|
|
246
|
+
This mechanism works from Chrome 123, Safari 17.5, and Firefox 120; the package overall requires Firefox 121 for `:has()` (see [Setup](docs/setup.md#requirements)).
|
|
358
247
|
|
|
359
|
-
|
|
360
|
-
---
|
|
361
|
-
// src/layouts/Layout.astro
|
|
362
|
-
import "@codenhub/styles";
|
|
363
|
-
---
|
|
248
|
+
<!-- Source: docs/usage/index.md -->
|
|
364
249
|
|
|
365
|
-
|
|
366
|
-
<body>
|
|
367
|
-
<slot />
|
|
368
|
-
</body>
|
|
369
|
-
</html>
|
|
370
|
-
```
|
|
250
|
+
# Usage
|
|
371
251
|
|
|
372
|
-
|
|
373
|
-
the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
252
|
+
These guides assume the [Concepts](docs/concepts.md) mental model: intent, presentation, and aesthetic as three independent axes, resolved through tokens a component reads.
|
|
374
253
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
254
|
+
- [Composing](docs/usage/composing.md): Combining the three axes on a component, the axis-support matrix, and elevation modifiers.
|
|
255
|
+
- [Theming](docs/usage/theming.md): The color, intent, and foundation token reference.
|
|
256
|
+
- [Customizing](docs/usage/customizing.md): The presentation and material token reference, aesthetic knobs, and defining a custom intent.
|
|
257
|
+
- [Aesthetics](docs/usage/aesthetics.md): Each shipped aesthetic in depth, including its documented exceptions.
|
|
258
|
+
- [Buttons](docs/usage/buttons.md)
|
|
259
|
+
- [Forms](docs/usage/forms.md)
|
|
260
|
+
- [Feedback](docs/usage/feedback.md)
|
|
261
|
+
- [Tooltips](docs/usage/tooltips.md)
|
|
262
|
+
- [Content and layout](docs/usage/content-and-layout.md): Layout helpers, tables, quotes, code, surfaces, and typography utilities.
|
|
378
263
|
|
|
379
|
-
|
|
264
|
+
## Supported surface
|
|
380
265
|
|
|
381
|
-
|
|
266
|
+
A class, component, and axis combination is supported when this documentation describes it and the package playground demonstrates it. Undocumented and undemonstrated combinations may still produce CSS, but are not maintained behavior. Playground variant matrices are the exhaustive demonstrations; small examples elsewhere illustrate usage without widening that contract.
|
|
382
267
|
|
|
383
|
-
|
|
384
|
-
[Introduction](docs/index.md#what-it-does-not-do). Integrating it into a
|
|
385
|
-
framework is entirely about where that framework loads a global stylesheet,
|
|
386
|
-
and whether the project runs Tailwind CSS v4.
|
|
268
|
+
<!-- Source: docs/usage/composing.md -->
|
|
387
269
|
|
|
388
|
-
|
|
270
|
+
# Composing the three axes
|
|
389
271
|
|
|
390
|
-
|
|
391
|
-
`@codenhub/styles` for any build, or `@codenhub/styles/tw` when the
|
|
392
|
-
project already runs Tailwind CSS v4 — from wherever that framework loads
|
|
393
|
-
global CSS.
|
|
394
|
-
2. Import `@codenhub/styles/aesthetics` (or `/tw/aesthetics`) after it, only
|
|
395
|
-
if the project uses an [aesthetic](docs/usage/aesthetics.md).
|
|
272
|
+
See [Concepts](docs/concepts.md#the-three-axes) for what each axis means. This page covers how they combine in markup, what the presentation classes mean in depth, which components support which axis, and elevation.
|
|
396
273
|
|
|
397
|
-
|
|
398
|
-
| ---------------------------------------- | -------------------------------- |
|
|
399
|
-
| A Tailwind CSS v4 project on any bundler | [Tailwind CSS v4](docs/integrating/tailwind.md) |
|
|
400
|
-
| Next.js / React | [Next.js](docs/integrating/nextjs.md) |
|
|
401
|
-
| Vue | [Vue](docs/integrating/vue.md) |
|
|
402
|
-
| Svelte / SvelteKit | [Svelte](docs/integrating/svelte.md) |
|
|
403
|
-
| Astro | [Astro](docs/integrating/astro.md) |
|
|
274
|
+
## Combining axes
|
|
404
275
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
276
|
+
```html
|
|
277
|
+
<div class="soft">
|
|
278
|
+
<button class="btn primary">Soft primary button</button>
|
|
279
|
+
<span class="badge success">Soft success badge</span>
|
|
280
|
+
<button class="btn primary ghost edged">Outlined; the element wins</button>
|
|
281
|
+
</div>
|
|
282
|
+
```
|
|
408
283
|
|
|
409
|
-
|
|
284
|
+
A declaration on the element always beats one inherited from a container, so a container sets the default look for its subtree and any element opts out.
|
|
410
285
|
|
|
411
|
-
#
|
|
286
|
+
Intent classes do not cascade. `.primary` and its siblings stay on the element that shows the intent, because a container silently recoloring every descendant is a trap rather than a feature — see [Theming → Intent tokens](docs/usage/theming.md#intent-tokens). Use `.neutral` to opt an element back out of an inherited intent context. Presentation and [material tokens](docs/usage/customizing.md#material-tokens) do cascade, so a container can set the look of its whole subtree while any element overrides it.
|
|
412
287
|
|
|
413
|
-
|
|
414
|
-
package from the root layout in the App Router, or from the custom App in
|
|
415
|
-
the Pages Router — not from a page or component further down the tree.
|
|
288
|
+
## Presentation
|
|
416
289
|
|
|
417
|
-
|
|
418
|
-
// app/layout.tsx
|
|
419
|
-
import "@codenhub/styles";
|
|
290
|
+
Presentation has two independent axes. `.solid`, `.soft`, and `.ghost` decide how much intent fills a component; `.edged` and `.edgeless` decide whether it draws a boundary. They set [presentation tokens](docs/usage/customizing.md#presentation-tokens) and nothing else, so they work on the component itself or on any ancestor.
|
|
420
291
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
```
|
|
292
|
+
| Class | Look |
|
|
293
|
+
| ----------- | ---------------------------------------------------------- |
|
|
294
|
+
| `.solid` | Intent-colored fill with contrast text. |
|
|
295
|
+
| `.soft` | Lightly tinted fill with intent-colored text. |
|
|
296
|
+
| `.ghost` | No fill at rest, with intent-colored text. |
|
|
297
|
+
| `.edged` | Intent-colored boundary at the aesthetic's material width. |
|
|
298
|
+
| `.edgeless` | No boundary. |
|
|
429
299
|
|
|
430
|
-
|
|
431
|
-
// pages/_app.tsx
|
|
432
|
-
import "@codenhub/styles";
|
|
433
|
-
import type { AppProps } from "next/app";
|
|
300
|
+
Values each class ships:
|
|
434
301
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
302
|
+
| Class | `--ui-fill` | `--ui-fg-on-fill` | `--ui-border` |
|
|
303
|
+
| ----------- | ----------- | ----------------- | ------------- |
|
|
304
|
+
| `.solid` | `100%` | `100%` | |
|
|
305
|
+
| `.soft` | `12%` | `0%` | |
|
|
306
|
+
| `.ghost` | `0%` | `0%` | |
|
|
307
|
+
| `.edged` | | | `100%` |
|
|
308
|
+
| `.edgeless` | | | `0%` |
|
|
439
309
|
|
|
440
|
-
|
|
441
|
-
the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
310
|
+
The combinations mean exactly what they spell:
|
|
442
311
|
|
|
443
|
-
```
|
|
444
|
-
<
|
|
312
|
+
```html
|
|
313
|
+
<button class="btn primary">Solid, the button default</button>
|
|
314
|
+
<button class="btn soft edged">Tinted with a border</button>
|
|
315
|
+
<button class="btn primary ghost edged">Outline</button>
|
|
316
|
+
<button class="btn ghost">Ghost; picks up a tint on hover</button>
|
|
317
|
+
<input class="ipt soft edgeless" />
|
|
318
|
+
<!-- A field sunk into the page -->
|
|
445
319
|
```
|
|
446
320
|
|
|
447
|
-
A
|
|
448
|
-
same file instead; see [Tailwind CSS v4](docs/integrating/tailwind.md) for the `@source`
|
|
449
|
-
directive Next.js needs to scan its own `app`/`src` directories.
|
|
321
|
+
A fill class never decides an edge and an edge class never decides a fill. Use `.solid.edgeless` for a filled box with no line — and prefer it on a neutral one, because a capped fill leaves the box translucent and the edge blend then paints a second coat of the same tint rather than disappearing into it (measured 1.53:1 against its own plate in light, 1.82:1 in dark).
|
|
450
322
|
|
|
451
|
-
|
|
323
|
+
The edge is the silhouette and nothing else. Rules _inside_ a component that has an inside are a separate switch — see [Content and layout → Table rules](docs/usage/content-and-layout.md#table-rules) — because tying them to this axis made them arrive by implication rather than by request.
|
|
452
324
|
|
|
453
|
-
|
|
325
|
+
With no presentation class in scope, each component keeps its own default: buttons are filled, alerts and badges are tinted, surfaces and controls are neutral and bordered.
|
|
454
326
|
|
|
455
|
-
|
|
456
|
-
|
|
327
|
+
| Component | Reads |
|
|
328
|
+
| ----------------------------------------------- | ------------------------------------------- |
|
|
329
|
+
| `.btn`, `.alert`, `.badge`, `.card`, `.panel` | Fill, text, border, and border width. |
|
|
330
|
+
| `.kbd` | Fill, text, border, and border width. |
|
|
331
|
+
| `.data-table` | Header fill and text, border, border width. |
|
|
332
|
+
| `.ipt`, `.textarea`, `.select`, `.text-control` | Border, border width, and a capped fill. |
|
|
333
|
+
| `.input-group` | Border, border width, and a capped fill. |
|
|
334
|
+
| `.checkbox`, `.radio` | A capped fill, checked and unchecked. |
|
|
335
|
+
| `.switch` | Border, border width, and a capped fill. |
|
|
336
|
+
| `.quote` | Fill, text, border, and width. |
|
|
337
|
+
| `.code`, `.pre`, `.tooltip` | Fill, text, border, and material. |
|
|
338
|
+
| `.loader`, `.skeleton`, `.progress`, `.divider` | Intent only, not presentation. |
|
|
457
339
|
|
|
458
|
-
|
|
459
|
-
<!-- src/routes/+layout.svelte -->
|
|
460
|
-
<script>
|
|
461
|
-
import "@codenhub/styles";
|
|
462
|
-
let { children } = $props();
|
|
463
|
-
</script>
|
|
340
|
+
Text controls and toggles cap a **cascaded** fill at `6%`, keeping typed text legible when a `.solid` container reaches a field nobody classed. A fill class written on the control itself names its own cap instead, because that is a consumer describing what they want: `.soft` takes `12%` and `.solid` takes `20%`. A switch caps at `40%`, where its three fills separate far enough to read on a track.
|
|
464
341
|
|
|
465
|
-
|
|
466
|
-
|
|
342
|
+
| On a text control | fill |
|
|
343
|
+
| ----------------- | ---- |
|
|
344
|
+
| `.ghost` | 0% |
|
|
345
|
+
| cascaded `.solid` | 6% |
|
|
346
|
+
| `.soft` | 12% |
|
|
347
|
+
| `.solid` | 20% |
|
|
467
348
|
|
|
468
|
-
|
|
349
|
+
The same split governs the edge: a cascaded `.edgeless` is floored and the element's own is honoured — except on `.checkbox` and `.radio`, which never drop their line at all. See [Forms](docs/usage/forms.md) for the full toggle and text control reference.
|
|
469
350
|
|
|
470
|
-
|
|
471
|
-
// main.ts
|
|
472
|
-
import "@codenhub/styles";
|
|
473
|
-
import { mount } from "svelte";
|
|
474
|
-
import App from "./App.svelte";
|
|
351
|
+
A tooltip bubble is filled, over a tinted ground. An intent fills it with that intent's own color: `.tooltip.primary` is the primary color, black on a light page and white on a dark one, and `.tooltip.destructive` is a red bubble.
|
|
475
352
|
|
|
476
|
-
|
|
477
|
-
```
|
|
353
|
+
With no intent the bubble is `--color-tooltip`, the one plate in the package chosen per theme rather than derived from an intent. Composed like everything else it was `20%` of the page's ink over the surface tone, which steps _lighter_ than the surface on a dark page and _darker_ on a light one — so the dark bubble read as lifted and the light one as a mid-grey slab two steps darker than every card on the screen. The token states each direction instead: near-white over a light page, a mid grey over a dark one. `--color-tooltip-contrast` is its ink.
|
|
478
354
|
|
|
479
|
-
|
|
480
|
-
force a theme instead of following the system preference; see
|
|
481
|
-
[Setup → Configuration](docs/setup.md#configuration).
|
|
355
|
+
Near-white is only 1.04:1 against a light page, so the bubble draws a hairline as well, and floors it: a container's `.solid` or `.edgeless` cannot take the boundary away from a bubble nobody classed, while `.tooltip.edgeless` still can. The ground keeps the bubble opaque at every fill, so a cascaded presentation leaves it readable over whatever it floats above. It reads the material tokens too, so an [aesthetic](docs/usage/aesthetics.md) in scope shapes the bubble like any other component. See [Tooltips](docs/usage/tooltips.md) for the full tooltip reference.
|
|
482
356
|
|
|
483
|
-
|
|
484
|
-
app's CSS entry instead; see [Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
357
|
+
## Component axis reference
|
|
485
358
|
|
|
486
|
-
|
|
359
|
+
This table is the authoritative axis map for demonstrated components. "Shape" means the component reads applicable radius, border-width, shadow, hover, or clip/edge material tokens; an aesthetic may intentionally affect only the materials that component draws.
|
|
487
360
|
|
|
488
|
-
|
|
361
|
+
Presentation is two independent axes, so they get a column each. A `Yes` means the class changes what the component computes, which `tests/browser/axes.spec.ts` asserts against `registry.json` in both directions: an axis marked `Yes` must move, and an axis marked `No` must not.
|
|
489
362
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
363
|
+
| Components | Intent | Fill | Edge | Aesthetic material |
|
|
364
|
+
| --------------------------------------------------------- | ------ | ---- | ---- | ------------------ |
|
|
365
|
+
| `.btn`, `.alert`, `.badge`, `.card`, `.panel` | Yes | Yes | Yes | Shape |
|
|
366
|
+
| `.loader` | Yes | No | No | No |
|
|
367
|
+
| `.kbd`, `.data-table` | Yes | Yes | Yes | Radius and edge |
|
|
368
|
+
| `.quote` | Yes | Yes | Yes | Edge width |
|
|
369
|
+
| `.divider`, `.skeleton` | Yes | No | No | No |
|
|
370
|
+
| `.ipt`, `.textarea`, `.select`, `.text-control` | Yes | Yes | Yes | Shape |
|
|
371
|
+
| `.input-group` | Yes | Yes | Yes | Shape |
|
|
372
|
+
| `.surface` | Yes | Yes | Yes | Shape |
|
|
373
|
+
| `.checkbox`, `.radio` | Yes | Yes | No | Radius and edge |
|
|
374
|
+
| `.switch` | Yes | Yes | Yes | Radius and edge |
|
|
375
|
+
| `.progress` | Yes | No | No | No |
|
|
376
|
+
| `.code`, `.pre` | Yes | Yes | Yes | Radius and clip |
|
|
377
|
+
| `.tooltip` | Yes | Yes | Yes | Shape and overlay |
|
|
378
|
+
| `.table-wrap`, `.quote-inline`, layout and text utilities | No | No | No | No |
|
|
495
379
|
|
|
496
|
-
|
|
497
|
-
@import "tailwindcss";
|
|
498
|
-
@import "@codenhub/styles/tw";
|
|
380
|
+
`.checkbox` and `.radio` are the only components that read one axis and not the other. Their line is the only thing marking an unchecked box, so it is drawn whatever the edge class says, from a container or from the element itself. `.edgeless` on either is unsupported rather than merely discouraged.
|
|
499
381
|
|
|
500
|
-
|
|
501
|
-
```
|
|
382
|
+
Every other text control floors a _cascaded_ `.edgeless` and honours its own: a `.edgeless` toolbar will not erase the line of a field nobody classed, while `.ipt.edgeless` is a consumer describing what they want and gets it.
|
|
502
383
|
|
|
503
|
-
|
|
504
|
-
class names actually used in your markup, so it can generate only what is
|
|
505
|
-
referenced. Point it at your app's source, not at this package — `/tw`
|
|
506
|
-
already ships every class definition it publishes.
|
|
384
|
+
Intent aliases such as `.danger` and `.error` occupy the same intent axis as `.destructive`; they do not add component behavior. State and modifier classes such as `.interactive`, `.hoverable`, `.pressable`, `.loading`, `.invalid`, `.compact`, and `.vertical` sit above this map and are documented with their component.
|
|
507
385
|
|
|
508
|
-
|
|
509
|
-
after the base import:
|
|
386
|
+
## Elevation
|
|
510
387
|
|
|
511
|
-
|
|
512
|
-
@import "tailwindcss";
|
|
513
|
-
@import "@codenhub/styles/tw";
|
|
514
|
-
@import "@codenhub/styles/tw/aesthetics";
|
|
388
|
+
Depth is a modifier, not an axis. Nothing is raised until an [aesthetic](docs/usage/aesthetics.md) draws depth or one of these classes asks for it.
|
|
515
389
|
|
|
516
|
-
|
|
517
|
-
|
|
390
|
+
| Class | Alias | Depth |
|
|
391
|
+
| ----------------- | ----------- | ------------------------------------------------------------------------ |
|
|
392
|
+
| `.elevation-none` | `.flat` | Removes part-based elevation; glass surfaces keep their complete shadow. |
|
|
393
|
+
| `.elevation-sm` | `.raised` | One unit of the depth in scope. Cards, tiles, popovers that sit close. |
|
|
394
|
+
| `.elevation-md` | `.floating` | Twice it, for menus and popovers. |
|
|
518
395
|
|
|
519
|
-
|
|
520
|
-
`/tw/button` or `/tw/form` — when a build only needs one component family;
|
|
521
|
-
see the full [import path table](docs/setup.md#import-paths) for what each one
|
|
522
|
-
composes. Tailwind CSS 4 or newer is required for every `/tw` entrypoint.
|
|
396
|
+
Both names in a row are equivalent, interchangeable classes — `.elevation-sm` and `.raised` are aliases, not a canonical form and a deprecated one, the way `.destructive` and `.danger` are on the intent axis. The `none`/`sm`/`md` naming matches the raw `--elevation-*` tokens in [Theming](docs/usage/theming.md#foundation-tokens) for the same weight of depth, even though the two are read from different places.
|
|
523
397
|
|
|
524
|
-
|
|
398
|
+
Each is one unitless multiplier over whatever shadow geometry is in scope, so the same class reads as a soft blur on a plain page and as a hard offset slab under `.neobrutalism` — the aesthetic decides what depth looks like, the class decides how much of it this element takes.
|
|
525
399
|
|
|
526
|
-
|
|
400
|
+
```html
|
|
401
|
+
<article class="card elevation-sm">Lifted</article>
|
|
402
|
+
<div class="elevation-md panel">A menu surface</div>
|
|
403
|
+
<article class="card elevation-none">Flat, whatever the page or container says</article>
|
|
404
|
+
```
|
|
527
405
|
|
|
528
|
-
|
|
406
|
+
The multiplier is a plain number, so it inherits: a container lifts or flattens a whole region and any element inside it still opts out on itself. Spread is deliberately left out of the multiplication, because an aesthetic that draws its edge as an inset ring spends spread on it and scaling that would erase the edge.
|
|
529
407
|
|
|
530
|
-
|
|
531
|
-
// main.ts
|
|
532
|
-
import "@codenhub/styles";
|
|
533
|
-
import { createApp } from "vue";
|
|
534
|
-
import App from "./App.vue";
|
|
408
|
+
<!-- Source: docs/usage/theming.md -->
|
|
535
409
|
|
|
536
|
-
|
|
410
|
+
# Theming
|
|
411
|
+
|
|
412
|
+
Color tokens are how you restyle the palette; see [Concepts → Theme selection](docs/concepts.md#theme-selection) for how a theme is chosen. Intent tokens are how a component reads that palette once an intent class is applied. Foundation tokens are the shared layout, shape, and motion defaults underneath everything.
|
|
413
|
+
|
|
414
|
+
## Color tokens
|
|
415
|
+
|
|
416
|
+
Each color token holds both of its theme values at once through `light-dark()`, and the element's `color-scheme` picks one.
|
|
417
|
+
|
|
418
|
+
Every row is an override point: set it on `:root` to retheme globally, or on any element to retheme that subtree. The `-hover`, `-subtle`, `-strong`, and `-contrast` rows are companion tones wired into the intent slots, so overriding a base color such as `--color-primary` on its own does not shift its companions — retheme the whole family. The `text` family has no `-subtle` row: the neutral intent draws its subtle tone from `--color-surface`.
|
|
419
|
+
|
|
420
|
+
```html
|
|
421
|
+
<section data-theme="dark">
|
|
422
|
+
<article>Dark token subtree</article>
|
|
423
|
+
</section>
|
|
537
424
|
```
|
|
538
425
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
426
|
+
| Token | Purpose |
|
|
427
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
428
|
+
| `--color-primary` | Primary action/content color. |
|
|
429
|
+
| `--color-primary-contrast` | Text/icon color on primary filled surface. |
|
|
430
|
+
| `--color-primary-hover` | Primary hover state. |
|
|
431
|
+
| `--color-primary-subtle` | Low-emphasis companion tone for primary. Use as soft surface or subtle background. |
|
|
432
|
+
| `--color-primary-strong` | High-emphasis companion tone for primary. Use as readable text, icon, or border on subtle surfaces. |
|
|
433
|
+
| `--color-accent` | Secondary/accent surface. |
|
|
434
|
+
| `--color-accent-contrast` | Text/icon color on accent filled surface. |
|
|
435
|
+
| `--color-accent-hover` | Accent hover state. |
|
|
436
|
+
| `--color-accent-subtle` | Low-emphasis companion tone for accent. Use as soft surface or subtle background. |
|
|
437
|
+
| `--color-accent-strong` | High-emphasis companion tone for accent. Use as readable text, icon, or border on subtle surfaces. |
|
|
438
|
+
| `--color-border` | Default border color. |
|
|
439
|
+
| `--color-border-hover` | Interactive border color. |
|
|
440
|
+
| `--color-control-border` | Resting line on the six text controls; one value, drawn at a fraction on text inputs. |
|
|
441
|
+
| `--color-background` | Page and default raised surface background. |
|
|
442
|
+
| `--color-foreground` | Subtle raised foreground surface. |
|
|
443
|
+
| `--color-surface` | Nested or muted surface. |
|
|
444
|
+
| `--color-text` | Primary text color. |
|
|
445
|
+
| `--color-text-secondary` | Secondary text color. |
|
|
446
|
+
| `--color-text-contrast` | Readable color on top of a full fill of `--color-text`. A checked toggle prints it. |
|
|
447
|
+
| `--color-text-hover` | Text hover state. |
|
|
448
|
+
| `--color-text-strong` | High-emphasis companion tone for text. Use as readable text, icon, or border on subtle surfaces. |
|
|
449
|
+
| `--color-tooltip` | Tooltip bubble plate with no intent. Chosen per theme rather than derived: near-white in light, mid grey in dark. |
|
|
450
|
+
| `--color-tooltip-contrast` | Ink on `--color-tooltip`. |
|
|
451
|
+
| `--color-success` | Success state color. |
|
|
452
|
+
| `--color-success-contrast` | Text/icon color on success filled surface. Meets 4.5:1 as normal text on `--color-success` (5.14:1). |
|
|
453
|
+
| `--color-success-hover` | Success hover tone. |
|
|
454
|
+
| `--color-success-subtle` | Low-emphasis companion tone for success. |
|
|
455
|
+
| `--color-success-strong` | High-emphasis companion tone for success. |
|
|
456
|
+
| `--color-warning` | Warning state color. |
|
|
457
|
+
| `--color-warning-contrast` | The near-black tone, not the page tone. Meets 4.5:1 as normal text on `--color-warning` (6.19:1). |
|
|
458
|
+
| `--color-warning-hover` | Warning hover tone. |
|
|
459
|
+
| `--color-warning-subtle` | Low-emphasis companion tone for warning. |
|
|
460
|
+
| `--color-warning-strong` | High-emphasis companion tone for warning. |
|
|
461
|
+
| `--color-destructive` | Destructive/error state color. |
|
|
462
|
+
| `--color-destructive-contrast` | Text/icon color on destructive filled surface. Meets 4.5:1 as normal text on `--color-destructive` (5.78:1). |
|
|
463
|
+
| `--color-destructive-hover` | Destructive hover tone. |
|
|
464
|
+
| `--color-destructive-subtle` | Low-emphasis companion tone for destructive. |
|
|
465
|
+
| `--color-destructive-strong` | High-emphasis companion tone for destructive. |
|
|
466
|
+
| `--color-info` | Informational state color. |
|
|
467
|
+
| `--color-info-contrast` | Text/icon color on info filled surface. Meets 4.5:1 as normal text on `--color-info` (6.19:1). |
|
|
468
|
+
| `--color-info-hover` | Info hover tone. |
|
|
469
|
+
| `--color-info-subtle` | Low-emphasis companion tone for info. |
|
|
470
|
+
| `--color-info-strong` | High-emphasis companion tone for info. |
|
|
471
|
+
|
|
472
|
+
> **Intent token contract**: color intent tokens own meaning and tone variants. Intent classes map one family onto the shared intent slots below, and presentation classes decide how much of it a component shows. Theme changes belong in token values, not broad component-level theme checks. Component-level theme handling should exist only when a component has an internal structure that cannot be expressed through the token palette alone.
|
|
542
473
|
|
|
543
|
-
|
|
544
|
-
entry file instead of `main.ts`, using the `@tailwindcss/vite` plugin; see
|
|
545
|
-
[Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
474
|
+
## Intent tokens
|
|
546
475
|
|
|
547
|
-
|
|
476
|
+
Intent classes set these seven slots; components read them. Because every supporting component reads the same seven names, an intent works on every component that supports intent, and a custom intent needs no component changes.
|
|
548
477
|
|
|
549
|
-
|
|
478
|
+
| Token | Purpose |
|
|
479
|
+
| ------------------- | ------------------------------------------------------------------------------------- |
|
|
480
|
+
| `--intent-color` | The intent's base color. What a fill is made of. |
|
|
481
|
+
| `--intent-contrast` | Readable color on top of a filled `--intent-color`. |
|
|
482
|
+
| `--intent-hover` | The intent's hovered base color. |
|
|
483
|
+
| `--intent-strong` | The intent printed on a page. Text, icon, or border wherever the fill is not full. |
|
|
484
|
+
| `--intent-subtle` | Low-emphasis tone. Tinted surfaces and tracks. Neutral resolves to `--color-surface`. |
|
|
485
|
+
| `--intent-border` | Line color. Resolves to `--color-border` when no intent is set. |
|
|
486
|
+
| `--intent-fill-max` | How far a fill of this intent is allowed to go. `100%` for every intent but neutral. |
|
|
550
487
|
|
|
551
|
-
|
|
488
|
+
`--intent-color` and `--intent-strong` are two ends of the same family and not interchangeable. The base is a ground, chosen to be filled with; the strong tone is chosen to be read against a page. A `.soft` or `.ghost` component prints the strong one, which is why an unfilled warning reads in amber-800 rather than the amber-600 its solid sibling is filled with.
|
|
552
489
|
|
|
553
|
-
|
|
554
|
-
pnpm add @codenhub/styles
|
|
555
|
-
```
|
|
490
|
+
The strong tone has to stay recognisably its own hue, not just readable. On a dark page the `-100` shade of every family is a pale tint that carries almost no chroma at small sizes: a soft success badge and a soft destructive one printed labels that both read white, and a soft radio's dot stopped matching the ring around it. The dark tones are `-300` for that reason, and the tinted grounds under them are `-900` so there is room — measured at 5.0:1 or better everywhere a partial fill prints text, and past 9:1 on the page.
|
|
556
491
|
|
|
557
|
-
|
|
492
|
+
`--intent-border` exists because a neutral border must stay the quiet border gray rather than the text color. Everything that draws a line reads it: control borders, table rules, dividers, key caps, and quote bars.
|
|
493
|
+
|
|
494
|
+
`--intent-fill-max` exists for the neutral intent, whose color is the page's own ink. Every other intent is a hue, legible pale at 12% and saturated at 100%; a grey filled to 100% is a black or white slab, which is the loudest thing on the page and the wrong look for the intent that means _nothing in particular_. Neutral stops at `20%`, so `.solid` gives it a quiet plate that still reads as a step past `.soft`. Hover adds its step on top of the cap, so a capped fill still deepens under the pointer.
|
|
495
|
+
|
|
496
|
+
The foreground is gated by the plate rather than tied to the fill. `--intent-contrast` is the ink for a _full_ fill, so printing it at full strength on a fifth of one puts white on light grey. Contrast ink therefore appears only once the fill is past halfway and reaches full at a full fill; below that a component prints `--intent-strong`, the tone chosen to be read.
|
|
558
497
|
|
|
559
|
-
|
|
560
|
-
|
|
498
|
+
That means a capped neutral takes the strong tone whole rather than a fraction of the way toward the page. Tying it to the fill instead cost a neutral `.solid` button four points of contrast and a neutral tooltip nearly ten. A state that lifts the cap on purpose — a checked checkbox is filled with its own intent by definition — reaches a full fill and gets the contrast whole.
|
|
499
|
+
|
|
500
|
+
Set them directly to define an intent this package does not ship. **State every slot**, including `--intent-fill-max`: components reset all seven to the neutral values, so a slot your intent leaves out keeps neutral's — and an intent that omits the cap fills to 20% of its color instead of 100%.
|
|
561
501
|
|
|
562
502
|
```css
|
|
563
|
-
|
|
503
|
+
.brand {
|
|
504
|
+
--intent-color: var(--color-violet-600);
|
|
505
|
+
--intent-contrast: var(--color-neutral-50);
|
|
506
|
+
--intent-hover: var(--color-violet-700);
|
|
507
|
+
--intent-strong: var(--color-violet-800);
|
|
508
|
+
--intent-subtle: var(--color-violet-100);
|
|
509
|
+
--intent-border: var(--color-violet-600);
|
|
510
|
+
--intent-fill-max: 100%;
|
|
511
|
+
}
|
|
564
512
|
```
|
|
565
513
|
|
|
566
514
|
```html
|
|
567
|
-
<
|
|
568
|
-
<p class="text-label">Status</p>
|
|
569
|
-
<h1 class="text-title">Ready to publish</h1>
|
|
570
|
-
<button class="btn primary">Continue</button>
|
|
571
|
-
</main>
|
|
515
|
+
<button class="btn brand">Custom intent</button> <span class="badge brand soft">Works everywhere</span>
|
|
572
516
|
```
|
|
573
517
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
518
|
+
> **Intent does not cascade.** Components reset these slots to the text palette at their own root, so a `.success` container never recolors a nested destructive button. Put the intent class on the element that shows the intent.
|
|
519
|
+
|
|
520
|
+
## Foundation tokens
|
|
521
|
+
|
|
522
|
+
Foundation tokens are not aliases for one color. They define layout, shape, motion, focus, depth, and layering behavior used by helper classes.
|
|
523
|
+
|
|
524
|
+
The four `--elevation-*` values below are raw shadows for elements you style yourself. They are a separate thing from `.elevation-none`/`.elevation-sm`/ `.elevation-md` (aliased as `.flat`/`.raised`/`.floating`), which scale a _component's own_ shadow geometry and default to no shadow at all until an aesthetic or one of those classes asks for depth — see [Composing → Elevation](docs/usage/composing.md#elevation) for that system. The two share `none`/`sm`/`md`/`lg` naming for the same weight of depth, but one is a fixed value and the other multiplies shadow parts, so they will not always paint identically.
|
|
525
|
+
|
|
526
|
+
| Token | Purpose |
|
|
527
|
+
| -------------------------- | ----------------------------------------------------------------------- |
|
|
528
|
+
| `--font-default` | Default app font family. |
|
|
529
|
+
| `--container-narrow` | Narrow content width. |
|
|
530
|
+
| `--container-max` | Default content width. |
|
|
531
|
+
| `--container-wide` | Wide content width. |
|
|
532
|
+
| `--layout-gutter` | Responsive inline page padding. |
|
|
533
|
+
| `--layout-section-block` | Responsive section vertical padding. |
|
|
534
|
+
| `--layout-gap` | Shared gap for `.view`, `.stack`, `.cluster`, and `.auto-grid`. |
|
|
535
|
+
| `--layout-grid-min` | Minimum column width for `.auto-grid`. |
|
|
536
|
+
| `--radius-small` | Small radius for compact utility surfaces such as code elements. |
|
|
537
|
+
| `--radius-control` | Radius for buttons, inputs, tooltips, and compact UI. |
|
|
538
|
+
| `--radius-surface` | Radius for cards, panels, and alerts. |
|
|
539
|
+
| `--control-height` | Default minimum height for controls. |
|
|
540
|
+
| `--border-width` | Default border width. |
|
|
541
|
+
| `--elevation-color` | Shadow color the four elevations compose from. Heavier in dark themes. |
|
|
542
|
+
| `--elevation-none` | No shadow. Use on an element that should read as flat against its page. |
|
|
543
|
+
| `--elevation-sm` | A light shadow for your own surface-level elements, such as cards. |
|
|
544
|
+
| `--elevation-md` | A shadow for your own raised elements, such as dropdowns and popovers. |
|
|
545
|
+
| `--elevation-lg` | A shadow for your own full overlays, such as modal dialogs. |
|
|
546
|
+
| `--focus-ring` | Focus-visible ring color. |
|
|
547
|
+
| `--focus-ring-offset` | Focus-visible outline offset. Negative, so the ring lands on the edge. |
|
|
548
|
+
| `--focus-ring-width` | Focus-visible outline/ring width. |
|
|
549
|
+
| `--motion-duration-fast` | Fast transition for buttons and input interactions (`120ms`). |
|
|
550
|
+
| `--motion-duration-normal` | Normal transition for layout and modals (`200ms`). |
|
|
551
|
+
| `--motion-duration-slow` | Slow animation for skeleton loaders and progress bars (`400ms`). |
|
|
552
|
+
| `--motion-ease` | Default easing curve. |
|
|
553
|
+
| `--z-popover` | Popover/tooltip z-index. |
|
|
554
|
+
| `--breakpoint-xs` | Extra-small Tailwind responsive breakpoint. |
|
|
555
|
+
| `--breakpoint-2xl` | Extended large Tailwind responsive breakpoint. |
|
|
556
|
+
|
|
557
|
+
Next: [Customizing](docs/usage/customizing.md) covers presentation and material tokens — how much of an intent shows, and what a component is made of.
|
|
558
|
+
|
|
559
|
+
<!-- Source: docs/usage/customizing.md -->
|
|
560
|
+
|
|
561
|
+
# Customizing
|
|
562
|
+
|
|
563
|
+
Presentation tokens decide how much of an intent shows. Material tokens decide what a component is made of. Aesthetic tokens are the small set of named knobs a shipped aesthetic exposes to scale its own look.
|
|
564
|
+
|
|
565
|
+
## Presentation tokens
|
|
566
|
+
|
|
567
|
+
Presentation tokens describe _how much_ of an intent a component shows, never _which_ intent it shows. They are unitless numbers and percentages, so they carry no color and inherit safely: a container sets them once and every component below resolves them against its own intent.
|
|
568
|
+
|
|
569
|
+
| Token | Purpose |
|
|
570
|
+
| ----------------- | -------------------------------------------------------------------------- |
|
|
571
|
+
| `--ui-fill` | Percentage of the intent color mixed into the background. |
|
|
572
|
+
| `--ui-fg-on-fill` | Percentage blended from the intent readable tone toward its contrast tone. |
|
|
573
|
+
| `--ui-border` | Percentage of the intent color mixed into the border color. |
|
|
574
|
+
|
|
575
|
+
A component resolves them with `color-mix` from its published default. Hover is derived by adding `--hover-step` to the resting fill and using `--intent-hover`; there are no per-presentation hover tokens.
|
|
578
576
|
|
|
579
|
-
|
|
580
|
-
aesthetic on its own, after the base stylesheet so its rules win:
|
|
577
|
+
No fill class writes `--ui-border` and no edge class writes `--ui-fill`. A filled box with no line is `.solid.edgeless`, which is worth reaching for on a neutral component: neutral caps its fill, so the box stays translucent and a border over it paints a second coat of the same tint instead of blending into it.
|
|
581
578
|
|
|
582
579
|
```css
|
|
583
|
-
|
|
584
|
-
@import "@codenhub/styles/aesthetics";
|
|
580
|
+
background: color-mix(in oklab, var(--color-primary) var(--ui-fill, 100%), transparent);
|
|
585
581
|
```
|
|
586
582
|
|
|
583
|
+
Two choices there are deliberate. Mixing toward `transparent` rather than a background token lets a tinted surface adapt to whatever it is placed on. Mixing in `oklab` keeps the wide-gamut token palette intact and blends perceptually, where `srgb` would clip it.
|
|
584
|
+
|
|
585
|
+
A computed color therefore reaches the page as a resolved `color-mix` result rather than the token's own `oklch` syntax. It is the same color; code that compares computed color strings should compare colors instead.
|
|
586
|
+
|
|
587
|
+
> **Presentation token contract**: only presentation classes and consumer overrides set these tokens; components only read them. Setting a value that no presentation class produces is supported but unvalidated. See [Composing](docs/usage/composing.md) for the classes that ship these values.
|
|
588
|
+
|
|
589
|
+
## Material tokens
|
|
590
|
+
|
|
591
|
+
Material tokens describe what a component is _made of_ rather than which intent it shows or how strongly. They control shape, borders, shadows, translucency, filters, and transforms.
|
|
592
|
+
|
|
593
|
+
Components read each with a fallback, so leaving them unset produces the default look. Setting them on a container restyles the whole subtree. Only shadow geometry is split into colorless parts that inherit safely; color-capable inputs such as `--ui-ink` and `--ui-surface-shadow` may include their own colors.
|
|
594
|
+
|
|
595
|
+
| Token | Purpose | Fallback |
|
|
596
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
597
|
+
| `--ui-radius` | Corner radius for controls. | `--radius-control` |
|
|
598
|
+
| `--ui-radius-surface` | Corner radius for surfaces. | `--radius-surface` |
|
|
599
|
+
| `--ui-border-width` | Edge thickness. | `--border-width` |
|
|
600
|
+
| `--ui-border-max` | Ceiling on computed edge width. | `100px` |
|
|
601
|
+
| `--ui-ink` | Neutral line color when no intent is set. | `--color-border` |
|
|
602
|
+
| `--ui-rule` | Lines inside a table. Unset draws the head and foot boundaries only; `0%` draws none; `100%` rules every row. | unset |
|
|
603
|
+
| `--ui-shadow-x` | Shadow horizontal offset. | `0px` |
|
|
604
|
+
| `--ui-shadow-y` | Shadow vertical offset. | `0px` |
|
|
605
|
+
| `--ui-shadow-blur` | Shadow blur radius. | `0px` |
|
|
606
|
+
| `--ui-shadow-spread` | Shadow spread radius. | `0px` |
|
|
607
|
+
| `--ui-shadow-inset` | The `inset` keyword for an inner ring. | Empty |
|
|
608
|
+
| `--ui-hover-shadow-x` | Shadow horizontal offset while hovered. | `--ui-shadow-x` |
|
|
609
|
+
| `--ui-hover-shadow-y` | Shadow vertical offset while hovered. | `--ui-shadow-y` |
|
|
610
|
+
| `--ui-active-shadow-x` | Shadow horizontal offset while pressed. | `--ui-shadow-x` |
|
|
611
|
+
| `--ui-active-shadow-y` | Shadow vertical offset while pressed. | `--ui-shadow-y` |
|
|
612
|
+
| `--ui-active-transform` | Transform while pressed. `none` under `prefers-reduced-motion`. | `scale(0.97)` |
|
|
613
|
+
| `--ui-shadow-ink` | Percentage of shadow color taken from intent ink. | `0%` |
|
|
614
|
+
| `--ui-shadow-edge` | Declared, even empty, when the shadow is the element's edge rather than its depth. Read for presence. | Unset |
|
|
615
|
+
| `--ui-elevation` | Unitless multiplier over shadow geometry. | `1` |
|
|
616
|
+
| `--ui-surface-shadow` | Complete multi-layer shadow accepted by surfaces only. | Unset |
|
|
617
|
+
| `--ui-surface-ground` | Ground a surface sits on. | `--color-background` |
|
|
618
|
+
| `--ui-bg-alpha` | Multiplier over fill for translucent materials. | `1` |
|
|
619
|
+
| `--ui-backdrop` | Backdrop filter accepted by surfaces only. | `none` |
|
|
620
|
+
| `--ui-hover-transform` | Transform while an interactive element is hovered. | `none` |
|
|
621
|
+
| `--ui-clip` | Structural component silhouette. | `none` |
|
|
622
|
+
| `--ui-clip-tight` | Compact component silhouette. | `--ui-clip` |
|
|
623
|
+
| `--ui-focus-inset` | Inset focus layer width. | Unset |
|
|
624
|
+
|
|
587
625
|
```html
|
|
588
|
-
<section
|
|
589
|
-
<button class="btn primary">
|
|
626
|
+
<section style="--ui-radius: 0; --ui-border-width: 3px">
|
|
627
|
+
<button class="btn primary">Square and heavy</button>
|
|
628
|
+
<input class="ipt" placeholder="Matches" />
|
|
590
629
|
</section>
|
|
591
630
|
```
|
|
592
631
|
|
|
593
|
-
|
|
594
|
-
instead; see [Integrating → Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
632
|
+
> **Material token contract**: components read these; aesthetic classes and consumer overrides set them.
|
|
595
633
|
|
|
596
|
-
|
|
634
|
+
### Shape and ring composition
|
|
635
|
+
|
|
636
|
+
Clipping removes borders, outlines, and outer shadows. An aesthetic that uses a clip can replace the border with an inset shadow by setting `--ui-shadow-inset` and the four shadow geometry parts. Set `--ui-border-max: 0px` when that ring replaces the component border. Focusable components restore the clipped focus outline through `--ui-focus-inset`.
|
|
637
|
+
|
|
638
|
+
Declare `--ui-shadow-edge` when that ring _is_ the border. The ring then takes the element's edge color, which carries the edge axis as its alpha, so `.edged` draws it and `.edgeless` does not — the same answer a real border gives. Without it the ring paints on every component the aesthetic reaches and the edge classes have no effect. Use `--ui-shadow-ink` instead when the shadow is depth cast in the intent's own ink, such as a hard offset slab, which an `.edgeless` element still gets.
|
|
639
|
+
|
|
640
|
+
The token is read for its presence, not its value: declare it empty to switch the ring on, and `initial` to switch it back off in an aesthetic nested inside one that declares it.
|
|
641
|
+
|
|
642
|
+
```css
|
|
643
|
+
.stepped {
|
|
644
|
+
--ui-clip: polygon(/* structural silhouette */);
|
|
645
|
+
--ui-clip-tight: none;
|
|
646
|
+
--ui-border-max: 0px;
|
|
647
|
+
--ui-shadow-inset: inset;
|
|
648
|
+
--ui-shadow-edge: ;
|
|
649
|
+
--ui-shadow-x: 0px;
|
|
650
|
+
--ui-shadow-y: 0px;
|
|
651
|
+
--ui-shadow-blur: 0px;
|
|
652
|
+
--ui-shadow-spread: 4px;
|
|
653
|
+
--ui-focus-inset: var(--focus-ring-width);
|
|
654
|
+
}
|
|
655
|
+
```
|
|
656
|
+
|
|
657
|
+
Variables prefixed `--_` are internal composition outputs — `--_bg`, `--_fg`, `--_edge`, `--_fill`, `--_shadow`, and the `--_d-*` resting slots a component states for `box` to read. Do not set or read them; only the `--ui-*` inputs above are public.
|
|
658
|
+
|
|
659
|
+
## Aesthetic tokens
|
|
660
|
+
|
|
661
|
+
The shipped [aesthetic classes](docs/usage/aesthetics.md) set material tokens for you. Only aesthetics with a token listed below expose an aesthetic-specific token. Tune all other behavior through the shared material tokens above. Listed tokens are available only where that aesthetic's stylesheet is imported.
|
|
597
662
|
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
663
|
+
| Token | Aesthetic | Purpose | Default |
|
|
664
|
+
| ------------------------ | --------------- | ----------------------------------------------------------- | --------------------------------- |
|
|
665
|
+
| `--neo-offset` | `.neobrutalism` | Hard shadow offset and distance the press travels. | `4px` |
|
|
666
|
+
| `--glass-radius` | `.glass` | Control corner radius. | `0.75rem` |
|
|
667
|
+
| `--glass-radius-surface` | `.glass` | Surface corner radius. | `1rem` |
|
|
668
|
+
| `--pixel-unit` | `.pixel` | One pixel of the grid. The corner cut and the ring are one. | `4px` |
|
|
669
|
+
| `--font-pixel` | `.pixel` | Consumer-supplied pixel font stack. | Falls back to the monospace stack |
|
|
670
|
+
| `--tile-radius` | `.chunky-tile` | Corner radius, on controls and surfaces alike. | `0.75rem` |
|
|
671
|
+
| `--tile-lift` | `.chunky-tile` | Depth of the seated bar, and how far a press travels. | `4px` |
|
|
672
|
+
| `--font-rounded` | `.chunky-tile` | Consumer-supplied rounded font stack. | Falls back to the page stack |
|
|
673
|
+
|
|
674
|
+
All four aesthetics reach the same way: each knob is _read_ with its default as a `var()` fallback rather than declared, so it resolves once into a private on the aesthetic's own class (`--_pixel-unit`, `--_neo-offset`, `--_tile-radius`, `--_tile-lift`, and so on). Set a knob on the element carrying the aesthetic class, or on any ancestor including `:root`:
|
|
601
675
|
|
|
602
676
|
```html
|
|
603
|
-
<
|
|
677
|
+
<section class="pixel" style="--pixel-unit: 6px">
|
|
678
|
+
<button class="btn primary">Chunkier</button>
|
|
679
|
+
</section>
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
```html
|
|
683
|
+
<html class="pixel" style="--pixel-unit: 6px">
|
|
604
684
|
<body>
|
|
605
|
-
<button class="btn primary">
|
|
685
|
+
<button class="btn primary">Also chunkier, set from the root</button>
|
|
606
686
|
</body>
|
|
607
687
|
</html>
|
|
608
688
|
```
|
|
609
689
|
|
|
610
|
-
|
|
611
|
-
selectors resolve and [Usage → Theming](docs/usage/theming.md) for the full color
|
|
612
|
-
token reference.
|
|
690
|
+
Knobs and material tokens reach in opposite directions, and telling them apart matters. A knob resolves once at the aesthetic's own class and inherits down already-resolved, so it reaches the aesthetic **from above**: setting it on the element or any ancestor works, but setting it on a _descendant_ of the aesthetic class changes nothing — the value has already been read. `--ui-radius` and the other material tokens above are read fresh by each component as it draws, so they reach **at or below** the element carrying them, which is how you round one card differently from its neighbours without touching the knob at all.
|
|
613
691
|
|
|
614
|
-
|
|
692
|
+
Shipped aesthetics set the shared material tokens above. `.neobrutalism` and `.pixel` set `--ui-ink` for their neutral outline; intent classes still override the intent slots on each component.
|
|
615
693
|
|
|
616
|
-
|
|
617
|
-
resolve package CSS imports. `/tw` entrypoints publish copied, uncompiled
|
|
618
|
-
source from `dist/tw`; a Tailwind v4 build must still process their `@theme`,
|
|
619
|
-
`@utility`, `@apply`, and related directives. Focused source component
|
|
620
|
-
entrypoints include theme tokens so their classes can work independently.
|
|
621
|
-
|
|
622
|
-
| Import path | Composition and effects |
|
|
623
|
-
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
624
|
-
| `@codenhub/styles` | Compiled complete surface: Tailwind base/theme output, tokens, typography, utilities, components, and reset. Applies global reset, root theme, and focus rules. |
|
|
625
|
-
| `@codenhub/styles/theme` | Compiled Tailwind theme variables, Codenhub tokens, and the presentation classes. Sets root theme properties and system/explicit theme selectors; no reset or component classes. |
|
|
626
|
-
| `@codenhub/styles/components` | Compiled theme tokens, typography utilities, and every component class. Includes static reduced-motion loader masks; no reset, layout/content utilities, or native mappings. |
|
|
627
|
-
| `@codenhub/styles/native` | Compiled complete surface plus classless mappings for headings, text, content elements, form controls, and buttons. Applies the reset and broad element selectors. |
|
|
628
|
-
| `@codenhub/styles/aesthetics` | Compiled `.neobrutalism`, `.glass`, `.pixel`, and `.chunky-tile` classes. Adds no tokens or components of its own; import after the base stylesheet. |
|
|
629
|
-
| `@codenhub/styles/aesthetics/*` | One compiled aesthetic: `/neobrutalism`, `/glass`, `/pixel`, or `/chunky-tile`. Same rules and ordering as the combined file. |
|
|
630
|
-
| `@codenhub/styles/tw` | Source equivalent of the complete stylesheet. Imports Tailwind itself, theme, typography, utilities, components, and reset; applies the same global rules. |
|
|
631
|
-
| `@codenhub/styles/tw/theme` | Source theme, tokens, and presentation classes. Imports Tailwind's theme layer; emits root/system/explicit theme selectors and defines the package's custom `dark:` variant. |
|
|
632
|
-
| `@codenhub/styles/tw/components` | Published Tailwind source for theme, typography, buttons, feedback, forms, loaders, surfaces, and tooltips, including static reduced-motion loader masks. No reset, layout/content utilities, or native mappings. |
|
|
633
|
-
| `@codenhub/styles/tw/surface` | Source theme plus `.surface`, `.card`, and `.panel`. |
|
|
634
|
-
| `@codenhub/styles/tw/button` | Published Tailwind source for theme, activity indicators, and `.btn`; includes static reduced-motion masks because buttons compose `.loader-mask` for loading state. |
|
|
635
|
-
| `@codenhub/styles/tw/form` | Source theme plus field, public `text-control`, input, textarea, select, checkbox, radio, and switch utilities. |
|
|
636
|
-
| `@codenhub/styles/tw/feedback` | Source theme plus alert, badge, skeleton, and progress utilities and their keyframes. |
|
|
637
|
-
| `@codenhub/styles/tw/loader` | Published Tailwind source for activity indicators and loaders, including static reduced-motion masks. It has no theme or reset side effects and uses `currentColor`. |
|
|
638
|
-
| `@codenhub/styles/tw/tooltip` | Source theme plus tooltip utilities. |
|
|
639
|
-
| `@codenhub/styles/tw/reset` | Source theme, typography utilities, and global reset/accessibility rules. It changes root/body/elements and selection, motion, focus, scrollbar, and forced colors. |
|
|
640
|
-
| `@codenhub/styles/tw/native` | Source complete surface plus reset and classless native-element mappings; broadest global effects. |
|
|
641
|
-
| `@codenhub/styles/tw/typography` | Source theme plus typography utilities; sets theme selectors but no reset or classless mappings. |
|
|
642
|
-
| `@codenhub/styles/tw/utilities` | Source theme and typography composition plus layout and content utilities; safelists the package utility names. |
|
|
643
|
-
| `@codenhub/styles/tw/aesthetics` | Source aesthetics, combined. `/tw/aesthetics/neobrutalism`, `/glass`, `/pixel`, and `/chunky-tile` publish one apiece. Plain CSS with no theme or reset side effects. |
|
|
644
|
-
|
|
645
|
-
Avoid importing overlapping entrypoints in the same build unless duplicate
|
|
646
|
-
generated CSS is acceptable; pick the narrowest entrypoint that covers what a
|
|
647
|
-
page needs.
|
|
694
|
+
## Component internals
|
|
648
695
|
|
|
649
|
-
|
|
696
|
+
Component classes may define scoped implementation variables such as `--surface-padding`, `--field-gap`, `--input-group-pad`, `--switch-*`, `--table-*`, `--quote-*`, and `--tooltip-*`. These variables are internal wiring for class composition and are not the public token contract.
|
|
650
697
|
|
|
651
|
-
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
- Tailwind CSS 4 or newer is required only for `/tw` source entrypoints.
|
|
657
|
-
- The package has no JavaScript runtime. Apps must provide semantic HTML,
|
|
658
|
-
ARIA, keyboard behavior, focus management, validation, and announcements;
|
|
659
|
-
see [Accessibility](docs/accessibility.md).
|
|
698
|
+
Consumers should customize broad behavior through color, foundation, motion, elevation, radius, layout, and focus tokens first. The only supported component-scoped input is `--progress-value` on the `.progress` element, because consumers must provide a value such as `64%`.
|
|
699
|
+
|
|
700
|
+
`--layout-gap` replaces the removed `--layout-stack-gap` and `--layout-cluster-gap` tokens. No compatibility aliases are provided.
|
|
701
|
+
|
|
702
|
+
Next: [Aesthetics](docs/usage/aesthetics.md) covers each shipped aesthetic's complete look and its documented exceptions.
|
|
660
703
|
|
|
661
704
|
<!-- Source: docs/usage/aesthetics.md -->
|
|
662
705
|
|
|
663
706
|
# Aesthetics
|
|
664
707
|
|
|
665
|
-
An aesthetic decides what a component is _made of_: its radius, border
|
|
666
|
-
thickness, shadow, and shape. Aesthetics ship from opt-in entrypoints, so
|
|
667
|
-
importing the stylesheet is what makes the classes available:
|
|
708
|
+
An aesthetic decides what a component is _made of_: its radius, border thickness, shadow, and shape. Aesthetics ship from opt-in entrypoints, so importing the stylesheet is what makes the classes available:
|
|
668
709
|
|
|
669
710
|
```css
|
|
670
711
|
@import "@codenhub/styles";
|
|
671
712
|
@import "@codenhub/styles/aesthetics";
|
|
672
713
|
```
|
|
673
714
|
|
|
674
|
-
Import them after the base stylesheet. `.neobrutalism` and `.pixel` replace
|
|
675
|
-
the neutral border color, and they do so at zero specificity, so source order
|
|
676
|
-
is what lets them win.
|
|
715
|
+
Import them after the base stylesheet. `.neobrutalism` and `.pixel` replace the neutral border color, and they do so at zero specificity, so source order is what lets them win.
|
|
677
716
|
|
|
678
717
|
Like presentation, an aesthetic class cascades to any subtree:
|
|
679
718
|
|
|
@@ -691,33 +730,19 @@ Like presentation, an aesthetic class cascades to any subtree:
|
|
|
691
730
|
| `.pixel` | Corners cut by one grid unit, a chunky outline drawn as an inset ring, and the consumer-supplied `--font-pixel` over monospace. |
|
|
692
731
|
| `.chunky-tile` | Rounded slabs seated on a darker shade of themselves, with a press that moves the element down into its own bar. |
|
|
693
732
|
|
|
694
|
-
Aesthetics compose with every supported fill and edge pair. `.ghost.edgeless`
|
|
695
|
-
intentionally removes the visible material traits from components whose
|
|
696
|
-
aesthetic is expressed only through their fill, edge, or elevation.
|
|
733
|
+
Aesthetics compose with every supported fill and edge pair. `.ghost.edgeless` intentionally removes the visible material traits from components whose aesthetic is expressed only through their fill, edge, or elevation.
|
|
697
734
|
|
|
698
|
-
An explicit presentation on the element still wins over the aesthetic's
|
|
699
|
-
defaults. The aesthetic supplies edge thickness; presentation only decides
|
|
700
|
-
whether that edge is drawn.
|
|
735
|
+
An explicit presentation on the element still wins over the aesthetic's defaults. The aesthetic supplies edge thickness; presentation only decides whether that edge is drawn.
|
|
701
736
|
|
|
702
|
-
An aesthetic directly on a component likewise wins over an inherited
|
|
703
|
-
aesthetic. This includes tooltip pseudo-elements: `.tooltip.glass` gets the
|
|
704
|
-
complete glass bubble under a pixel ancestor, and `.tooltip.pixel` gets the
|
|
705
|
-
complete stepped bubble under a glass ancestor.
|
|
737
|
+
An aesthetic directly on a component likewise wins over an inherited aesthetic. This includes tooltip pseudo-elements: `.tooltip.glass` gets the complete glass bubble under a pixel ancestor, and `.tooltip.pixel` gets the complete stepped bubble under a glass ancestor.
|
|
706
738
|
|
|
707
|
-
Each aesthetic that scales from one number publishes it as a knob — see
|
|
708
|
-
[Customizing → Aesthetic tokens](docs/usage/customizing.md#aesthetic-tokens) for how
|
|
709
|
-
knobs resolve and where they can be set. This page covers what each
|
|
710
|
-
aesthetic looks like and where it makes documented exceptions.
|
|
739
|
+
Each aesthetic that scales from one number publishes it as a knob — see [Customizing → Aesthetic tokens](docs/usage/customizing.md#aesthetic-tokens) for how knobs resolve and where they can be set. This page covers what each aesthetic looks like and where it makes documented exceptions.
|
|
711
740
|
|
|
712
741
|
## Neobrutalism
|
|
713
742
|
|
|
714
|
-
The shadow is cast in the component's own intent, so a success button throws
|
|
715
|
-
a green shadow and a destructive card a red one. With no intent, both the
|
|
716
|
-
outline and the shadow use the ink, which follows the theme rather than the
|
|
717
|
-
palette.
|
|
743
|
+
The shadow is cast in the component's own intent, so a success button throws a green shadow and a destructive card a red one. With no intent, both the outline and the shadow use the ink, which follows the theme rather than the palette.
|
|
718
744
|
|
|
719
|
-
`--neo-offset` is the knob: the shadow offset and the distance the press
|
|
720
|
-
travels are the same number, so scaling the look scales both at once.
|
|
745
|
+
`--neo-offset` is the knob: the shadow offset and the distance the press travels are the same number, so scaling the look scales both at once.
|
|
721
746
|
|
|
722
747
|
```html
|
|
723
748
|
<section class="neobrutalism" style="--neo-offset: 6px">
|
|
@@ -727,26 +752,15 @@ travels are the same number, so scaling the look scales both at once.
|
|
|
727
752
|
|
|
728
753
|
**Exceptions:**
|
|
729
754
|
|
|
730
|
-
- Content chips are left alone. A `.kbd`, `.code`, or `.pre` is content
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
- Only `.btn` and `.card.interactive` respond to hover and press. A card
|
|
734
|
-
becomes a control when it opts in with `.interactive`; a plain card, an
|
|
735
|
-
alert, or a panel is a container and stays put.
|
|
736
|
-
- An alert rests on the slab under this aesthetic and nowhere else. Here the
|
|
737
|
-
slab is a second ink line rather than depth, and an alert is the only
|
|
738
|
-
container the package rests flat, so without it a neobrutalist alert is
|
|
739
|
-
the one box on the page that reads as unfinished. It is a resting default,
|
|
740
|
-
so `.flat` still takes it off and `.floating` still doubles it.
|
|
755
|
+
- Content chips are left alone. A `.kbd`, `.code`, or `.pre` is content rather than structure, and an ink edge on one reads as a defect: a key cap keeps the quiet border color and a code chip keeps no border at all.
|
|
756
|
+
- Only `.btn` and an opted-in `.card` respond to hover and press. A card opts in with `.interactive`, or with one of its halves — `.hoverable` for the hover response alone, `.pressable` for the press alone; a plain card, an alert, or a panel is a container and stays put.
|
|
757
|
+
- An alert rests on the slab under this aesthetic and nowhere else. Here the slab is a second ink line rather than depth, and an alert is the only container the package rests flat, so without it a neobrutalist alert is the one box on the page that reads as unfinished. It is a resting default, so `.flat` still takes it off and `.floating` still doubles it.
|
|
741
758
|
|
|
742
759
|
## Glass
|
|
743
760
|
|
|
744
|
-
`.glass` needs something behind it to blur. On a flat page background it
|
|
745
|
-
renders as a plain translucent panel.
|
|
761
|
+
`.glass` needs something behind it to blur. On a flat page background it renders as a plain translucent panel.
|
|
746
762
|
|
|
747
|
-
`--glass-radius` and `--glass-radius-surface` are the corners, at `0.75rem`
|
|
748
|
-
and `1rem`. Glass is rounder than the base geometry because a translucent
|
|
749
|
-
panel with a tight corner reads as a cut-out rather than as a pane.
|
|
763
|
+
`--glass-radius` and `--glass-radius-surface` are the corners, at `0.75rem` and `1rem`. Glass is rounder than the base geometry because a translucent panel with a tight corner reads as a cut-out rather than as a pane.
|
|
750
764
|
|
|
751
765
|
```html
|
|
752
766
|
<section class="glass" style="--glass-radius-surface: 1.5rem">
|
|
@@ -756,18 +770,12 @@ panel with a tight corner reads as a cut-out rather than as a pane.
|
|
|
756
770
|
|
|
757
771
|
**Exceptions:**
|
|
758
772
|
|
|
759
|
-
- The blur applies to `.card`, `.panel`, `.alert`, and the tooltip bubble
|
|
760
|
-
|
|
761
|
-
of a dense cluster costs a composited layer apiece and reads as noise.
|
|
762
|
-
Controls still take the aesthetic's radius, border, and shadow.
|
|
763
|
-
- Under `prefers-reduced-transparency: reduce`, glass surfaces drop the blur
|
|
764
|
-
and become opaque.
|
|
773
|
+
- The blur applies to `.card`, `.panel`, `.alert`, and the tooltip bubble only. Controls stay solid and sit on the glass: a blur under every control of a dense cluster costs a composited layer apiece and reads as noise. Controls still take the aesthetic's radius, border, and shadow.
|
|
774
|
+
- Under `prefers-reduced-transparency: reduce`, glass surfaces drop the blur and become opaque.
|
|
765
775
|
|
|
766
776
|
## Pixel
|
|
767
777
|
|
|
768
|
-
`--pixel-unit` is one pixel of the imaginary low-resolution grid, `4px` by
|
|
769
|
-
default. One square unit is cut from each corner and the outline is one unit
|
|
770
|
-
thick, so the cut and what covers it are the same size.
|
|
778
|
+
`--pixel-unit` is one pixel of the imaginary low-resolution grid, `4px` by default. One square unit is cut from each corner and the outline is one unit thick, so the cut and what covers it are the same size.
|
|
771
779
|
|
|
772
780
|
```html
|
|
773
781
|
<section class="pixel" style="--pixel-unit: 6px">
|
|
@@ -777,44 +785,16 @@ thick, so the cut and what covers it are the same size.
|
|
|
777
785
|
|
|
778
786
|
**Exceptions:**
|
|
779
787
|
|
|
780
|
-
- Corners are one unit or nothing. Chips square instead of stepping —
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
progress bars, and skeletons square too, each for its own reason: a
|
|
785
|
-
table's `overflow: hidden` fights the clip and the corners square off
|
|
786
|
-
where the two meet, and progress and skeleton never read a clip at all —
|
|
787
|
-
a squaring aesthetic reaches them through `border-radius` alone. `.pre` is
|
|
788
|
-
the one exception that steps: it carries no clip override, so it inherits
|
|
789
|
-
the same polygon a button or a card gets, and with no border by default
|
|
790
|
-
the cut shows with no ring around it.
|
|
791
|
-
- The outline is an inset ring, because a clip removes a real border — and
|
|
792
|
-
the focus ring, for the same reason, is a second inset layer rather than
|
|
793
|
-
an outline. Both are the element's own edge rather than a shadow, so the
|
|
794
|
-
border answers `.edged` and `.edgeless` the way a border does: a
|
|
795
|
-
`.edgeless` badge and a `.solid` button draw none, a `.edged` card draws
|
|
796
|
-
one, and a field keeps one whatever a container asks for.
|
|
797
|
-
- The tooltip trigger and `.radio` are hardcoded past the clip rather than
|
|
798
|
-
reached by it. `.tooltip-icon` forces `clip-path: none`, since a stepped
|
|
799
|
-
badge would clip its own bubble away with it. `.radio` forces the same,
|
|
800
|
-
because the circle is the only thing telling it from a checkbox at a
|
|
801
|
-
glance, and a stepped polygon would square it.
|
|
802
|
-
- `--font-pixel` is yours to supply. The package ships no font binary, so the
|
|
803
|
-
aesthetic has no network side effect and falls back to the monospace
|
|
804
|
-
stack.
|
|
788
|
+
- Corners are one unit or nothing. Chips square instead of stepping — badges, key caps, code, checkboxes, and switches all read `--ui-clip-tight`, which this aesthetic sets to none, because one unit off each corner of a 24px badge is a bite rather than a corner. Tables, progress bars, and skeletons square too, each for its own reason: a table's `overflow: hidden` fights the clip and the corners square off where the two meet, and progress and skeleton never read a clip at all — a squaring aesthetic reaches them through `border-radius` alone. `.pre` is the one exception that steps: it carries no clip override, so it inherits the same polygon a button or a card gets, and with no border by default the cut shows with no ring around it.
|
|
789
|
+
- The outline is an inset ring, because a clip removes a real border — and the focus ring, for the same reason, is a second inset layer rather than an outline. Both are the element's own edge rather than a shadow, so the border answers `.edged` and `.edgeless` the way a border does: a `.edgeless` badge and a `.solid` button draw none, a `.edged` card draws one, and a field keeps one whatever a container asks for.
|
|
790
|
+
- The tooltip trigger and `.radio` are hardcoded past the clip rather than reached by it. `.tooltip-icon` forces `clip-path: none`, since a stepped badge would clip its own bubble away with it. `.radio` forces the same, because the circle is the only thing telling it from a checkbox at a glance, and a stepped polygon would square it.
|
|
791
|
+
- `--font-pixel` is yours to supply. The package ships no font binary, so the aesthetic has no network side effect and falls back to the monospace stack.
|
|
805
792
|
|
|
806
793
|
## Chunky tile
|
|
807
794
|
|
|
808
|
-
Rounded slabs sitting on a darker shade of themselves, pressed flat on
|
|
809
|
-
click. The look mobile learning and game apps use; it is named for what it
|
|
810
|
-
is made of rather than for any one product.
|
|
795
|
+
Rounded slabs sitting on a darker shade of themselves, pressed flat on click. The look mobile learning and game apps use; it is named for what it is made of rather than for any one product.
|
|
811
796
|
|
|
812
|
-
`--tile-lift` is how deep the bar is and how far a press travels, `4px` by
|
|
813
|
-
default. One number drives both, so the top edge drops by exactly the bar's
|
|
814
|
-
depth and the bottom edge does not move. `--tile-radius` is the corner,
|
|
815
|
-
`0.75rem`, and it is one value rather than a control/surface pair on
|
|
816
|
-
purpose — the shared corner is what makes a button and the card it sits in
|
|
817
|
-
read as the same object.
|
|
797
|
+
`--tile-lift` is how deep the bar is and how far a press travels, `4px` by default. One number drives both, so the top edge drops by exactly the bar's depth and the bottom edge does not move. `--tile-radius` is the corner, `0.75rem`, and it is one value rather than a control/surface pair on purpose — the shared corner is what makes a button and the card it sits in read as the same object.
|
|
818
798
|
|
|
819
799
|
```html
|
|
820
800
|
<section class="chunky-tile" style="--tile-lift: 6px; --tile-radius: 0.5rem">
|
|
@@ -822,49 +802,29 @@ read as the same object.
|
|
|
822
802
|
</section>
|
|
823
803
|
```
|
|
824
804
|
|
|
825
|
-
The bar is a darker shade of the element's own colour rather than a shadow
|
|
826
|
-
under it, so it follows every intent: a success button sits on a dark green
|
|
827
|
-
edge, a destructive one on a dark red edge, and a plain card on a grey edge
|
|
828
|
-
that matches the line it already draws. Measured on the light palette,
|
|
829
|
-
`.btn.success` is `#007a55` on `#004c34`. On a dark page a near-black
|
|
830
|
-
surface cannot go darker, so its bar lands lighter and reads as a rim.
|
|
805
|
+
The bar is a darker shade of the element's own colour rather than a shadow under it, so it follows every intent: a success button sits on a dark green edge, a destructive one on a dark red edge, and a plain card on a grey edge that matches the line it already draws. Measured on the light palette, `.btn.success` is `#007a55` on `#004c34`. On a dark page a near-black surface cannot go darker, so its bar lands lighter and reads as a rim.
|
|
831
806
|
|
|
832
807
|
**Exceptions:**
|
|
833
808
|
|
|
834
|
-
- Only what the registry rests above zero sits on a bar — buttons and cards.
|
|
835
|
-
A badge, chip, field, or tooltip is flat until it asks for depth with
|
|
836
|
-
`.raised`, and `.flat` takes the bar off anything:
|
|
809
|
+
- Only what the registry rests above zero sits on a bar — buttons and cards. A badge, chip, field, or tooltip is flat until it asks for depth with `.raised`, and `.flat` takes the bar off anything:
|
|
837
810
|
|
|
838
811
|
```html
|
|
839
812
|
<div class="card soft edgeless info flat">Promo panel, deliberately flat</div>
|
|
840
813
|
```
|
|
841
814
|
|
|
842
|
-
- `--font-rounded` is yours to supply. A heavy rounded grotesque is most of
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
-
|
|
846
|
-
|
|
847
|
-
uppercase buttons, write that rule in your own stylesheet.
|
|
848
|
-
- `.card.interactive` presses like a `.btn`, so a chunky answer tile drops
|
|
849
|
-
onto its bar on click. A plain `.card` stays put.
|
|
850
|
-
- The shipped `.primary` is a near-black monochrome, which leaves a primary
|
|
851
|
-
button's bar almost invisible against its own plate; give `.primary` a hue
|
|
852
|
-
if it is the call to action.
|
|
853
|
-
- Depth in this aesthetic is the bar, never a blurred drop shadow. Anything
|
|
854
|
-
the registry rests flat sits flush on the page.
|
|
815
|
+
- `--font-rounded` is yours to supply. A heavy rounded grotesque is most of this look and the package ships no font binary, so with nothing supplied the page's own stack is used.
|
|
816
|
+
- Action labels are drawn heavier and slightly tracked. Casing is left alone: how a label is worded is the application's decision, so if you want uppercase buttons, write that rule in your own stylesheet.
|
|
817
|
+
- `.card.interactive` presses like a `.btn`, so a chunky answer tile drops onto its bar on click; `.card.pressable` gets the same press on its own. A plain `.card` stays put.
|
|
818
|
+
- The shipped `.primary` is a near-black monochrome, which leaves a primary button's bar almost invisible against its own plate; give `.primary` a hue if it is the call to action.
|
|
819
|
+
- Depth in this aesthetic is the bar, never a blurred drop shadow. Anything the registry rests flat sits flush on the page.
|
|
855
820
|
|
|
856
821
|
<!-- Source: docs/usage/buttons.md -->
|
|
857
822
|
|
|
858
823
|
# Buttons
|
|
859
824
|
|
|
860
|
-
Use `.btn` with one optional intent class, one optional fill class, one
|
|
861
|
-
optional edge class, optional size class, and optional state. See
|
|
862
|
-
[Composing](docs/usage/composing.md) for how the intent, presentation, and aesthetic
|
|
863
|
-
axes combine on any component.
|
|
825
|
+
Use `.btn` with one optional intent class, one optional fill class, one optional edge class, optional size class, and optional state. See [Composing](docs/usage/composing.md) for how the intent, presentation, and aesthetic axes combine on any component.
|
|
864
826
|
|
|
865
|
-
Intent classes map color tokens into button tone slots.
|
|
866
|
-
[Presentation](docs/usage/composing.md#presentation) decides how much of that intent
|
|
867
|
-
reaches background, text, border, and hover.
|
|
827
|
+
Intent classes map color tokens into button tone slots. [Presentation](docs/usage/composing.md#presentation) decides how much of that intent reaches background, text, border, and hover.
|
|
868
828
|
|
|
869
829
|
Intent classes:
|
|
870
830
|
|
|
@@ -878,29 +838,23 @@ Intent classes:
|
|
|
878
838
|
| `.destructive`, `.danger`, `.error` | Destructive or error action. |
|
|
879
839
|
| `.info` | Informational action. |
|
|
880
840
|
|
|
881
|
-
Every component that supports intent accepts the same list and reads the
|
|
882
|
-
same [intent tokens](docs/usage/theming.md#intent-tokens), so a custom intent class
|
|
883
|
-
works everywhere without touching a component.
|
|
841
|
+
Every component that supports intent accepts the same list and reads the same [intent tokens](docs/usage/theming.md#intent-tokens), so a custom intent class works everywhere without touching a component.
|
|
884
842
|
|
|
885
|
-
`.neutral` is the only intent that does not fill all the way. Its color is
|
|
886
|
-
the page's own text color, so a full fill of it would be a black or white
|
|
887
|
-
slab — the loudest element on the page, for the intent that means nothing in
|
|
888
|
-
particular. It stops at `--intent-fill-max`, which is why a `.solid` neutral
|
|
889
|
-
is a quiet plate a step past `.soft` rather than a block of ink. Set the slot
|
|
890
|
-
on your own intent classes; see [Theming → Intent tokens](docs/usage/theming.md#intent-tokens).
|
|
843
|
+
`.neutral` is the only intent that does not fill all the way. Its color is the page's own text color, so a full fill of it would be a black or white slab — the loudest element on the page, for the intent that means nothing in particular. It stops at `--intent-fill-max`, which is why a `.solid` neutral is a quiet plate a step past `.soft` rather than a block of ink. Set the slot on your own intent classes; see [Theming → Intent tokens](docs/usage/theming.md#intent-tokens).
|
|
891
844
|
|
|
892
845
|
Size and shape classes:
|
|
893
846
|
|
|
894
|
-
| Class | Purpose
|
|
895
|
-
| ---------------------------------------------------------------------- |
|
|
896
|
-
| `.pill` | Fully rounded button corners (`border-radius: 9999px`).
|
|
897
|
-
| `.sm` | Smaller button.
|
|
898
|
-
| `.lg` | Larger button.
|
|
899
|
-
| `.p-
|
|
900
|
-
| `.p-
|
|
901
|
-
| `.
|
|
902
|
-
| `.
|
|
903
|
-
| `.
|
|
847
|
+
| Class | Purpose |
|
|
848
|
+
| ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
849
|
+
| `.pill` | Fully rounded button corners (`border-radius: 9999px`). |
|
|
850
|
+
| `.sm` | Smaller button. |
|
|
851
|
+
| `.lg` | Larger button. |
|
|
852
|
+
| `.p-xs`, `.dense` | Tightest padding modifier (`px-2 py-0.5`; icon `p-0.5`). Also drops the `--control-height` minimum so a chip-sized button fits a table cell or a dense toolbar; every other size and padding class keeps that floor. An icon-only button at this tier gives up its `min-width` too, so size the glyph yourself. |
|
|
853
|
+
| `.p-sm`, `.compact` | Compact padding modifier (`px-2.5 py-1`; icon `p-1`). |
|
|
854
|
+
| `.p-lg`, `.spacious` | Spacious padding modifier (`px-6 py-3`; icon `p-3`). |
|
|
855
|
+
| `.icon` | Square icon button. Use an accessible name in HTML. |
|
|
856
|
+
| `.loading` | Loading state. Hides text and shows CSS activity indicator. |
|
|
857
|
+
| `.disabled`, `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]` | Disabled styling. |
|
|
904
858
|
|
|
905
859
|
Examples:
|
|
906
860
|
|
|
@@ -913,233 +867,255 @@ Examples:
|
|
|
913
867
|
<button class="btn primary loading" disabled>Saving</button>
|
|
914
868
|
```
|
|
915
869
|
|
|
916
|
-
`.loading` is a state, not a color or presentation class. Prefer combining
|
|
917
|
-
it with disabled behavior so users cannot trigger duplicate work. Loading
|
|
918
|
-
buttons keep only opacity and transform transitions active so spinner and
|
|
919
|
-
surface colors stay synchronized when theme tokens change.
|
|
870
|
+
`.loading` is a state, not a color or presentation class. Prefer combining it with disabled behavior so users cannot trigger duplicate work. Loading buttons keep only opacity and transform transitions active so spinner and surface colors stay synchronized when theme tokens change.
|
|
920
871
|
|
|
921
|
-
On the base look a press scales the button down a little
|
|
922
|
-
(`--ui-active-transform`, `scale(0.97)`). [Aesthetics](docs/usage/aesthetics.md) swap
|
|
923
|
-
in their own press gesture, and `prefers-reduced-motion` turns it off.
|
|
872
|
+
On the base look a press scales the button down a little (`--ui-active-transform`, `scale(0.97)`). [Aesthetics](docs/usage/aesthetics.md) swap in their own press gesture, and `prefers-reduced-motion` turns it off.
|
|
924
873
|
|
|
925
|
-
Use `<button>` for actions or an accessible link for navigation; see
|
|
926
|
-
[Accessibility](docs/accessibility.md).
|
|
874
|
+
Use `<button>` for actions or an accessible link for navigation; see [Accessibility](docs/accessibility.md).
|
|
927
875
|
|
|
928
|
-
<!-- Source: docs/usage/
|
|
876
|
+
<!-- Source: docs/usage/forms.md -->
|
|
929
877
|
|
|
930
|
-
#
|
|
878
|
+
# Forms
|
|
931
879
|
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
880
|
+
| Class or Selector | Purpose |
|
|
881
|
+
| --------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
882
|
+
| `.field` | Vertical field wrapper. |
|
|
883
|
+
| `.label` | Form label text. |
|
|
884
|
+
| `.hint` | Secondary helper text. |
|
|
885
|
+
| `.hint.error` | Helper text with destructive intent. |
|
|
886
|
+
| `.surface` | Shared public container composition utility. |
|
|
887
|
+
| `.text-control` | Shared public text-control composition utility. |
|
|
888
|
+
| `.ipt` | Input control styling. |
|
|
889
|
+
| `.input-group` | Wrapper that owns the field box so a control can carry icons. |
|
|
890
|
+
| `.textarea` | Textarea control styling. |
|
|
891
|
+
| `.select` | Select control styling. |
|
|
892
|
+
| `input[type="checkbox"].checkbox` | Custom checkbox control styling. |
|
|
893
|
+
| `input[type="radio"].radio` | Custom radio control styling. |
|
|
894
|
+
| `input[type="checkbox"].switch` | Custom switch control styling. |
|
|
895
|
+
| `[aria-invalid="true"]` on controls | Destructive border and focus color. |
|
|
896
|
+
| `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]` on controls | Disabled styling. |
|
|
935
897
|
|
|
936
|
-
##
|
|
898
|
+
## Icons
|
|
899
|
+
|
|
900
|
+
No icon is shipped for text inputs — that's what this section covers. It used to paint one per input type as a `background-image` — a `data:` URI, which cannot read `currentColor` or a custom property, so every glyph shipped a light and a dark copy and a theme selector chose between them. That put icon artwork, and the package's only theme-by-selector branch, inside a CSS-only design system whose glyphs did not fit every aesthetic. Icons for `.input-group` are the consumer's to choose now.
|
|
901
|
+
|
|
902
|
+
This is separate from the toggle marks below and the alert icons in [Feedback](docs/usage/feedback.md#example): those are small, fixed, built-in glyphs — not a per-input icon system — and aren't affected by this change.
|
|
903
|
+
|
|
904
|
+
`.input-group` is the wrapper for a control that carries one. It owns the field box — border, radius, fill, focus ring, invalid and disabled state — and the control inside it goes flush, so the boundary is drawn once. Any icon element works, placed before the control for a leading icon or after it for a trailing one: an inline `<svg>`, an `<img>`, or a class from an icon set such as `@codenhub/icons`.
|
|
937
905
|
|
|
938
906
|
```html
|
|
939
|
-
<
|
|
940
|
-
<
|
|
941
|
-
<
|
|
942
|
-
|
|
943
|
-
|
|
907
|
+
<label class="field">
|
|
908
|
+
<span class="label">Email</span>
|
|
909
|
+
<div class="input-group">
|
|
910
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" aria-hidden="true">
|
|
911
|
+
<rect width="20" height="16" x="2" y="4" rx="2" />
|
|
912
|
+
<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
|
|
913
|
+
</svg>
|
|
914
|
+
<input class="ipt" type="email" />
|
|
915
|
+
</div>
|
|
916
|
+
</label>
|
|
917
|
+
<label class="field">
|
|
918
|
+
<span class="label">Search</span>
|
|
919
|
+
<div class="input-group">
|
|
920
|
+
<input class="ipt" type="search" />
|
|
921
|
+
<i class="ic-search" aria-hidden="true"></i>
|
|
922
|
+
</div>
|
|
923
|
+
</label>
|
|
944
924
|
```
|
|
945
925
|
|
|
946
|
-
|
|
947
|
-
a container sets the default look for its subtree and any element opts out.
|
|
926
|
+
The group reads intent and both [presentation](docs/usage/composing.md#presentation) axes the same way a lone `.ipt` does — `.input-group.soft.edgeless` is the sunk variant, `.input-group.primary` colors the boundary — and follows whichever [aesthetic](docs/usage/aesthetics.md) is in scope. `aria-invalid` or `disabled` on the control inside propagates to the group; so does either on the group itself. Focus is shown with `:focus-within`, so unlike a lone field the ring also appears on a mouse click.
|
|
948
927
|
|
|
949
|
-
|
|
950
|
-
element that shows the intent, because a container silently recoloring every
|
|
951
|
-
descendant is a trap rather than a feature — see
|
|
952
|
-
[Theming → Intent tokens](docs/usage/theming.md#intent-tokens). Use `.neutral` to opt
|
|
953
|
-
an element back out of an inherited intent context. Presentation and
|
|
954
|
-
[material tokens](docs/usage/customizing.md#material-tokens) do cascade, so a
|
|
955
|
-
container can set the look of its whole subtree while any element overrides
|
|
956
|
-
it.
|
|
928
|
+
Non-icon input types keep the browser's native `date` and `datetime-local` pickers. WebKit's native `search` decorations are still suppressed on `.text-control` to keep them from overlapping the value.
|
|
957
929
|
|
|
958
|
-
##
|
|
930
|
+
## Toggles
|
|
959
931
|
|
|
960
|
-
|
|
961
|
-
decide how much intent fills a component; `.edged` and `.edgeless` decide
|
|
962
|
-
whether it draws a boundary. They set
|
|
963
|
-
[presentation tokens](docs/usage/customizing.md#presentation-tokens) and nothing
|
|
964
|
-
else, so they work on the component itself or on any ancestor.
|
|
932
|
+
`.checkbox`, `.radio`, and `.switch` accept the same intent classes as buttons to set the checked color:
|
|
965
933
|
|
|
966
|
-
| Class
|
|
967
|
-
|
|
|
968
|
-
| `.
|
|
969
|
-
| `.
|
|
970
|
-
| `.
|
|
971
|
-
| `.
|
|
972
|
-
| `.
|
|
934
|
+
| Class | Meaning |
|
|
935
|
+
| ----------------------------------- | ----------------------- |
|
|
936
|
+
| `.neutral` _(default)_ | Text color, capped. |
|
|
937
|
+
| `.primary` | Primary color. |
|
|
938
|
+
| `.secondary` | Secondary/accent color. |
|
|
939
|
+
| `.success` | Success color. |
|
|
940
|
+
| `.warning` | Warning color. |
|
|
941
|
+
| `.destructive`, `.danger`, `.error` | Destructive color. |
|
|
942
|
+
| `.info` | Info color. |
|
|
973
943
|
|
|
974
|
-
|
|
944
|
+
All three toggles rest at `.solid`, and **`.ghost` is not supported on any of them.** An unchecked ghost toggle is the silhouette every toggle already has, and a checked one is a mark on nothing — a tick floating on the page, a dot with no ring around it. A container that cascades `.ghost` onto a toggle is floored rather than obeyed.
|
|
975
945
|
|
|
976
|
-
|
|
977
|
-
| ----------- | ----------- | ----------------- | ------------- |
|
|
978
|
-
| `.solid` | `100%` | `100%` | |
|
|
979
|
-
| `.soft` | `12%` | `0%` | |
|
|
980
|
-
| `.ghost` | `0%` | `0%` | |
|
|
981
|
-
| `.edged` | | | `100%` |
|
|
982
|
-
| `.edgeless` | | | `0%` |
|
|
946
|
+
Presentation decides the fill in both states. Being checked lifts the cap rather than pinning a fill, so the class still chooses:
|
|
983
947
|
|
|
984
|
-
|
|
948
|
+
| Toggle | unchecked | checked |
|
|
949
|
+
| ----------------- | --------------- | ------------------------------- |
|
|
950
|
+
| `.solid`, default | 20%, switch 40% | 100%, mark in the contrast tone |
|
|
951
|
+
| `.soft` | 12% | 12%, mark in the strong tone |
|
|
952
|
+
|
|
953
|
+
A checked checkbox and a checked switch cut their mark out of that plate. A checked radio thickens its ring to twice the resting line and takes the intent whole on it, so `.radio.soft` is the classic ring-and-dot radio and `.radio.solid` is a filled circle whose dot stays readable — the mark follows the plate rather than being pinned to the intent color.
|
|
954
|
+
|
|
955
|
+
## Text controls
|
|
956
|
+
|
|
957
|
+
Text controls also take intent, which colors the resting border and the focus-visible border, and both [presentation](docs/usage/composing.md#presentation) axes. `.ghost` fills nothing, `.soft` takes `12%`, and `.solid` takes `20%` — quiet enough that typed text still reads on it, and ordered so the louder name draws the stronger tint. None of them touches the line.
|
|
958
|
+
|
|
959
|
+
The boundary is the edge axis's, and it splits the same way. A container's `.edgeless` is floored, so a toolbar cannot leave a field with no mark of where typing goes. `.edgeless` on the control itself is honoured, which is how the borderless field is spelled — it does not meet WCAG 1.4.11 at rest, so it is opt-in and never a default, and the focus ring still shows.
|
|
985
960
|
|
|
986
961
|
```html
|
|
987
|
-
<
|
|
988
|
-
<
|
|
989
|
-
<
|
|
990
|
-
<
|
|
991
|
-
<
|
|
992
|
-
|
|
962
|
+
<input class="ipt success" placeholder="Valid" />
|
|
963
|
+
<input class="ipt ghost edged" placeholder="Outlined" />
|
|
964
|
+
<input class="ipt soft edged" placeholder="Tinted with a border" />
|
|
965
|
+
<input class="ipt soft edgeless" placeholder="Sunk into the page" />
|
|
966
|
+
<div class="soft">
|
|
967
|
+
<input class="ipt" placeholder="Tinted from the container, capped at 6%" />
|
|
968
|
+
</div>
|
|
969
|
+
<div class="edgeless">
|
|
970
|
+
<input class="ipt" placeholder="Keeps its line; the floor holds" />
|
|
971
|
+
</div>
|
|
993
972
|
```
|
|
994
973
|
|
|
995
|
-
|
|
996
|
-
Use `.solid.edgeless` for a filled box with no line — and prefer it on a
|
|
997
|
-
neutral one, because a capped fill leaves the box translucent and the edge
|
|
998
|
-
blend then paints a second coat of the same tint rather than disappearing
|
|
999
|
-
into it (measured 1.53:1 against its own plate in light, 1.82:1 in dark).
|
|
974
|
+
`.surface` is a public low-level utility. It is the box every container in the package composes: ghost, edged, surface radius, and the two slots only a surface resolves — the backdrop filter and the complete surface shadow. Use it to paint a container the package does not ship, under whichever aesthetic is in scope. Prefer `.card` or `.panel` when they fit.
|
|
1000
975
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
976
|
+
```html
|
|
977
|
+
<div class="surface glass">Blurred, translucent, glass corners</div>
|
|
978
|
+
<div class="surface pixel">Cut corners and an inset ring</div>
|
|
979
|
+
<div class="surface primary solid">Any intent, any presentation</div>
|
|
980
|
+
```
|
|
1006
981
|
|
|
1007
|
-
|
|
1008
|
-
buttons are filled, alerts and badges are tinted, surfaces and controls are
|
|
1009
|
-
neutral and bordered.
|
|
982
|
+
`.text-control` is a public low-level utility from the form entrypoint. It provides the shared control dimensions, border, placeholder, focus-visible, invalid, and disabled styles composed by `ipt`, `textarea`, and `select`. Use it for custom text-like controls; prefer those higher-level utilities when they fit.
|
|
1010
983
|
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
984
|
+
## Example
|
|
985
|
+
|
|
986
|
+
```html
|
|
987
|
+
<label class="field">
|
|
988
|
+
<span class="label">Email</span>
|
|
989
|
+
<input class="ipt" type="email" aria-invalid="true" aria-describedby="email-error" />
|
|
990
|
+
<span class="hint error" id="email-error">Enter a valid email.</span>
|
|
991
|
+
</label>
|
|
992
|
+
<label style="display: flex; gap: 0.5rem; align-items: center">
|
|
993
|
+
<input type="checkbox" class="checkbox success" />
|
|
994
|
+
<span>Accept terms</span>
|
|
995
|
+
</label>
|
|
996
|
+
<label style="display: flex; gap: 0.5rem; align-items: center">
|
|
997
|
+
<input type="radio" class="radio secondary" name="plan" />
|
|
998
|
+
<span>Standard plan</span>
|
|
999
|
+
</label>
|
|
1000
|
+
<label style="display: flex; gap: 0.5rem; align-items: center">
|
|
1001
|
+
<input type="checkbox" class="switch destructive" />
|
|
1002
|
+
<span>Enable</span>
|
|
1003
|
+
</label>
|
|
1004
|
+
```
|
|
1023
1005
|
|
|
1024
|
-
|
|
1025
|
-
text legible when a `.solid` container reaches a field nobody classed. A
|
|
1026
|
-
fill class written on the control itself names its own cap instead, because
|
|
1027
|
-
that is a consumer describing what they want: `.soft` takes `12%` and
|
|
1028
|
-
`.solid` takes `20%`. A switch caps at `40%`, where its three fills separate
|
|
1029
|
-
far enough to read on a track.
|
|
1006
|
+
Use labels, `type`, validation logic, `aria-describedby`, and error message relationships; see [Accessibility](docs/accessibility.md).
|
|
1030
1007
|
|
|
1031
|
-
|
|
1032
|
-
| ----------------- | ---- |
|
|
1033
|
-
| `.ghost` | 0% |
|
|
1034
|
-
| cascaded `.solid` | 6% |
|
|
1035
|
-
| `.soft` | 12% |
|
|
1036
|
-
| `.solid` | 20% |
|
|
1008
|
+
<!-- Source: docs/usage/feedback.md -->
|
|
1037
1009
|
|
|
1038
|
-
|
|
1039
|
-
element's own is honoured — except on `.checkbox` and `.radio`, which never
|
|
1040
|
-
drop their line at all. See [Forms](docs/usage/forms.md) for the full toggle and text
|
|
1041
|
-
control reference.
|
|
1042
|
-
|
|
1043
|
-
A tooltip bubble is filled, over a tinted ground. An intent fills it with
|
|
1044
|
-
that intent's own color: `.tooltip.primary` is the primary color, black on a
|
|
1045
|
-
light page and white on a dark one, and `.tooltip.destructive` is a red
|
|
1046
|
-
bubble.
|
|
1047
|
-
|
|
1048
|
-
With no intent the bubble is `--color-tooltip`, the one plate in the package
|
|
1049
|
-
chosen per theme rather than derived from an intent. Composed like
|
|
1050
|
-
everything else it was `20%` of the page's ink over the surface tone, which
|
|
1051
|
-
steps _lighter_ than the surface on a dark page and _darker_ on a light
|
|
1052
|
-
one — so the dark bubble read as lifted and the light one as a mid-grey
|
|
1053
|
-
slab two steps darker than every card on the screen. The token states each
|
|
1054
|
-
direction instead: near-white over a light page, a mid grey over a dark
|
|
1055
|
-
one. `--color-tooltip-contrast` is its ink.
|
|
1056
|
-
|
|
1057
|
-
Near-white is only 1.04:1 against a light page, so the bubble draws a
|
|
1058
|
-
hairline as well, and floors it: a container's `.solid` or `.edgeless`
|
|
1059
|
-
cannot take the boundary away from a bubble nobody classed, while
|
|
1060
|
-
`.tooltip.edgeless` still can. The ground keeps the bubble opaque at every
|
|
1061
|
-
fill, so a cascaded presentation leaves it readable over whatever it floats
|
|
1062
|
-
above. It reads the material tokens too, so an [aesthetic](docs/usage/aesthetics.md)
|
|
1063
|
-
in scope shapes the bubble like any other component. See
|
|
1064
|
-
[Tooltips](docs/usage/tooltips.md) for the full tooltip reference.
|
|
1010
|
+
# Feedback
|
|
1065
1011
|
|
|
1066
|
-
|
|
1012
|
+
| Class | Purpose |
|
|
1013
|
+
| ---------------- | ---------------------------------------------------------------------------- |
|
|
1014
|
+
| `.alert` | Inline feedback surface. |
|
|
1015
|
+
| `.icon` | Subclass of `.alert`. Adds a corresponding intent icon and padding. |
|
|
1016
|
+
| `.badge` | Compact status pill. |
|
|
1017
|
+
| `.loader-mask` | Low-level activity indicator composition utility. Applies the spinner mask. |
|
|
1018
|
+
| `.loader` | Standalone inline loader artwork. |
|
|
1019
|
+
| `.skeleton` | Ambient loading placeholder. |
|
|
1020
|
+
| `.progress` | Progress track. Uses `--progress-value` variable. |
|
|
1021
|
+
| `.active` | Optional on `.progress` to add a track shimmer. |
|
|
1022
|
+
| `.indeterminate` | Optional on `.progress` to animate a moving fill without `--progress-value`. |
|
|
1023
|
+
|
|
1024
|
+
Activity indicator modifier classes compose with `.loader`:
|
|
1067
1025
|
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1026
|
+
| Class | Animation style |
|
|
1027
|
+
| ---------------------- | --------------------------------------- |
|
|
1028
|
+
| _(default)_ | Circular spinner (rotating arc). |
|
|
1029
|
+
| `.dots-wave` | Three dots bouncing up/down in a wave. |
|
|
1030
|
+
| `.dots-fade` | Three dots fading in and out. |
|
|
1031
|
+
| `.dots-queue` | Dot queuing from left to right. |
|
|
1032
|
+
| `.dots-rotate` | Side dots rotating around a center dot. |
|
|
1033
|
+
| `.dots-grow` | Three dots growing and shrinking. |
|
|
1034
|
+
| `.dots-grow-alternate` | Outer dots small, center dot pulses. |
|
|
1035
|
+
| `.dot-bounce` | Single dot bouncing with squash effect. |
|
|
1036
|
+
| `.bars-wave` | Three vertical bars scaling in a wave. |
|
|
1037
|
+
| `.pulse-ring` | Two concentric rings pulsing outward. |
|
|
1072
1038
|
|
|
1073
|
-
|
|
1074
|
-
the class changes what the component computes, which
|
|
1075
|
-
`tests/browser/axes.spec.ts` asserts against `registry.json` in both
|
|
1076
|
-
directions: an axis marked `Yes` must move, and an axis marked `No` must not.
|
|
1039
|
+
These variants retain their embedded SVG animations normally. Under `prefers-reduced-motion: reduce`, loader CSS substitutes a corresponding static mask. This fallback is part of focused loader, button, and components imports; it does not depend on the global reset. See [Accessibility](docs/accessibility.md).
|
|
1077
1040
|
|
|
1078
|
-
|
|
1079
|
-
| --------------------------------------------------------- | ------ | ---- | ---- | ------------------ |
|
|
1080
|
-
| `.btn`, `.alert`, `.badge`, `.card`, `.panel` | Yes | Yes | Yes | Shape |
|
|
1081
|
-
| `.loader` | Yes | No | No | No |
|
|
1082
|
-
| `.kbd`, `.data-table` | Yes | Yes | Yes | Radius and edge |
|
|
1083
|
-
| `.quote` | Yes | Yes | Yes | Edge width |
|
|
1084
|
-
| `.divider`, `.skeleton` | Yes | No | No | No |
|
|
1085
|
-
| `.ipt`, `.textarea`, `.select`, `.text-control` | Yes | Yes | Yes | Shape |
|
|
1086
|
-
| `.input-group` | Yes | Yes | Yes | Shape |
|
|
1087
|
-
| `.surface` | Yes | Yes | Yes | Shape |
|
|
1088
|
-
| `.checkbox`, `.radio` | Yes | Yes | No | Radius and edge |
|
|
1089
|
-
| `.switch` | Yes | Yes | Yes | Radius and edge |
|
|
1090
|
-
| `.progress` | Yes | No | No | No |
|
|
1091
|
-
| `.code`, `.pre` | Yes | Yes | Yes | Radius and clip |
|
|
1092
|
-
| `.tooltip` | Yes | Yes | Yes | Shape and overlay |
|
|
1093
|
-
| `.table-wrap`, `.quote-inline`, layout and text utilities | No | No | No | No |
|
|
1041
|
+
Loader size modifiers:
|
|
1094
1042
|
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1043
|
+
| Class | Size |
|
|
1044
|
+
| -------- | ----------------- |
|
|
1045
|
+
| _(none)_ | Default (`2rem`). |
|
|
1046
|
+
| `.sm` | Small (`1.5rem`). |
|
|
1047
|
+
| `.lg` | Large (`2.5rem`). |
|
|
1099
1048
|
|
|
1100
|
-
|
|
1101
|
-
a `.edgeless` toolbar will not erase the line of a field nobody classed, while
|
|
1102
|
-
`.ipt.edgeless` is a consumer describing what they want and gets it.
|
|
1049
|
+
Alerts, badges, progress bars, skeletons, and loaders accept `.primary`, `.secondary`, `.success`, `.warning`, `.destructive`, `.danger`, `.error`, and `.info`. Without an intent, they use the text palette, except `.loader`, which keeps `currentColor` so it matches whatever content surrounds it.
|
|
1103
1050
|
|
|
1104
|
-
|
|
1105
|
-
`.destructive`; they do not add component behavior. State and modifier
|
|
1106
|
-
classes such as `.interactive`, `.loading`, `.invalid`, `.compact`, and
|
|
1107
|
-
`.vertical` sit above this map and are documented with their component.
|
|
1051
|
+
Skeletons, loaders, progress bars, and dividers are indicators. They read intent but ignore fill and edge [presentation](docs/usage/composing.md#presentation).
|
|
1108
1052
|
|
|
1109
|
-
|
|
1053
|
+
```html
|
|
1054
|
+
<span class="loader success" aria-hidden="true"></span> <span class="skeleton info"></span>
|
|
1055
|
+
```
|
|
1110
1056
|
|
|
1111
|
-
|
|
1112
|
-
[aesthetic](docs/usage/aesthetics.md) draws depth or one of these classes asks for it.
|
|
1057
|
+
`.icon` is a subclass of `.alert`. When applied as `.alert.icon`, it increases the left padding and adds an embedded SVG. Success, warning, and destructive intents use corresponding symbols; other intents use the information symbol.
|
|
1113
1058
|
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1059
|
+
Alerts and badges read the shared [presentation](docs/usage/composing.md#presentation) classes. Without one they use a tinted surface, intent-colored text, and a mixed intent border.
|
|
1060
|
+
|
|
1061
|
+
## Example
|
|
1062
|
+
|
|
1063
|
+
```html
|
|
1064
|
+
<div class="alert success" role="status">Saved successfully.</div>
|
|
1065
|
+
<div class="alert primary solid" role="status">Deployment started.</div>
|
|
1066
|
+
<div class="alert warning soft icon" role="status">Review required.</div>
|
|
1067
|
+
<div class="alert destructive ghost edged" role="alert">Deployment failed.</div>
|
|
1068
|
+
<span class="badge warning">Queued</span>
|
|
1069
|
+
<span class="badge success solid">Live</span>
|
|
1070
|
+
<span class="badge info soft">Draft</span>
|
|
1071
|
+
<span class="loader" aria-hidden="true"></span>
|
|
1072
|
+
<span class="loader dots-wave" aria-hidden="true"></span>
|
|
1073
|
+
<span class="loader dots-fade" aria-hidden="true"></span>
|
|
1074
|
+
<span class="loader bars-wave" aria-hidden="true"></span>
|
|
1075
|
+
<span class="loader pulse-ring sm" aria-hidden="true"></span>
|
|
1076
|
+
<span class="loader dots-grow lg" aria-hidden="true"></span>
|
|
1077
|
+
<div class="progress" role="progressbar" aria-label="Upload progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="64" style="--progress-value: 64%"></div>
|
|
1078
|
+
<div class="progress secondary active" role="progressbar" aria-label="Upload progress" aria-valuemin="0" aria-valuemax="100" aria-valuenow="64" style="--progress-value: 64%"></div>
|
|
1079
|
+
<div class="progress info indeterminate" role="progressbar" aria-label="Loading" aria-valuemin="0" aria-valuemax="100"></div>
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
Add `role="status"` or `role="alert"` to alerts based on announcement urgency, mark decorative loading visuals with `aria-hidden="true"`, and use semantic progress elements or ARIA values when numeric progress must be announced; see [Accessibility](docs/accessibility.md).
|
|
1083
|
+
|
|
1084
|
+
<!-- Source: docs/usage/tooltips.md -->
|
|
1085
|
+
|
|
1086
|
+
# Tooltips
|
|
1087
|
+
|
|
1088
|
+
| Class or Attribute | Purpose |
|
|
1089
|
+
| --------------------------------------- | -------------------------------------------------------------- |
|
|
1090
|
+
| `.tooltip` | Tooltip host. Uses `data-tooltip` as pseudo-element content. |
|
|
1091
|
+
| `.tooltip.tooltip-icon` | Circular icon-style tooltip host. |
|
|
1092
|
+
| `[data-tooltip-position="top"]` | Positions tooltip above host. |
|
|
1093
|
+
| `[data-tooltip-position="bottom"]` | Positions tooltip below host. |
|
|
1094
|
+
| `[data-tooltip-position="left"]` | Positions tooltip left of host. |
|
|
1095
|
+
| `[data-tooltip-position="right"]` | Positions tooltip right of host. |
|
|
1096
|
+
| No `data-tooltip-position` | Defaults to top placement. |
|
|
1097
|
+
| `[data-state="open"]` | Shows tooltip without hover. |
|
|
1098
|
+
| `.tooltip.raised` / `.tooltip.floating` | Adds one or two units of depth. The bubble is flat by default. |
|
|
1099
|
+
|
|
1100
|
+
A tooltip bubble's fill, ground color, and floor behavior are covered in [Composing → Presentation](docs/usage/composing.md#presentation), and its material follows whichever [aesthetic](docs/usage/aesthetics.md) is in scope, including the pseudo-element itself.
|
|
1119
1101
|
|
|
1120
|
-
|
|
1121
|
-
and `.raised` are aliases, not a canonical form and a deprecated one, the way
|
|
1122
|
-
`.destructive` and `.danger` are on the intent axis. The `none`/`sm`/`md`
|
|
1123
|
-
naming matches the raw `--elevation-*` tokens in
|
|
1124
|
-
[Theming](docs/usage/theming.md#foundation-tokens) for the same weight of depth, even
|
|
1125
|
-
though the two are read from different places.
|
|
1102
|
+
The bubble rests flat. It draws no shadow of its own on a plain page, and zeroes an aesthetic's part-based depth (such as `.neobrutalism`'s slab) the same way `.flat` does elsewhere. Add [`.raised` or `.floating`](docs/usage/composing.md#elevation) to lift it — `.tooltip.floating` is the pre-0.1.0 look. An aesthetic whose shadow is a complete value, like `.glass`, still reaches the bubble as it reaches any surface.
|
|
1126
1103
|
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
class decides how much of it this element takes.
|
|
1104
|
+
Intent works on a tooltip the same way it works on a filled component: `.tooltip.primary` fills the bubble with the primary color, black text on a light page and white on a dark one; `.tooltip.destructive` is a red bubble with the same logic. With no intent, the bubble uses `--color-tooltip`, a plate chosen per theme rather than derived from an intent — near-white in light, mid-grey in dark; see [Composing → Presentation](docs/usage/composing.md#presentation) for why.
|
|
1105
|
+
|
|
1106
|
+
## Example
|
|
1131
1107
|
|
|
1132
1108
|
```html
|
|
1133
|
-
<
|
|
1134
|
-
<
|
|
1135
|
-
<
|
|
1109
|
+
<button class="tooltip" data-tooltip="Saved 2 minutes ago">Status</button>
|
|
1110
|
+
<button class="tooltip" data-tooltip="Opens in a new tab" data-tooltip-position="bottom">Docs</button>
|
|
1111
|
+
<button class="tooltip primary raised" data-tooltip="Primary intent, lifted a step">Deploy</button>
|
|
1112
|
+
<button class="tooltip" data-tooltip="Always visible, no hover needed" data-state="open">Pinned</button>
|
|
1113
|
+
<button class="tooltip tooltip-icon" data-tooltip="More details" data-tooltip-position="right" aria-label="More details">?</button>
|
|
1136
1114
|
```
|
|
1137
1115
|
|
|
1138
|
-
The
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
that draws its edge as an inset ring spends spread on it and scaling that
|
|
1142
|
-
would erase the edge.
|
|
1116
|
+
The first two show plain hosts with default (top) and explicit bottom placement. The third combines an intent with `.raised` to show they compose freely — the intent decides the bubble's fill, `.raised` decides whether it casts depth. The fourth uses `data-state="open"` to keep a tooltip visible without a hover or focus interaction, useful for a tooltip that should be demonstrated or tested without simulating pointer input. The fifth is the circular icon variant.
|
|
1117
|
+
|
|
1118
|
+
CSS pseudo-element tooltips are presentational. They are not a complete accessible tooltip implementation by themselves — provide accessible names/descriptions outside the CSS; see [Accessibility](docs/accessibility.md).
|
|
1143
1119
|
|
|
1144
1120
|
<!-- Source: docs/usage/content-and-layout.md -->
|
|
1145
1121
|
|
|
@@ -1147,26 +1123,18 @@ would erase the edge.
|
|
|
1147
1123
|
|
|
1148
1124
|
## Layout
|
|
1149
1125
|
|
|
1150
|
-
Layout helpers use the shared `--layout-gap` token. `.tight` sets it to
|
|
1151
|
-
`0.5rem` and `.loose` sets it to `1.5rem` within a view, stack, cluster, or
|
|
1152
|
-
auto-grid.
|
|
1126
|
+
Layout helpers use the shared `--layout-gap` token. `.tight` sets it to `0.5rem` and `.loose` sets it to `1.5rem` within a view, stack, cluster, or auto-grid.
|
|
1153
1127
|
|
|
1154
|
-
- `.view` is a flex container; `.vertical` and `.horizontal` set its
|
|
1155
|
-
direction, and horizontal views wrap with centered cross-axis alignment.
|
|
1128
|
+
- `.view` is a flex container; `.vertical` and `.horizontal` set its direction, and horizontal views wrap with centered cross-axis alignment.
|
|
1156
1129
|
- `.stack` is a vertical flex stack.
|
|
1157
|
-
- `.cluster` is a wrapping horizontal flex row; `.between` adds
|
|
1158
|
-
`space-between` alignment.
|
|
1130
|
+
- `.cluster` is a wrapping horizontal flex row; `.between` adds `space-between` alignment.
|
|
1159
1131
|
- `.auto-grid` is a responsive auto-fit grid using `--layout-grid-min`.
|
|
1160
|
-
- `.tight` and `.loose` set the shared gap to `0.5rem` or `1.5rem` on views,
|
|
1161
|
-
stacks, clusters, and auto-grids.
|
|
1132
|
+
- `.tight` and `.loose` set the shared gap to `0.5rem` or `1.5rem` on views, stacks, clusters, and auto-grids.
|
|
1162
1133
|
- `.section` adds responsive block padding and an inline gutter.
|
|
1163
|
-
- `.section-content` centers content at `--container-max`; `.narrow` and
|
|
1164
|
-
|
|
1165
|
-
- `.divider` is horizontal; `.vertical` makes it self-stretch vertically. It
|
|
1166
|
-
takes intent, but presentation classes do not affect it.
|
|
1134
|
+
- `.section-content` centers content at `--container-max`; `.narrow` and `.wide` select the corresponding container tokens.
|
|
1135
|
+
- `.divider` is horizontal; `.vertical` makes it self-stretch vertically. It takes intent, but presentation classes do not affect it.
|
|
1167
1136
|
|
|
1168
|
-
The removed `--layout-stack-gap` and `--layout-cluster-gap` tokens have no
|
|
1169
|
-
compatibility aliases.
|
|
1137
|
+
The removed `--layout-stack-gap` and `--layout-cluster-gap` tokens have no compatibility aliases.
|
|
1170
1138
|
|
|
1171
1139
|
## Content
|
|
1172
1140
|
|
|
@@ -1184,8 +1152,7 @@ compatibility aliases.
|
|
|
1184
1152
|
|
|
1185
1153
|
### Table rules
|
|
1186
1154
|
|
|
1187
|
-
A table draws three kinds of line, and `.ruled` and `.ruleless` move all of
|
|
1188
|
-
them together:
|
|
1155
|
+
A table draws three kinds of line, and `.ruled` and `.ruleless` move all of them together:
|
|
1189
1156
|
|
|
1190
1157
|
| Class | Head and foot boundaries | Rules between body rows |
|
|
1191
1158
|
| ----------- | ------------------------ | ----------------------- |
|
|
@@ -1194,36 +1161,32 @@ them together:
|
|
|
1194
1161
|
| `.ruled` | Yes | Yes |
|
|
1195
1162
|
|
|
1196
1163
|
```html
|
|
1197
|
-
<table class="data-table">
|
|
1198
|
-
|
|
1199
|
-
|
|
1164
|
+
<table class="data-table">
|
|
1165
|
+
Head and foot boundaries only
|
|
1166
|
+
</table>
|
|
1167
|
+
<table class="data-table ruled">
|
|
1168
|
+
Every row separated
|
|
1169
|
+
</table>
|
|
1170
|
+
<table class="data-table ruleless">
|
|
1171
|
+
No lines inside the table at all
|
|
1172
|
+
</table>
|
|
1200
1173
|
```
|
|
1201
1174
|
|
|
1202
|
-
The boundaries under a head and above a foot separate the parts of a table
|
|
1203
|
-
from each other, so they are drawn by default where the row rules are not.
|
|
1204
|
-
Rules between body rows used to arrive on their own, because the
|
|
1205
|
-
component's published edge default is `edged` and the edge axis wrote the
|
|
1206
|
-
rules along with the boundary — so whether you got them depended on a
|
|
1207
|
-
registry default rather than on anything in your markup.
|
|
1175
|
+
The boundaries under a head and above a foot separate the parts of a table from each other, so they are drawn by default where the row rules are not. Rules between body rows used to arrive on their own, because the component's published edge default is `edged` and the edge axis wrote the rules along with the boundary — so whether you got them depended on a registry default rather than on anything in your markup.
|
|
1208
1176
|
|
|
1209
|
-
`--ui-rule` is the token behind both classes, so a container can set the
|
|
1210
|
-
answer for a whole region without classing each table:
|
|
1177
|
+
`--ui-rule` is the token behind both classes, so a container can set the answer for a whole region without classing each table:
|
|
1211
1178
|
|
|
1212
1179
|
```html
|
|
1213
1180
|
<section style="--ui-rule: 100%">
|
|
1214
|
-
<table class="data-table">
|
|
1181
|
+
<table class="data-table">
|
|
1182
|
+
Ruled by the region
|
|
1183
|
+
</table>
|
|
1215
1184
|
</section>
|
|
1216
1185
|
```
|
|
1217
1186
|
|
|
1218
|
-
The frame around the table is the edge axis and is asked for the same way:
|
|
1219
|
-
`.data-table` publishes `edgeless`, so `.edged` draws one. None of the
|
|
1220
|
-
three switches reaches the others — `.data-table.ruleless.edged` is a
|
|
1221
|
-
framed table with no lines inside it, and `.data-table.ruled` is a
|
|
1222
|
-
frameless one with every row separated.
|
|
1187
|
+
The frame around the table is the edge axis and is asked for the same way: `.data-table` publishes `edgeless`, so `.edged` draws one. None of the three switches reaches the others — `.data-table.ruleless.edged` is a framed table with no lines inside it, and `.data-table.ruled` is a frameless one with every row separated.
|
|
1223
1188
|
|
|
1224
|
-
A table's rows deliberately inherit its intent instead of resetting it, so
|
|
1225
|
-
`.data-table.success` tints throughout. A row carrying its own intent still
|
|
1226
|
-
wins:
|
|
1189
|
+
A table's rows deliberately inherit its intent instead of resetting it, so `.data-table.success` tints throughout. A row carrying its own intent still wins:
|
|
1227
1190
|
|
|
1228
1191
|
```html
|
|
1229
1192
|
<table class="data-table success">
|
|
@@ -1238,37 +1201,28 @@ wins:
|
|
|
1238
1201
|
</table>
|
|
1239
1202
|
```
|
|
1240
1203
|
|
|
1241
|
-
This is the one place intent cascades, because a table's rows are parts of
|
|
1242
|
-
the table rather than independent components.
|
|
1204
|
+
This is the one place intent cascades, because a table's rows are parts of the table rather than independent components.
|
|
1243
1205
|
|
|
1244
|
-
`.data-table`, `.kbd`, `.code`, and `.pre` also read
|
|
1245
|
-
[presentation](docs/usage/composing.md#presentation). A table applies it to its
|
|
1246
|
-
header, its rules and its border; a chip to its whole plate:
|
|
1206
|
+
`.data-table`, `.kbd`, `.code`, and `.pre` also read [presentation](docs/usage/composing.md#presentation). A table applies it to its header, its rules and its border; a chip to its whole plate:
|
|
1247
1207
|
|
|
1248
1208
|
```html
|
|
1249
|
-
<table class="data-table success soft edged"
|
|
1250
|
-
|
|
1209
|
+
<table class="data-table success soft edged">
|
|
1210
|
+
...
|
|
1211
|
+
</table>
|
|
1212
|
+
<table class="data-table">
|
|
1213
|
+
A ghost table: rules and type, no header plate
|
|
1214
|
+
</table>
|
|
1251
1215
|
<kbd class="kbd primary solid">Ctrl</kbd>
|
|
1252
1216
|
<kbd class="kbd primary soft edged">Shift</kbd>
|
|
1253
1217
|
```
|
|
1254
1218
|
|
|
1255
|
-
`.ghost` means two different things on these components, and both are worth
|
|
1256
|
-
knowing before you reach for it.
|
|
1219
|
+
`.ghost` means two different things on these components, and both are worth knowing before you reach for it.
|
|
1257
1220
|
|
|
1258
|
-
On `.data-table` it removes the header plate along with the body tint, so
|
|
1259
|
-
`.data-table.ghost` is boundaries and type alone. The component rests at
|
|
1260
|
-
`soft`, so that is something to ask for rather than the default.
|
|
1221
|
+
On `.data-table` it removes the header plate along with the body tint, so `.data-table.ghost` is boundaries and type alone. The component rests at `soft`, so that is something to ask for rather than the default.
|
|
1261
1222
|
|
|
1262
|
-
On `.kbd`, `.code`, and `.pre` it is **not supported**. All three rest on
|
|
1263
|
-
`--intent-subtle`, and that ground draws the plate whatever the fill says —
|
|
1264
|
-
so `.ghost` took the fill away and changed nothing visible. Worse, the
|
|
1265
|
-
ground alone is a near-page tint: a ghost chip measured the same `#e5e5e5`
|
|
1266
|
-
for neutral and primary on the light page, and `#f5f5f5` at 1.04:1 against
|
|
1267
|
-
it for secondary. All three rest at `.soft` instead, which puts a real `12%`
|
|
1268
|
-
of the intent over the ground and separates them.
|
|
1223
|
+
On `.kbd`, `.code`, and `.pre` it is **not supported**. All three rest on `--intent-subtle`, and that ground draws the plate whatever the fill says — so `.ghost` took the fill away and changed nothing visible. Worse, the ground alone is a near-page tint: a ghost chip measured the same `#e5e5e5` for neutral and primary on the light page, and `#f5f5f5` at 1.04:1 against it for secondary. All three rest at `.soft` instead, which puts a real `12%` of the intent over the ground and separates them.
|
|
1269
1224
|
|
|
1270
|
-
Use `.table-wrap` around `.data-table` when table width may exceed its
|
|
1271
|
-
container:
|
|
1225
|
+
Use `.table-wrap` around `.data-table` when table width may exceed its container:
|
|
1272
1226
|
|
|
1273
1227
|
```html
|
|
1274
1228
|
<div class="table-wrap">
|
|
@@ -1291,38 +1245,34 @@ container:
|
|
|
1291
1245
|
|
|
1292
1246
|
## Surfaces
|
|
1293
1247
|
|
|
1294
|
-
| Class | Purpose
|
|
1295
|
-
| -------------------- |
|
|
1296
|
-
| `.card` | Bordered container, surface radius, padded. Rests at elevation `1`.
|
|
1297
|
-
| `.panel` | Flush container for sidebars, toolbars, and wells. No elevation.
|
|
1298
|
-
| `.interactive` | On `.card`. Adds pointer cursor, hover and press response, and a focus ring.
|
|
1299
|
-
| `.
|
|
1300
|
-
| `.
|
|
1301
|
-
| `.
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
at elevation `1` is not a visible shadow by itself — nothing draws depth
|
|
1307
|
-
|
|
1308
|
-
`.
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
On the base look, `.card.interactive` scales down slightly on press
|
|
1312
|
-
(`--ui-active-transform`, `scale(0.97)`); an [aesthetic](docs/usage/aesthetics.md)
|
|
1313
|
-
substitutes its own press gesture, and `prefers-reduced-motion` turns it off.
|
|
1248
|
+
| Class | Purpose |
|
|
1249
|
+
| -------------------- | ------------------------------------------------------------------------------------- |
|
|
1250
|
+
| `.card` | Bordered container, surface radius, padded. Rests at elevation `1`. |
|
|
1251
|
+
| `.panel` | Flush container for sidebars, toolbars, and wells. No elevation. |
|
|
1252
|
+
| `.interactive` | On `.card`. Adds pointer cursor, hover and press response, and a focus ring. |
|
|
1253
|
+
| `.hoverable` | On `.card`. The hover half of `.interactive`: hover response only, no pointer cursor. |
|
|
1254
|
+
| `.pressable` | On `.card`. The press half of `.interactive`: press response and pointer cursor. |
|
|
1255
|
+
| `.p-xs`, `.dense` | On `.card` or `.panel`. Reduces padding further than `.compact`. |
|
|
1256
|
+
| `.p-sm`, `.compact` | On `.card` or `.panel`. Reduces padding. |
|
|
1257
|
+
| `.p-lg`, `.spacious` | On `.card` or `.panel`. Increases padding. |
|
|
1258
|
+
| `.flush` | On `.card` or `.panel`. Removes padding, for edge-to-edge content. |
|
|
1259
|
+
|
|
1260
|
+
Both read intent, [presentation](docs/usage/composing.md#presentation), and [material tokens](docs/usage/customizing.md#material-tokens). A plain `.card` is a neutral bordered container; only an explicit presentation tints it. Resting at elevation `1` is not a visible shadow by itself — nothing draws depth until an [aesthetic](docs/usage/aesthetics.md) supplies shadow geometry or `.elevation-sm`/`.elevation-md` asks for it; see [Composing → Elevation](docs/usage/composing.md#elevation).
|
|
1261
|
+
|
|
1262
|
+
On the base look, `.card.interactive` scales down slightly on press (`--ui-active-transform`, `scale(0.97)`); an [aesthetic](docs/usage/aesthetics.md) substitutes its own press gesture, and `prefers-reduced-motion` turns it off.
|
|
1263
|
+
|
|
1264
|
+
`.interactive` is the pair `.hoverable` (hover response only, no pointer cursor) and `.pressable` (press response and pointer cursor) applied together. Take one half for a card that answers a single gesture: a card that warms on hover but holds its own action in a nested button takes `.hoverable`, so pressing that button does not dip the whole card.
|
|
1314
1265
|
|
|
1315
1266
|
```html
|
|
1316
1267
|
<article class="card">Neutral card</article>
|
|
1317
1268
|
<article class="card success soft">Tinted success card</article>
|
|
1318
1269
|
<article class="card primary ghost edged">Intent border, no fill</article>
|
|
1319
1270
|
<a class="card interactive" href="/package">Responds to hover and press</a>
|
|
1271
|
+
<article class="card hoverable">Warms on hover; the action is a nested button</article>
|
|
1320
1272
|
<aside class="panel">Flush panel</aside>
|
|
1321
1273
|
```
|
|
1322
1274
|
|
|
1323
|
-
`.interactive`
|
|
1324
|
-
an accessible name; a `<div class="card interactive">` is not focusable or
|
|
1325
|
-
operable by keyboard.
|
|
1275
|
+
`.interactive` and `.pressable` are styling only. Use a real interactive element and give it an accessible name; a `<div class="card interactive">` is not focusable or operable by keyboard.
|
|
1326
1276
|
|
|
1327
1277
|
## Typography utilities
|
|
1328
1278
|
|
|
@@ -1339,784 +1289,388 @@ All typography classes and `.selection-contrast` are `@utility` classes.
|
|
|
1339
1289
|
| `.text-body` | Default body copy. |
|
|
1340
1290
|
| `.selection-contrast` | Inverts `::selection` colors to primary-contrast background. |
|
|
1341
1291
|
|
|
1342
|
-
<!-- Source: docs/
|
|
1292
|
+
<!-- Source: docs/integrating/index.md -->
|
|
1343
1293
|
|
|
1344
|
-
#
|
|
1294
|
+
# Integrating
|
|
1345
1295
|
|
|
1346
|
-
|
|
1347
|
-
decide what a component is made of. Aesthetic tokens are the small set of
|
|
1348
|
-
named knobs a shipped aesthetic exposes to scale its own look.
|
|
1296
|
+
This package has no JavaScript and no framework bindings; see [Introduction](docs/index.md#what-it-does-not-do). Integrating it into a framework is entirely about where that framework lets you load a global stylesheet, and whether the project runs Tailwind CSS v4.
|
|
1349
1297
|
|
|
1350
|
-
##
|
|
1298
|
+
## The shared model
|
|
1351
1299
|
|
|
1352
|
-
|
|
1353
|
-
never _which_ intent it shows. They are unitless numbers and percentages, so
|
|
1354
|
-
they carry no color and inherit safely: a container sets them once and every
|
|
1355
|
-
component below resolves them against its own intent.
|
|
1300
|
+
Every stack does the same two imports, from the same kind of place — a root layout, an app entry file, or a global CSS file, never a page or a component further down the tree:
|
|
1356
1301
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
| `--ui-fill` | Percentage of the intent color mixed into the background. |
|
|
1360
|
-
| `--ui-fg-on-fill` | Percentage blended from the intent readable tone toward its contrast tone. |
|
|
1361
|
-
| `--ui-border` | Percentage of the intent color mixed into the border color. |
|
|
1302
|
+
1. One [entrypoint](docs/setup.md#import-paths) — the compiled `@codenhub/styles` for any build, or `@codenhub/styles/tw` when the project already runs Tailwind CSS v4.
|
|
1303
|
+
2. `@codenhub/styles/aesthetics` (or `/tw/aesthetics`) after it, only if the project uses an [aesthetic](docs/usage/aesthetics.md).
|
|
1362
1304
|
|
|
1363
|
-
|
|
1364
|
-
is derived by adding `--hover-step` to the resting fill and using
|
|
1365
|
-
`--intent-hover`; there are no per-presentation hover tokens.
|
|
1305
|
+
Importing from one place matters for two reasons. Some frameworks only _allow_ global CSS from a designated root file and fail the build otherwise — Next.js's Pages Router is one, see [Next.js → Troubleshooting](docs/integrating/nextjs.md#troubleshooting). Where a framework allows it more broadly, as Next.js's App Router does, importing from the root remains the recommended choice for predictable CSS ordering — and importing per-component instead would load the same reset and token rules once per component rather than once per app.
|
|
1366
1306
|
|
|
1367
|
-
|
|
1368
|
-
filled box with no line is `.solid.edgeless`, which is worth reaching for on
|
|
1369
|
-
a neutral component: neutral caps its fill, so the box stays translucent and
|
|
1370
|
-
a border over it paints a second coat of the same tint instead of blending
|
|
1371
|
-
into it.
|
|
1307
|
+
## Which guide to follow
|
|
1372
1308
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1309
|
+
| Stack | Guide |
|
|
1310
|
+
| ---------------------------------------- | -------------------------------- |
|
|
1311
|
+
| A Tailwind CSS v4 project on any bundler | [Tailwind CSS v4](docs/integrating/tailwind.md) |
|
|
1312
|
+
| Next.js / React | [Next.js](docs/integrating/nextjs.md) |
|
|
1313
|
+
| Vue | [Vue](docs/integrating/vue.md) |
|
|
1314
|
+
| Svelte / SvelteKit | [Svelte](docs/integrating/svelte.md) |
|
|
1315
|
+
| Astro | [Astro](docs/integrating/astro.md) |
|
|
1376
1316
|
|
|
1377
|
-
|
|
1378
|
-
background token lets a tinted surface adapt to whatever it is placed on.
|
|
1379
|
-
Mixing in `oklab` keeps the wide-gamut token palette intact and blends
|
|
1380
|
-
perceptually, where `srgb` would clip it.
|
|
1317
|
+
A project with no framework — a plain Vite, webpack, or Parcel build — needs nothing beyond [Setup → Quick start](docs/setup.md#quick-start): import the compiled stylesheet from the project's existing global CSS entry.
|
|
1381
1318
|
|
|
1382
|
-
|
|
1383
|
-
rather than the token's own `oklch` syntax. It is the same color; code that
|
|
1384
|
-
compares computed color strings should compare colors instead.
|
|
1319
|
+
## Verifying it worked
|
|
1385
1320
|
|
|
1386
|
-
|
|
1387
|
-
> overrides set these tokens; components only read them. Setting a value
|
|
1388
|
-
> that no presentation class produces is supported but unvalidated. See
|
|
1389
|
-
> [Composing](docs/usage/composing.md) for the classes that ship these values.
|
|
1321
|
+
After the import, render one styled element and confirm it picked up the package's tokens rather than the browser default:
|
|
1390
1322
|
|
|
1391
|
-
|
|
1323
|
+
```html
|
|
1324
|
+
<button class="btn primary">Continue</button>
|
|
1325
|
+
```
|
|
1392
1326
|
|
|
1393
|
-
|
|
1394
|
-
intent it shows or how strongly. They control shape, borders, shadows,
|
|
1395
|
-
translucency, filters, and transforms.
|
|
1327
|
+
A rounded, filled button in the primary color means the stylesheet loaded. Unstyled browser-default text most often means the import specifier didn't resolve — check the [import paths table](docs/setup.md#import-paths) for the exact one your entrypoint needs, and confirm your build tooling resolves package CSS imports at all, see [Setup → Requirements](docs/setup.md#requirements).
|
|
1396
1328
|
|
|
1397
|
-
|
|
1398
|
-
default look. Setting them on a container restyles the whole subtree. Only
|
|
1399
|
-
shadow geometry is split into colorless parts that inherit safely;
|
|
1400
|
-
color-capable inputs such as `--ui-ink` and `--ui-surface-shadow` may
|
|
1401
|
-
include their own colors.
|
|
1329
|
+
<!-- Source: docs/integrating/tailwind.md -->
|
|
1402
1330
|
|
|
1403
|
-
|
|
1404
|
-
| ----------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------- |
|
|
1405
|
-
| `--ui-radius` | Corner radius for controls. | `--radius-control` |
|
|
1406
|
-
| `--ui-radius-surface` | Corner radius for surfaces. | `--radius-surface` |
|
|
1407
|
-
| `--ui-border-width` | Edge thickness. | `--border-width` |
|
|
1408
|
-
| `--ui-border-max` | Ceiling on computed edge width. | `100px` |
|
|
1409
|
-
| `--ui-ink` | Neutral line color when no intent is set. | `--color-border` |
|
|
1410
|
-
| `--ui-rule` | Lines inside a table. Unset draws the head and foot boundaries only; `0%` draws none; `100%` rules every row. | unset |
|
|
1411
|
-
| `--ui-shadow-x` | Shadow horizontal offset. | `0px` |
|
|
1412
|
-
| `--ui-shadow-y` | Shadow vertical offset. | `0px` |
|
|
1413
|
-
| `--ui-shadow-blur` | Shadow blur radius. | `0px` |
|
|
1414
|
-
| `--ui-shadow-spread` | Shadow spread radius. | `0px` |
|
|
1415
|
-
| `--ui-shadow-inset` | The `inset` keyword for an inner ring. | Empty |
|
|
1416
|
-
| `--ui-hover-shadow-x` | Shadow horizontal offset while hovered. | `--ui-shadow-x` |
|
|
1417
|
-
| `--ui-hover-shadow-y` | Shadow vertical offset while hovered. | `--ui-shadow-y` |
|
|
1418
|
-
| `--ui-active-shadow-x` | Shadow horizontal offset while pressed. | `--ui-shadow-x` |
|
|
1419
|
-
| `--ui-active-shadow-y` | Shadow vertical offset while pressed. | `--ui-shadow-y` |
|
|
1420
|
-
| `--ui-active-transform` | Transform while pressed. `none` under `prefers-reduced-motion`. | `scale(0.97)` |
|
|
1421
|
-
| `--ui-shadow-ink` | Percentage of shadow color taken from intent ink. | `0%` |
|
|
1422
|
-
| `--ui-shadow-edge` | Declared, even empty, when the shadow is the element's edge rather than its depth. Read for presence. | Unset |
|
|
1423
|
-
| `--ui-elevation` | Unitless multiplier over shadow geometry. | `1` |
|
|
1424
|
-
| `--ui-surface-shadow` | Complete multi-layer shadow accepted by surfaces only. | Unset |
|
|
1425
|
-
| `--ui-surface-ground` | Ground a surface sits on. | `--color-background` |
|
|
1426
|
-
| `--ui-bg-alpha` | Multiplier over fill for translucent materials. | `1` |
|
|
1427
|
-
| `--ui-backdrop` | Backdrop filter accepted by surfaces only. | `none` |
|
|
1428
|
-
| `--ui-hover-transform` | Transform while an interactive element is hovered. | `none` |
|
|
1429
|
-
| `--ui-clip` | Structural component silhouette. | `none` |
|
|
1430
|
-
| `--ui-clip-tight` | Compact component silhouette. | `--ui-clip` |
|
|
1431
|
-
| `--ui-focus-inset` | Inset focus layer width. | Unset |
|
|
1331
|
+
# Tailwind CSS v4
|
|
1432
1332
|
|
|
1433
|
-
|
|
1434
|
-
<section style="--ui-radius: 0; --ui-border-width: 3px">
|
|
1435
|
-
<button class="btn primary">Square and heavy</button>
|
|
1436
|
-
<input class="ipt" placeholder="Matches" />
|
|
1437
|
-
</section>
|
|
1438
|
-
```
|
|
1333
|
+
A project that already runs Tailwind CSS v4 can process this package's source instead of its compiled output, so both sets of classes compile through the same Tailwind build.
|
|
1439
1334
|
|
|
1440
|
-
|
|
1441
|
-
> consumer overrides set them.
|
|
1335
|
+
## Why source instead of compiled
|
|
1442
1336
|
|
|
1443
|
-
|
|
1337
|
+
`/tw` entrypoints publish copied, uncompiled source from `dist/tw`; your own Tailwind build compiles it alongside your app, so its `@theme`, `@utility`, and `@apply` directives resolve together with yours. The compiled entrypoints (`@codenhub/styles`) still work in a Tailwind project, but then two separate CSS pipelines run side by side instead of one — use `/tw` unless a specific reason rules it out.
|
|
1444
1338
|
|
|
1445
|
-
|
|
1446
|
-
a clip can replace the border with an inset shadow by setting
|
|
1447
|
-
`--ui-shadow-inset` and the four shadow geometry parts. Set
|
|
1448
|
-
`--ui-border-max: 0px` when that ring replaces the component border.
|
|
1449
|
-
Focusable components restore the clipped focus outline through
|
|
1450
|
-
`--ui-focus-inset`.
|
|
1451
|
-
|
|
1452
|
-
Declare `--ui-shadow-edge` when that ring _is_ the border. The ring then
|
|
1453
|
-
takes the element's edge color, which carries the edge axis as its alpha, so
|
|
1454
|
-
`.edged` draws it and `.edgeless` does not — the same answer a real border
|
|
1455
|
-
gives. Without it the ring paints on every component the aesthetic reaches
|
|
1456
|
-
and the edge classes have no effect. Use `--ui-shadow-ink` instead when the
|
|
1457
|
-
shadow is depth cast in the intent's own ink, such as a hard offset slab,
|
|
1458
|
-
which an `.edgeless` element still gets.
|
|
1459
|
-
|
|
1460
|
-
The token is read for its presence, not its value: declare it empty to
|
|
1461
|
-
switch the ring on, and `initial` to switch it back off in an aesthetic
|
|
1462
|
-
nested inside one that declares it.
|
|
1339
|
+
## Import the source entrypoint
|
|
1463
1340
|
|
|
1464
1341
|
```css
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
--ui-shadow-inset: inset;
|
|
1470
|
-
--ui-shadow-edge: ;
|
|
1471
|
-
--ui-shadow-x: 0px;
|
|
1472
|
-
--ui-shadow-y: 0px;
|
|
1473
|
-
--ui-shadow-blur: 0px;
|
|
1474
|
-
--ui-shadow-spread: 4px;
|
|
1475
|
-
--ui-focus-inset: var(--focus-ring-width);
|
|
1476
|
-
}
|
|
1342
|
+
@import "tailwindcss";
|
|
1343
|
+
@import "@codenhub/styles/tw";
|
|
1344
|
+
|
|
1345
|
+
@source "./src";
|
|
1477
1346
|
```
|
|
1478
1347
|
|
|
1479
|
-
|
|
1480
|
-
read them; only the `--ui-*` inputs above are public.
|
|
1348
|
+
Tailwind CSS v4 scans your project automatically — most projects need nothing beyond the two imports above. `@source` paths resolve relative to the CSS file that declares them, not your project root, so `./src` here means "the `src/` next to this stylesheet"; adjust it to match where your own global stylesheet actually lives. Add `@source` only for markup Tailwind's automatic scan won't reach on its own: a path excluded by default (`.gitignore`d, or inside `node_modules` — an external component library, for instance) or, in a monorepo, one outside this file's own directory tree. Point it at your app's markup, not at this package — `/tw` already ships every class definition it publishes, so scanning it too only slows the build without adding classes.
|
|
1481
1349
|
|
|
1482
|
-
##
|
|
1350
|
+
## Add aesthetics
|
|
1483
1351
|
|
|
1484
|
-
|
|
1485
|
-
Only aesthetics with a token listed below expose an aesthetic-specific
|
|
1486
|
-
token. Tune all other behavior through the shared material tokens above.
|
|
1487
|
-
Listed tokens are available only where that aesthetic's stylesheet is
|
|
1488
|
-
imported.
|
|
1352
|
+
Add an aesthetic from the source entrypoint the same way as the compiled one, after the base import:
|
|
1489
1353
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
| `--glass-radius-surface` | `.glass` | Surface corner radius. | `1rem` |
|
|
1495
|
-
| `--pixel-unit` | `.pixel` | One pixel of the grid. The corner cut and the ring are one. | `4px` |
|
|
1496
|
-
| `--font-pixel` | `.pixel` | Consumer-supplied pixel font stack. | Falls back to the monospace stack |
|
|
1497
|
-
| `--tile-radius` | `.chunky-tile` | Corner radius, on controls and surfaces alike. | `0.75rem` |
|
|
1498
|
-
| `--tile-lift` | `.chunky-tile` | Depth of the seated bar, and how far a press travels. | `4px` |
|
|
1499
|
-
| `--font-rounded` | `.chunky-tile` | Consumer-supplied rounded font stack. | Falls back to the page stack |
|
|
1500
|
-
|
|
1501
|
-
All four aesthetics reach the same way: each knob is _read_ with its default
|
|
1502
|
-
as a `var()` fallback rather than declared, so it resolves once into a
|
|
1503
|
-
private on the aesthetic's own class (`--_pixel-unit`, `--_neo-offset`,
|
|
1504
|
-
`--_tile-radius`, `--_tile-lift`, and so on). Set a knob on the element
|
|
1505
|
-
carrying the aesthetic class, or on any ancestor including `:root`:
|
|
1354
|
+
```css
|
|
1355
|
+
@import "tailwindcss";
|
|
1356
|
+
@import "@codenhub/styles/tw";
|
|
1357
|
+
@import "@codenhub/styles/tw/aesthetics";
|
|
1506
1358
|
|
|
1507
|
-
|
|
1508
|
-
<section class="pixel" style="--pixel-unit: 6px">
|
|
1509
|
-
<button class="btn primary">Chunkier</button>
|
|
1510
|
-
</section>
|
|
1359
|
+
@source "./src";
|
|
1511
1360
|
```
|
|
1512
1361
|
|
|
1513
|
-
|
|
1514
|
-
<html class="pixel" style="--pixel-unit: 6px">
|
|
1515
|
-
<body>
|
|
1516
|
-
<button class="btn primary">Also chunkier, set from the root</button>
|
|
1517
|
-
</body>
|
|
1518
|
-
</html>
|
|
1519
|
-
```
|
|
1362
|
+
## Using a focused entrypoint
|
|
1520
1363
|
|
|
1521
|
-
|
|
1522
|
-
apart matters. A knob resolves once at the aesthetic's own class and
|
|
1523
|
-
inherits down already-resolved, so it reaches the aesthetic **from above**:
|
|
1524
|
-
setting it on the element or any ancestor works, but setting it on a
|
|
1525
|
-
_descendant_ of the aesthetic class changes nothing — the value has already
|
|
1526
|
-
been read. `--ui-radius` and the other material tokens above are read fresh
|
|
1527
|
-
by each component as it draws, so they reach **at or below** the element
|
|
1528
|
-
carrying them, which is how you round one card differently from its
|
|
1529
|
-
neighbours without touching the knob at all.
|
|
1364
|
+
Import a focused `/tw/*` entrypoint instead of the combined one — such as `/tw/button` or `/tw/form` — when a build only needs one component family; see the full [import path table](docs/setup.md#import-paths) for what each one composes.
|
|
1530
1365
|
|
|
1531
|
-
|
|
1532
|
-
`.pixel` set `--ui-ink` for their neutral outline; intent classes still
|
|
1533
|
-
override the intent slots on each component.
|
|
1366
|
+
## Troubleshooting
|
|
1534
1367
|
|
|
1535
|
-
|
|
1368
|
+
**Classes resolve to no styling**
|
|
1536
1369
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
public token contract.
|
|
1370
|
+
- **What happened:** components use documented classes like `.btn.primary`, but no styling appears even though `@import "@codenhub/styles/tw"` is in the stylesheet.
|
|
1371
|
+
- **Why:** this is rarely `@source` itself — Tailwind already scans your project automatically. The more common cause is markup living somewhere that automatic scan excludes by default: a `.gitignore`d path, or a component pulled from `node_modules`. Tailwind may not see a class used only there and skips generating a rule for it.
|
|
1372
|
+
- **Fix:** add an explicit `@source` pointing at that directory, resolved relative to this stylesheet — matching the [example above](#import-the-source-entrypoint).
|
|
1541
1373
|
|
|
1542
|
-
|
|
1543
|
-
elevation, radius, layout, and focus tokens first. The only supported
|
|
1544
|
-
component-scoped input is `--progress-value` on the `.progress` element,
|
|
1545
|
-
because consumers must provide a value such as `64%`.
|
|
1374
|
+
**Duplicate token and reset rules**
|
|
1546
1375
|
|
|
1547
|
-
|
|
1548
|
-
|
|
1376
|
+
- **What happened:** the built stylesheet is larger than expected, and browser devtools show the same custom properties or reset rules defined twice.
|
|
1377
|
+
- **Why:** importing both a compiled entrypoint (`@codenhub/styles`) and a `/tw` entrypoint (`@codenhub/styles/tw`) in the same build compiles the same tokens and reset from two independent sources; Tailwind's build has no way to know they describe the same package.
|
|
1378
|
+
- **Fix:** pick one path per project — `/tw` entrypoints for a project running Tailwind CSS v4, compiled entrypoints everywhere else.
|
|
1549
1379
|
|
|
1550
|
-
|
|
1551
|
-
look and its documented exceptions.
|
|
1380
|
+
Tailwind CSS 4 or newer is required for every `/tw` entrypoint.
|
|
1552
1381
|
|
|
1553
|
-
<!-- Source: docs/
|
|
1382
|
+
<!-- Source: docs/integrating/nextjs.md -->
|
|
1554
1383
|
|
|
1555
|
-
#
|
|
1384
|
+
# Next.js
|
|
1556
1385
|
|
|
1557
|
-
|
|
1558
|
-
| ---------------- | ---------------------------------------------------------------------------- |
|
|
1559
|
-
| `.alert` | Inline feedback surface. |
|
|
1560
|
-
| `.icon` | Subclass of `.alert`. Adds a corresponding intent icon and padding. |
|
|
1561
|
-
| `.badge` | Compact status pill. |
|
|
1562
|
-
| `.loader-mask` | Low-level activity indicator composition utility. Applies the spinner mask. |
|
|
1563
|
-
| `.loader` | Standalone inline loader artwork. |
|
|
1564
|
-
| `.skeleton` | Ambient loading placeholder. |
|
|
1565
|
-
| `.progress` | Progress track. Uses `--progress-value` variable. |
|
|
1566
|
-
| `.active` | Optional on `.progress` to add a track shimmer. |
|
|
1567
|
-
| `.indeterminate` | Optional on `.progress` to animate a moving fill without `--progress-value`. |
|
|
1386
|
+
Next.js has two router architectures, and they treat global CSS differently:
|
|
1568
1387
|
|
|
1569
|
-
|
|
1388
|
+
- **App Router** (an `app/` directory): global CSS — including an external package's stylesheet like this one — can be imported from any layout, page, or component under `app/`. Importing it from the root layout is only a recommendation, for predictable CSS ordering across routes; Next.js does not enforce it and no error occurs if you import it elsewhere.
|
|
1389
|
+
- **Pages Router** (a `pages/` directory, no `app/`): global CSS is restricted to `pages/_app.tsx`. Importing it from anywhere else fails the build — Next.js enforces this itself, not this package; see [Troubleshooting](#troubleshooting).
|
|
1390
|
+
- **Both directories present** (mid-migration): import the stylesheet in both root files. The two routers serve their own routes independently, so a route under `pages/` never sees a stylesheet imported only in `app/layout.tsx`, and vice versa.
|
|
1570
1391
|
|
|
1571
|
-
|
|
1572
|
-
| ---------------------- | --------------------------------------- |
|
|
1573
|
-
| _(default)_ | Circular spinner (rotating arc). |
|
|
1574
|
-
| `.dots-wave` | Three dots bouncing up/down in a wave. |
|
|
1575
|
-
| `.dots-fade` | Three dots fading in and out. |
|
|
1576
|
-
| `.dots-queue` | Dot queuing from left to right. |
|
|
1577
|
-
| `.dots-rotate` | Side dots rotating around a center dot. |
|
|
1578
|
-
| `.dots-grow` | Three dots growing and shrinking. |
|
|
1579
|
-
| `.dots-grow-alternate` | Outer dots small, center dot pulses. |
|
|
1580
|
-
| `.dot-bounce` | Single dot bouncing with squash effect. |
|
|
1581
|
-
| `.bars-wave` | Three vertical bars scaling in a wave. |
|
|
1582
|
-
| `.pulse-ring` | Two concentric rings pulsing outward. |
|
|
1392
|
+
## Import the stylesheet
|
|
1583
1393
|
|
|
1584
|
-
|
|
1585
|
-
`prefers-reduced-motion: reduce`, loader CSS substitutes a corresponding
|
|
1586
|
-
static mask. This fallback is part of focused loader, button, and components
|
|
1587
|
-
imports; it does not depend on the global reset. See
|
|
1588
|
-
[Accessibility](docs/accessibility.md).
|
|
1394
|
+
Add the import to the root file for your router:
|
|
1589
1395
|
|
|
1590
|
-
|
|
1396
|
+
**App Router**
|
|
1591
1397
|
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1398
|
+
```tsx
|
|
1399
|
+
// app/layout.tsx
|
|
1400
|
+
import "@codenhub/styles";
|
|
1401
|
+
|
|
1402
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
1403
|
+
return (
|
|
1404
|
+
<html lang="en">
|
|
1405
|
+
<body>{children}</body>
|
|
1406
|
+
</html>
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
```
|
|
1597
1410
|
|
|
1598
|
-
|
|
1599
|
-
`.secondary`, `.success`, `.warning`, `.destructive`, `.danger`, `.error`,
|
|
1600
|
-
and `.info`. Without an intent, they use the text palette, except `.loader`,
|
|
1601
|
-
which keeps `currentColor` so it matches whatever content surrounds it.
|
|
1411
|
+
**Pages Router**
|
|
1602
1412
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1413
|
+
```tsx
|
|
1414
|
+
// pages/_app.tsx
|
|
1415
|
+
import "@codenhub/styles";
|
|
1416
|
+
import type { AppProps } from "next/app";
|
|
1605
1417
|
|
|
1606
|
-
|
|
1607
|
-
<
|
|
1608
|
-
|
|
1418
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
1419
|
+
return <Component {...pageProps} />;
|
|
1420
|
+
}
|
|
1609
1421
|
```
|
|
1610
1422
|
|
|
1611
|
-
|
|
1612
|
-
increases the left padding and adds an embedded SVG. Success, warning, and
|
|
1613
|
-
destructive intents use corresponding symbols; other intents use the
|
|
1614
|
-
information symbol.
|
|
1423
|
+
Running Tailwind CSS v4? `@import "@codenhub/styles/tw"` is a CSS directive, so it belongs in a CSS file, not a bare import in `layout.tsx`/`_app.tsx` — add it (with `@import "tailwindcss"` and, if needed, `@source`) to your global CSS file, and import that file from the same root file shown above instead. See [Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
1615
1424
|
|
|
1616
|
-
|
|
1617
|
-
classes. Without one they use a tinted surface, intent-colored text, and a
|
|
1618
|
-
mixed intent border.
|
|
1425
|
+
## Force a theme
|
|
1619
1426
|
|
|
1620
|
-
|
|
1427
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
1621
1428
|
|
|
1622
|
-
```
|
|
1623
|
-
<
|
|
1624
|
-
<div class="alert primary solid" role="status">Deployment started.</div>
|
|
1625
|
-
<div class="alert warning soft icon" role="status">Review required.</div>
|
|
1626
|
-
<div class="alert destructive ghost edged" role="alert">Deployment failed.</div>
|
|
1627
|
-
<span class="badge warning">Queued</span>
|
|
1628
|
-
<span class="badge success solid">Live</span>
|
|
1629
|
-
<span class="badge info soft">Draft</span>
|
|
1630
|
-
<span class="loader" aria-hidden="true"></span>
|
|
1631
|
-
<span class="loader dots-wave" aria-hidden="true"></span>
|
|
1632
|
-
<span class="loader dots-fade" aria-hidden="true"></span>
|
|
1633
|
-
<span class="loader bars-wave" aria-hidden="true"></span>
|
|
1634
|
-
<span class="loader pulse-ring sm" aria-hidden="true"></span>
|
|
1635
|
-
<span class="loader dots-grow lg" aria-hidden="true"></span>
|
|
1636
|
-
<div
|
|
1637
|
-
class="progress"
|
|
1638
|
-
role="progressbar"
|
|
1639
|
-
aria-label="Upload progress"
|
|
1640
|
-
aria-valuemin="0"
|
|
1641
|
-
aria-valuemax="100"
|
|
1642
|
-
aria-valuenow="64"
|
|
1643
|
-
style="--progress-value: 64%"
|
|
1644
|
-
></div>
|
|
1645
|
-
<div
|
|
1646
|
-
class="progress secondary active"
|
|
1647
|
-
role="progressbar"
|
|
1648
|
-
aria-label="Upload progress"
|
|
1649
|
-
aria-valuemin="0"
|
|
1650
|
-
aria-valuemax="100"
|
|
1651
|
-
aria-valuenow="64"
|
|
1652
|
-
style="--progress-value: 64%"
|
|
1653
|
-
></div>
|
|
1654
|
-
<div
|
|
1655
|
-
class="progress info indeterminate"
|
|
1656
|
-
role="progressbar"
|
|
1657
|
-
aria-label="Loading"
|
|
1658
|
-
aria-valuemin="0"
|
|
1659
|
-
aria-valuemax="100"
|
|
1660
|
-
></div>
|
|
1429
|
+
```tsx
|
|
1430
|
+
<html lang="en" className="dark">
|
|
1661
1431
|
```
|
|
1662
1432
|
|
|
1663
|
-
|
|
1664
|
-
urgency, mark decorative loading visuals with `aria-hidden="true"`, and use
|
|
1665
|
-
semantic progress elements or ARIA values when numeric progress must be
|
|
1666
|
-
announced; see [Accessibility](docs/accessibility.md).
|
|
1433
|
+
## Troubleshooting
|
|
1667
1434
|
|
|
1668
|
-
|
|
1435
|
+
**Pages Router build fails with "Global CSS cannot be imported from files other than your Custom `<App>`"**
|
|
1669
1436
|
|
|
1670
|
-
|
|
1437
|
+
- **What happened:** Next.js rejected a global CSS `import` statement outside `pages/_app.tsx`. This restriction is specific to the Pages Router — Next.js enforces it itself, not this package, and it applies to any global CSS import, not specifically to `@codenhub/styles`. It does not apply to the App Router, where the same import works from any layout, page, or component.
|
|
1438
|
+
- **Why:** the Pages Router has no per-route CSS boundary the way the App Router does, so Next.js requires one predictable file for global stylesheets to avoid ordering conflicts between pages.
|
|
1439
|
+
- **Fix:** move the `import "@codenhub/styles"` line to `pages/_app.tsx`, and remove it from wherever it currently is.
|
|
1671
1440
|
|
|
1672
|
-
|
|
1673
|
-
| --------------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
1674
|
-
| `.field` | Vertical field wrapper. |
|
|
1675
|
-
| `.label` | Form label text. |
|
|
1676
|
-
| `.hint` | Secondary helper text. |
|
|
1677
|
-
| `.hint.error` | Helper text with destructive intent. |
|
|
1678
|
-
| `.surface` | Shared public container composition utility. |
|
|
1679
|
-
| `.text-control` | Shared public text-control composition utility. |
|
|
1680
|
-
| `.ipt` | Input control styling. |
|
|
1681
|
-
| `.input-group` | Wrapper that owns the field box so a control can carry icons. |
|
|
1682
|
-
| `.textarea` | Textarea control styling. |
|
|
1683
|
-
| `.select` | Select control styling. |
|
|
1684
|
-
| `input[type="checkbox"].checkbox` | Custom checkbox control styling. |
|
|
1685
|
-
| `input[type="radio"].radio` | Custom radio control styling. |
|
|
1686
|
-
| `input[type="checkbox"].switch` | Custom switch control styling. |
|
|
1687
|
-
| `[aria-invalid="true"]` on controls | Destructive border and focus color. |
|
|
1688
|
-
| `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]` on controls | Disabled styling. |
|
|
1441
|
+
## See also
|
|
1689
1442
|
|
|
1690
|
-
|
|
1443
|
+
- [Setup → Import paths](docs/setup.md#import-paths): every entrypoint this package publishes.
|
|
1444
|
+
- [Usage](docs/usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
1691
1445
|
|
|
1692
|
-
|
|
1693
|
-
`background-image` — a `data:` URI, which cannot read `currentColor` or a
|
|
1694
|
-
custom property, so every glyph shipped a light and a dark copy and a theme
|
|
1695
|
-
selector chose between them. That put icon artwork, and the package's only
|
|
1696
|
-
theme-by-selector branch, inside a CSS-only design system whose glyphs did
|
|
1697
|
-
not fit every aesthetic. Icons are the consumer's to choose now.
|
|
1446
|
+
<!-- Source: docs/integrating/vue.md -->
|
|
1698
1447
|
|
|
1699
|
-
|
|
1700
|
-
field box — border, radius, fill, focus ring, invalid and disabled state —
|
|
1701
|
-
and the control inside it goes flush, so the boundary is drawn once. Any
|
|
1702
|
-
icon element works, placed before the control for a leading icon or after it
|
|
1703
|
-
for a trailing one: an inline `<svg>`, an `<img>`, or a class from an icon
|
|
1704
|
-
set such as `@codenhub/icons`.
|
|
1448
|
+
# Vue
|
|
1705
1449
|
|
|
1706
|
-
|
|
1707
|
-
<label class="field">
|
|
1708
|
-
<span class="label">Email</span>
|
|
1709
|
-
<div class="input-group">
|
|
1710
|
-
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" aria-hidden="true">
|
|
1711
|
-
<rect width="20" height="16" x="2" y="4" rx="2" />
|
|
1712
|
-
<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
|
|
1713
|
-
</svg>
|
|
1714
|
-
<input class="ipt" type="email" />
|
|
1715
|
-
</div>
|
|
1716
|
-
</label>
|
|
1717
|
-
<label class="field">
|
|
1718
|
-
<span class="label">Search</span>
|
|
1719
|
-
<div class="input-group">
|
|
1720
|
-
<input class="ipt" type="search" />
|
|
1721
|
-
<i class="ic-search" aria-hidden="true"></i>
|
|
1722
|
-
</div>
|
|
1723
|
-
</label>
|
|
1724
|
-
```
|
|
1450
|
+
Vue places no restriction on where CSS is imported from, but importing it once, from the app's entry file, keeps the reset and tokens from loading more than once and guarantees they're in place before any component renders.
|
|
1725
1451
|
|
|
1726
|
-
|
|
1727
|
-
axes the same way a lone `.ipt` does — `.input-group.soft.edgeless` is the
|
|
1728
|
-
sunk variant, `.input-group.primary` colors the boundary — and follows
|
|
1729
|
-
whichever [aesthetic](docs/usage/aesthetics.md) is in scope. `aria-invalid` or
|
|
1730
|
-
`disabled` on the control inside propagates to the group; so does either on
|
|
1731
|
-
the group itself. Focus is shown with `:focus-within`, so unlike a lone
|
|
1732
|
-
field the ring also appears on a mouse click.
|
|
1452
|
+
## Import the stylesheet
|
|
1733
1453
|
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1454
|
+
```ts
|
|
1455
|
+
// main.ts
|
|
1456
|
+
import "@codenhub/styles";
|
|
1457
|
+
import { createApp } from "vue";
|
|
1458
|
+
import App from "./App.vue";
|
|
1737
1459
|
|
|
1738
|
-
|
|
1460
|
+
createApp(App).mount("#app");
|
|
1461
|
+
```
|
|
1739
1462
|
|
|
1740
|
-
|
|
1741
|
-
buttons to set the checked color:
|
|
1463
|
+
Running Tailwind CSS v4? Import `@codenhub/styles/tw` from a CSS entry file instead of `main.ts`, using the `@tailwindcss/vite` plugin — see [Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
1742
1464
|
|
|
1743
|
-
|
|
1744
|
-
| ----------------------------------- | ----------------------- |
|
|
1745
|
-
| `.neutral` _(default)_ | Text color, capped. |
|
|
1746
|
-
| `.primary` | Primary color. |
|
|
1747
|
-
| `.secondary` | Secondary/accent color. |
|
|
1748
|
-
| `.success` | Success color. |
|
|
1749
|
-
| `.warning` | Warning color. |
|
|
1750
|
-
| `.destructive`, `.danger`, `.error` | Destructive color. |
|
|
1751
|
-
| `.info` | Info color. |
|
|
1465
|
+
## Force a theme
|
|
1752
1466
|
|
|
1753
|
-
|
|
1754
|
-
them.** An unchecked ghost toggle is the silhouette every toggle already
|
|
1755
|
-
has, and a checked one is a mark on nothing — a tick floating on the page, a
|
|
1756
|
-
dot with no ring around it. A container that cascades `.ghost` onto a
|
|
1757
|
-
toggle is floored rather than obeyed.
|
|
1467
|
+
Apply `.dark` or `.light` on the root element to force a theme instead of following the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
1758
1468
|
|
|
1759
|
-
|
|
1760
|
-
rather than pinning a fill, so the class still chooses:
|
|
1469
|
+
## See also
|
|
1761
1470
|
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
| `.solid`, default | 20%, switch 40% | 100%, mark in the contrast tone |
|
|
1765
|
-
| `.soft` | 12% | 12%, mark in the strong tone |
|
|
1471
|
+
- [Setup → Import paths](docs/setup.md#import-paths): every entrypoint this package publishes.
|
|
1472
|
+
- [Usage](docs/usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
1766
1473
|
|
|
1767
|
-
|
|
1768
|
-
checked radio thickens its ring to twice the resting line and takes the
|
|
1769
|
-
intent whole on it, so `.radio.soft` is the classic ring-and-dot radio and
|
|
1770
|
-
`.radio.solid` is a filled circle whose dot stays readable — the mark
|
|
1771
|
-
follows the plate rather than being pinned to the intent color.
|
|
1474
|
+
<!-- Source: docs/integrating/svelte.md -->
|
|
1772
1475
|
|
|
1773
|
-
|
|
1476
|
+
# Svelte
|
|
1774
1477
|
|
|
1775
|
-
|
|
1776
|
-
focus-visible border, and both [presentation](docs/usage/composing.md#presentation)
|
|
1777
|
-
axes. `.ghost` fills nothing, `.soft` takes `12%`, and `.solid` takes `20%`
|
|
1778
|
-
— quiet enough that typed text still reads on it, and ordered so the louder
|
|
1779
|
-
name draws the stronger tint. None of them touches the line.
|
|
1478
|
+
## Import the stylesheet
|
|
1780
1479
|
|
|
1781
|
-
|
|
1782
|
-
`.edgeless` is floored, so a toolbar cannot leave a field with no mark of
|
|
1783
|
-
where typing goes. `.edgeless` on the control itself is honoured, which is
|
|
1784
|
-
how the borderless field is spelled — it does not meet WCAG 1.4.11 at rest,
|
|
1785
|
-
so it is opt-in and never a default, and the focus ring still shows.
|
|
1480
|
+
**SvelteKit** — import from the root layout so it loads once for every route:
|
|
1786
1481
|
|
|
1787
|
-
```
|
|
1788
|
-
|
|
1789
|
-
<
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
<div class="edgeless">
|
|
1796
|
-
<input class="ipt" placeholder="Keeps its line; the floor holds" />
|
|
1797
|
-
</div>
|
|
1482
|
+
```svelte
|
|
1483
|
+
<!-- src/routes/+layout.svelte -->
|
|
1484
|
+
<script>
|
|
1485
|
+
import "@codenhub/styles";
|
|
1486
|
+
let { children } = $props();
|
|
1487
|
+
</script>
|
|
1488
|
+
|
|
1489
|
+
{@render children()}
|
|
1798
1490
|
```
|
|
1799
1491
|
|
|
1800
|
-
|
|
1801
|
-
the package composes: ghost, edged, surface radius, and the two slots only
|
|
1802
|
-
a surface resolves — the backdrop filter and the complete surface shadow.
|
|
1803
|
-
Use it to paint a container the package does not ship, under whichever
|
|
1804
|
-
aesthetic is in scope. Prefer `.card` or `.panel` when they fit.
|
|
1492
|
+
**Plain Svelte + Vite** — import from the entry file instead:
|
|
1805
1493
|
|
|
1806
|
-
```
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1494
|
+
```ts
|
|
1495
|
+
// main.ts
|
|
1496
|
+
import "@codenhub/styles";
|
|
1497
|
+
import { mount } from "svelte";
|
|
1498
|
+
import App from "./App.svelte";
|
|
1499
|
+
|
|
1500
|
+
mount(App, { target: document.getElementById("app")! });
|
|
1810
1501
|
```
|
|
1811
1502
|
|
|
1812
|
-
|
|
1813
|
-
provides the shared control dimensions, border, placeholder, focus-visible,
|
|
1814
|
-
invalid, and disabled styles composed by `ipt`, `textarea`, and `select`.
|
|
1815
|
-
Use it for custom text-like controls; prefer those higher-level utilities
|
|
1816
|
-
when they fit.
|
|
1503
|
+
Running Tailwind CSS v4? Import `@codenhub/styles/tw` from the app's CSS entry instead — see [Tailwind CSS v4](docs/integrating/tailwind.md).
|
|
1817
1504
|
|
|
1818
|
-
##
|
|
1505
|
+
## Force a theme
|
|
1819
1506
|
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1507
|
+
Apply `.dark` or `.light` on `<html>` (edit `src/app.html` in SvelteKit) to force a theme instead of following the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
1508
|
+
|
|
1509
|
+
## See also
|
|
1510
|
+
|
|
1511
|
+
- [Setup → Import paths](docs/setup.md#import-paths): every entrypoint this package publishes.
|
|
1512
|
+
- [Usage](docs/usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
1513
|
+
|
|
1514
|
+
<!-- Source: docs/integrating/astro.md -->
|
|
1515
|
+
|
|
1516
|
+
# Astro
|
|
1517
|
+
|
|
1518
|
+
Astro renders components statically by default, but a global stylesheet import still only needs to happen once — from a shared layout, not from individual pages or islands.
|
|
1519
|
+
|
|
1520
|
+
## Import the stylesheet
|
|
1521
|
+
|
|
1522
|
+
```astro
|
|
1523
|
+
---
|
|
1524
|
+
// src/layouts/Layout.astro
|
|
1525
|
+
import "@codenhub/styles";
|
|
1526
|
+
---
|
|
1527
|
+
|
|
1528
|
+
<html lang="en">
|
|
1529
|
+
<body>
|
|
1530
|
+
<slot />
|
|
1531
|
+
</body>
|
|
1532
|
+
</html>
|
|
1838
1533
|
```
|
|
1839
1534
|
|
|
1840
|
-
|
|
1841
|
-
relationships; see [Accessibility](docs/accessibility.md).
|
|
1535
|
+
Every page that uses this layout loads the stylesheet once. Running Tailwind CSS v4? Import `@codenhub/styles/tw` through Astro's Tailwind integration instead — see [Tailwind CSS v4](docs/integrating/tailwind.md), including when an explicit `@source` is actually needed.
|
|
1842
1536
|
|
|
1843
|
-
|
|
1537
|
+
## Force a theme
|
|
1844
1538
|
|
|
1845
|
-
#
|
|
1539
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following the system preference; see [Setup → Configuration](docs/setup.md#configuration).
|
|
1846
1540
|
|
|
1847
|
-
|
|
1848
|
-
presentation, and aesthetic as three independent axes, resolved through
|
|
1849
|
-
tokens a component reads.
|
|
1541
|
+
## See also
|
|
1850
1542
|
|
|
1851
|
-
- [
|
|
1852
|
-
|
|
1853
|
-
- [Theming](docs/usage/theming.md): The color, intent, and foundation token reference.
|
|
1854
|
-
- [Customizing](docs/usage/customizing.md): The presentation and material token
|
|
1855
|
-
reference, aesthetic knobs, and defining a custom intent.
|
|
1856
|
-
- [Aesthetics](docs/usage/aesthetics.md): Each shipped aesthetic in depth, including
|
|
1857
|
-
its documented exceptions.
|
|
1858
|
-
- [Buttons](docs/usage/buttons.md)
|
|
1859
|
-
- [Forms](docs/usage/forms.md)
|
|
1860
|
-
- [Feedback](docs/usage/feedback.md)
|
|
1861
|
-
- [Tooltips](docs/usage/tooltips.md)
|
|
1862
|
-
- [Content and layout](docs/usage/content-and-layout.md): Layout helpers, tables,
|
|
1863
|
-
quotes, code, surfaces, and typography utilities.
|
|
1543
|
+
- [Setup → Import paths](docs/setup.md#import-paths): every entrypoint this package publishes.
|
|
1544
|
+
- [Usage](docs/usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
1864
1545
|
|
|
1865
|
-
|
|
1546
|
+
<!-- Source: docs/accessibility.md -->
|
|
1866
1547
|
|
|
1867
|
-
|
|
1868
|
-
describes it and the package playground demonstrates it. Undocumented and
|
|
1869
|
-
undemonstrated combinations may still produce CSS, but are not maintained
|
|
1870
|
-
behavior. Playground variant matrices are the exhaustive demonstrations; small
|
|
1871
|
-
examples elsewhere illustrate usage without widening that contract.
|
|
1548
|
+
# Accessibility responsibilities
|
|
1872
1549
|
|
|
1873
|
-
|
|
1550
|
+
This package provides CSS hooks for accessible states. It does not provide semantic HTML, ARIA attributes, keyboard behavior, focus management, validation, announcement timing, or JavaScript behavior.
|
|
1874
1551
|
|
|
1875
|
-
|
|
1552
|
+
## Provided by CSS
|
|
1876
1553
|
|
|
1877
|
-
|
|
1878
|
-
[Concepts → Theme selection](docs/concepts.md#theme-selection) for how a theme
|
|
1879
|
-
is chosen. Intent tokens are how a component reads that palette once an
|
|
1880
|
-
intent class is applied. Foundation tokens are the shared layout, shape, and
|
|
1881
|
-
motion defaults underneath everything.
|
|
1554
|
+
### Focus and state
|
|
1882
1555
|
|
|
1883
|
-
|
|
1556
|
+
| Feature | Behavior |
|
|
1557
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------- |
|
|
1558
|
+
| `:focus-visible` | Global focus-visible outline using `--focus-ring`, `--focus-ring-width`, and `--focus-ring-offset`. |
|
|
1559
|
+
| Form control focus | `.ipt`, `.textarea`, and `.select` draw the global focus ring and move their line to the intent color. |
|
|
1560
|
+
| Invalid controls | `[aria-invalid="true"]` applies destructive border/focus color on form controls. |
|
|
1561
|
+
| Disabled controls | `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]`, and `.disabled` apply disabled cursor/opacity where supported. |
|
|
1562
|
+
| Open state | `[data-state="open"]` styles supported surfaces and tooltips. |
|
|
1884
1563
|
|
|
1885
|
-
|
|
1886
|
-
`light-dark()`, and the element's `color-scheme` picks one.
|
|
1564
|
+
### Control boundaries
|
|
1887
1565
|
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1566
|
+
| Feature | Behavior |
|
|
1567
|
+
| -------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
1568
|
+
| Control boundaries | Text controls rest at `--_line-rest` of their intent, under 3:1 by choice; hover and focus take the tone whole. |
|
|
1569
|
+
| Toggle boundaries | `.checkbox`, `.radio`, and `.switch` draw their line whole, because it is the only thing marking an unchecked box. |
|
|
1570
|
+
| Cascaded `.edgeless` | Floored on every text control: a container cannot erase the line of a field or toggle nobody classed. |
|
|
1571
|
+
| Own `.edgeless` | On the element, `.ipt`, `.textarea`, `.select`, and `.switch` do drop their line and do not meet 1.4.11 at rest. |
|
|
1572
|
+
| `.checkbox`/`.radio` | Never drop their line, on the element or from a container. `.edgeless` on them is unsupported, not merely discouraged. |
|
|
1893
1573
|
|
|
1894
|
-
|
|
1895
|
-
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
1896
|
-
| `--color-primary` | Primary action/content color. |
|
|
1897
|
-
| `--color-primary-contrast` | Text/icon color on primary filled surface. |
|
|
1898
|
-
| `--color-primary-hover` | Primary hover state. |
|
|
1899
|
-
| `--color-primary-subtle` | Low-emphasis companion tone for primary. Use as soft surface or subtle background. |
|
|
1900
|
-
| `--color-primary-strong` | High-emphasis companion tone for primary. Use as readable text, icon, or border on subtle surfaces. |
|
|
1901
|
-
| `--color-accent` | Secondary/accent surface. |
|
|
1902
|
-
| `--color-accent-contrast` | Text/icon color on accent filled surface. |
|
|
1903
|
-
| `--color-accent-hover` | Accent hover state. |
|
|
1904
|
-
| `--color-accent-subtle` | Low-emphasis companion tone for accent. Use as soft surface or subtle background. |
|
|
1905
|
-
| `--color-accent-strong` | High-emphasis companion tone for accent. Use as readable text, icon, or border on subtle surfaces. |
|
|
1906
|
-
| `--color-border` | Default border color. |
|
|
1907
|
-
| `--color-border-hover` | Interactive border color. |
|
|
1908
|
-
| `--color-control-border` | Resting line on the six text controls; one value, drawn at a fraction on text inputs. |
|
|
1909
|
-
| `--color-background` | Page and default raised surface background. |
|
|
1910
|
-
| `--color-foreground` | Subtle raised foreground surface. |
|
|
1911
|
-
| `--color-surface` | Nested or muted surface. |
|
|
1912
|
-
| `--color-text` | Primary text color. |
|
|
1913
|
-
| `--color-text-secondary` | Secondary text color. |
|
|
1914
|
-
| `--color-text-contrast` | Readable color on top of a full fill of `--color-text`. A checked toggle prints it. |
|
|
1915
|
-
| `--color-text-hover` | Text hover state. |
|
|
1916
|
-
| `--color-text-subtle` | Low-emphasis companion tone for text. Use as soft surface or subtle background. |
|
|
1917
|
-
| `--color-text-strong` | High-emphasis companion tone for text. Use as readable text, icon, or border on subtle surfaces. |
|
|
1918
|
-
| `--color-tooltip` | Tooltip bubble plate with no intent. Chosen per theme rather than derived: near-white in light, mid grey in dark. |
|
|
1919
|
-
| `--color-tooltip-contrast` | Ink on `--color-tooltip`. |
|
|
1920
|
-
| `--color-success` | Success state color. |
|
|
1921
|
-
| `--color-success-contrast` | Text/icon color on success filled surface. Meets 4.5:1 as normal text on `--color-success` (5.14:1). |
|
|
1922
|
-
| `--color-success-hover` | Success hover tone. |
|
|
1923
|
-
| `--color-success-subtle` | Low-emphasis companion tone for success. |
|
|
1924
|
-
| `--color-success-strong` | High-emphasis companion tone for success. |
|
|
1925
|
-
| `--color-warning` | Warning state color. |
|
|
1926
|
-
| `--color-warning-contrast` | The near-black tone, not the page tone. Meets 4.5:1 as normal text on `--color-warning` (6.19:1). |
|
|
1927
|
-
| `--color-warning-hover` | Warning hover tone. |
|
|
1928
|
-
| `--color-warning-subtle` | Low-emphasis companion tone for warning. |
|
|
1929
|
-
| `--color-warning-strong` | High-emphasis companion tone for warning. |
|
|
1930
|
-
| `--color-destructive` | Destructive/error state color. |
|
|
1931
|
-
| `--color-destructive-contrast` | Text/icon color on destructive filled surface. Meets 4.5:1 as normal text on `--color-destructive` (5.78:1). |
|
|
1932
|
-
| `--color-destructive-hover` | Destructive hover tone. |
|
|
1933
|
-
| `--color-destructive-subtle` | Low-emphasis companion tone for destructive. |
|
|
1934
|
-
| `--color-destructive-strong` | High-emphasis companion tone for destructive. |
|
|
1935
|
-
| `--color-info` | Informational state color. |
|
|
1936
|
-
| `--color-info-contrast` | Text/icon color on info filled surface. Meets 4.5:1 as normal text on `--color-info` (6.19:1). |
|
|
1937
|
-
| `--color-info-hover` | Info hover tone. |
|
|
1938
|
-
| `--color-info-subtle` | Low-emphasis companion tone for info. |
|
|
1939
|
-
| `--color-info-strong` | High-emphasis companion tone for info. |
|
|
1574
|
+
### Motion and transparency
|
|
1940
1575
|
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
> internal structure that cannot be expressed through the token palette
|
|
1947
|
-
> alone.
|
|
1576
|
+
| Feature | Behavior |
|
|
1577
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
1578
|
+
| Reduced-motion loaders | Loader variants use animated embedded SVGs normally and static masks when `prefers-reduced-motion: reduce` matches. |
|
|
1579
|
+
| Reduced-motion document | The reset additionally shortens document animations and transitions when `prefers-reduced-motion: reduce` matches. |
|
|
1580
|
+
| Reduced transparency | `.glass` drops its blur and becomes an opaque surface when `prefers-reduced-transparency: reduce` matches. |
|
|
1948
1581
|
|
|
1949
|
-
|
|
1582
|
+
The loader fallback is embedded in loader CSS, so focused imports that include loaders honor reduced motion without the reset. This includes `@codenhub/styles/components`, `@codenhub/styles/tw/components`, and `@codenhub/styles/tw/loader`. The complete and native entrypoints include both that fallback and the reset's broader animation and transition shortening.
|
|
1950
1583
|
|
|
1951
|
-
|
|
1952
|
-
supporting component reads the same seven names, an intent works on every
|
|
1953
|
-
component that supports intent, and a custom intent needs no component
|
|
1954
|
-
changes.
|
|
1584
|
+
### Color and contrast
|
|
1955
1585
|
|
|
1956
|
-
|
|
|
1957
|
-
|
|
|
1958
|
-
|
|
|
1959
|
-
| `--
|
|
1960
|
-
| `--intent-
|
|
1961
|
-
| `--intent-strong`
|
|
1962
|
-
|
|
|
1963
|
-
| `--intent-border` | Line color. Resolves to `--color-border` when no intent is set. |
|
|
1964
|
-
| `--intent-fill-max` | How far a fill of this intent is allowed to go. `100%` for every intent but neutral. |
|
|
1586
|
+
| Feature | Behavior |
|
|
1587
|
+
| ------------------ | -------------------------------------------------------------------------------------------------------------------------- |
|
|
1588
|
+
| Filled labels | Every intent's `.solid` label meets 1.4.3 (4.5:1) as normal text, in both themes. Lowest is success at 5.14:1. |
|
|
1589
|
+
| Warning ink | `--color-warning-contrast` is the near-black tone, not the page tone. Amber dark enough to carry white is not amber. |
|
|
1590
|
+
| Partial fills | Contrast ink appears only past a half fill, so a capped plate keeps `--intent-strong` rather than walking toward the page. |
|
|
1591
|
+
| Intent hue in dark | `--intent-strong` is the `-300` shade in dark, so a soft or ghost label keeps its own hue instead of reading white. |
|
|
1592
|
+
| Toggle marks | A checked mark meets 3:1 as a state indicator on every plate its fill class can paint, in both themes. |
|
|
1965
1593
|
|
|
1966
|
-
|
|
1967
|
-
interchangeable. The base is a ground, chosen to be filled with; the strong
|
|
1968
|
-
tone is chosen to be read against a page. A `.soft` or `.ghost` component
|
|
1969
|
-
prints the strong one, which is why an unfilled warning reads in amber-800
|
|
1970
|
-
rather than the amber-600 its solid sibling is filled with.
|
|
1971
|
-
|
|
1972
|
-
The strong tone has to stay recognisably its own hue, not just readable. On a
|
|
1973
|
-
dark page the `-100` shade of every family is a pale tint that carries almost
|
|
1974
|
-
no chroma at small sizes: a soft success badge and a soft destructive one
|
|
1975
|
-
printed labels that both read white, and a soft radio's dot stopped matching
|
|
1976
|
-
the ring around it. The dark tones are `-300` for that reason, and the tinted
|
|
1977
|
-
grounds under them are `-900` so there is room — measured at 5.0:1 or better
|
|
1978
|
-
everywhere a partial fill prints text, and past 9:1 on the page.
|
|
1979
|
-
|
|
1980
|
-
`--intent-border` exists because a neutral border must stay the quiet border
|
|
1981
|
-
gray rather than the text color. Everything that draws a line reads it:
|
|
1982
|
-
control borders, table rules, dividers, key caps, and quote bars.
|
|
1983
|
-
|
|
1984
|
-
`--intent-fill-max` exists for the neutral intent, whose color is the page's
|
|
1985
|
-
own ink. Every other intent is a hue, legible pale at 12% and saturated at
|
|
1986
|
-
100%; a grey filled to 100% is a black or white slab, which is the loudest
|
|
1987
|
-
thing on the page and the wrong look for the intent that means _nothing in
|
|
1988
|
-
particular_. Neutral stops at `20%`, so `.solid` gives it a quiet plate that
|
|
1989
|
-
still reads as a step past `.soft`. Hover adds its step on top of the cap, so
|
|
1990
|
-
a capped fill still deepens under the pointer.
|
|
1991
|
-
|
|
1992
|
-
The foreground is gated by the plate rather than tied to the fill.
|
|
1993
|
-
`--intent-contrast` is the ink for a _full_ fill, so printing it at full
|
|
1994
|
-
strength on a fifth of one puts white on light grey. Contrast ink therefore
|
|
1995
|
-
appears only once the fill is past halfway and reaches full at a full fill;
|
|
1996
|
-
below that a component prints `--intent-strong`, the tone chosen to be read.
|
|
1997
|
-
|
|
1998
|
-
That means a capped neutral takes the strong tone whole rather than a
|
|
1999
|
-
fraction of the way toward the page. Tying it to the fill instead cost a
|
|
2000
|
-
neutral `.solid` button four points of contrast and a neutral tooltip nearly
|
|
2001
|
-
ten. A state that lifts the cap on purpose — a checked checkbox is filled
|
|
2002
|
-
with its own intent by definition — reaches a full fill and gets the contrast
|
|
2003
|
-
whole.
|
|
2004
|
-
|
|
2005
|
-
Set them directly to define an intent this package does not ship. **State
|
|
2006
|
-
every slot**, including `--intent-fill-max`: components reset all seven to
|
|
2007
|
-
the neutral values, so a slot your intent leaves out keeps neutral's — and an
|
|
2008
|
-
intent that omits the cap fills to 20% of its color instead of 100%.
|
|
1594
|
+
### Forced colors and direction
|
|
2009
1595
|
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
1596
|
+
| Feature | Behavior |
|
|
1597
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------------ |
|
|
1598
|
+
| Forced colors | `forced-colors: active` preserves visible borders and checked states using system colors. |
|
|
1599
|
+
| Text direction | Quote bar, alert icon, progress fill, vertical divider, and switch knob mirror under `dir="rtl"`. No class needed. |
|
|
1600
|
+
|
|
1601
|
+
In forced colors, class-based form controls including `.text-control` receive a 2px `Highlight` system-color focus outline. The native entrypoint provides the same visible system outline for unclassed text inputs, selects, textareas, checkboxes, and radios.
|
|
1602
|
+
|
|
1603
|
+
Custom checkboxes and radios use the system `Canvas`, `CanvasText`, `Highlight`, and `HighlightText` colors in forced-colors mode so checked and unchecked states remain distinct. Shape, size, and spacing remain unchanged.
|
|
1604
|
+
|
|
1605
|
+
## Required outside CSS
|
|
1606
|
+
|
|
1607
|
+
Use semantic HTML and behavior appropriate for the component.
|
|
1608
|
+
|
|
1609
|
+
| UI | Required outside CSS |
|
|
1610
|
+
| ----------------- | --------------------------------------------------------------------------------------------------------------- |
|
|
1611
|
+
| Buttons | Use `<button>` for actions or accessible links for navigation. Add accessible names for `.btn.icon`. |
|
|
1612
|
+
| Forms | Use labels, `type`, validation logic, `aria-describedby`, and error message relationships. |
|
|
1613
|
+
| Alerts | Add `role="status"` or `role="alert"` based on announcement urgency. |
|
|
1614
|
+
| Toasts | Add live-region behavior, dismissal behavior, focus rules, and pause/timeout logic when needed. |
|
|
1615
|
+
| Tooltips | Provide accessible names/descriptions. CSS pseudo-element content is not enough for all assistive tech. |
|
|
1616
|
+
| Progress | Use semantic progress elements or ARIA values when numeric progress must be announced. |
|
|
1617
|
+
| Skeletons/loaders | Mark decorative loading visuals with `aria-hidden="true"` and expose loading state elsewhere when needed. |
|
|
1618
|
+
| Popovers/modals | Provide focus trapping, escape handling, inert background behavior, labels, and roles outside this CSS package. |
|
|
1619
|
+
|
|
1620
|
+
## State attribute guidance
|
|
1621
|
+
|
|
1622
|
+
Prefer native attributes first:
|
|
1623
|
+
|
|
1624
|
+
```html
|
|
1625
|
+
<button class="btn primary" disabled>Saving</button> <input class="ipt" aria-invalid="true" aria-describedby="email-error" />
|
|
2020
1626
|
```
|
|
2021
1627
|
|
|
1628
|
+
Use ARIA or data attributes when native attributes are not available for the element or library:
|
|
1629
|
+
|
|
2022
1630
|
```html
|
|
2023
|
-
<
|
|
2024
|
-
<span class="badge brand soft">Works everywhere</span>
|
|
1631
|
+
<a class="btn secondary" aria-disabled="true">Unavailable</a> <button class="tooltip tooltip-icon" data-state="open" data-tooltip="More details" aria-label="More details">?</button>
|
|
2025
1632
|
```
|
|
2026
1633
|
|
|
2027
|
-
|
|
2028
|
-
> palette at their own root, so a `.success` container never recolors a
|
|
2029
|
-
> nested destructive button. Put the intent class on the element that shows
|
|
2030
|
-
> the intent.
|
|
1634
|
+
`aria-disabled="true"` communicates disabled state but does not prevent activation. JavaScript or element choice must prevent activation when required.
|
|
2031
1635
|
|
|
2032
|
-
|
|
1636
|
+
<!-- Source: docs/changelog/0.1.1.md -->
|
|
2033
1637
|
|
|
2034
|
-
|
|
2035
|
-
motion, focus, depth, and layering behavior used by helper classes.
|
|
1638
|
+
# 0.1.1
|
|
2036
1639
|
|
|
2037
|
-
|
|
2038
|
-
yourself. They are a separate thing from `.elevation-none`/`.elevation-sm`/
|
|
2039
|
-
`.elevation-md` (aliased as `.flat`/`.raised`/`.floating`), which scale a
|
|
2040
|
-
_component's own_ shadow geometry and default to no shadow at all until an
|
|
2041
|
-
aesthetic or one of those classes asks for depth — see
|
|
2042
|
-
[Composing → Elevation](docs/usage/composing.md#elevation) for that system. The two
|
|
2043
|
-
share `none`/`sm`/`md`/`lg` naming for the same weight of depth, but one is a
|
|
2044
|
-
fixed value and the other multiplies shadow parts, so they will not always
|
|
2045
|
-
paint identically.
|
|
1640
|
+
## Fixed
|
|
2046
1641
|
|
|
2047
|
-
|
|
2048
|
-
| -------------------------- | ----------------------------------------------------------------------- |
|
|
2049
|
-
| `--font-default` | Default app font family. |
|
|
2050
|
-
| `--container-narrow` | Narrow content width. |
|
|
2051
|
-
| `--container-max` | Default content width. |
|
|
2052
|
-
| `--container-wide` | Wide content width. |
|
|
2053
|
-
| `--layout-gutter` | Responsive inline page padding. |
|
|
2054
|
-
| `--layout-section-block` | Responsive section vertical padding. |
|
|
2055
|
-
| `--layout-gap` | Shared gap for `.view`, `.stack`, `.cluster`, and `.auto-grid`. |
|
|
2056
|
-
| `--layout-grid-min` | Minimum column width for `.auto-grid`. |
|
|
2057
|
-
| `--radius-small` | Small radius for compact utility surfaces such as code elements. |
|
|
2058
|
-
| `--radius-control` | Radius for buttons, inputs, tooltips, and compact UI. |
|
|
2059
|
-
| `--radius-surface` | Radius for cards, panels, and alerts. |
|
|
2060
|
-
| `--control-height` | Default minimum height for controls. |
|
|
2061
|
-
| `--border-width` | Default border width. |
|
|
2062
|
-
| `--elevation-color` | Shadow color the four elevations compose from. Heavier in dark themes. |
|
|
2063
|
-
| `--elevation-none` | No shadow. Use on an element that should read as flat against its page. |
|
|
2064
|
-
| `--elevation-sm` | A light shadow for your own surface-level elements, such as cards. |
|
|
2065
|
-
| `--elevation-md` | A shadow for your own raised elements, such as dropdowns and popovers. |
|
|
2066
|
-
| `--elevation-lg` | A shadow for your own full overlays, such as modal dialogs. |
|
|
2067
|
-
| `--focus-ring` | Focus-visible ring color. |
|
|
2068
|
-
| `--focus-ring-offset` | Focus-visible outline offset. Negative, so the ring lands on the edge. |
|
|
2069
|
-
| `--focus-ring-width` | Focus-visible outline/ring width. |
|
|
2070
|
-
| `--motion-duration-fast` | Fast transition for buttons and input interactions (`120ms`). |
|
|
2071
|
-
| `--motion-duration-normal` | Normal transition for layout and modals (`200ms`). |
|
|
2072
|
-
| `--motion-duration-slow` | Slow animation for skeleton loaders and progress bars (`400ms`). |
|
|
2073
|
-
| `--motion-ease` | Default easing curve. |
|
|
2074
|
-
| `--z-popover` | Popover/tooltip z-index. |
|
|
2075
|
-
| `--breakpoint-xs` | Extra-small Tailwind responsive breakpoint. |
|
|
2076
|
-
| `--breakpoint-2xl` | Extended large Tailwind responsive breakpoint. |
|
|
1642
|
+
- `.p-xs` and its alias `.dense` now clear a button's `--control-height` minimum, so a chip-sized button fits inside a table cell or a dense toolbar. Before this, every button kept the full control-height floor even at the tightest padding, so a button that small could not be built. Every other size and padding class still keeps the floor, so a plain button is unchanged. An icon-only `.p-xs`/`.dense` button also gives up its `min-width`; size the glyph yourself, as the package sizes no icons.
|
|
2077
1643
|
|
|
2078
|
-
|
|
2079
|
-
tokens — how much of an intent shows, and what a component is made of.
|
|
1644
|
+
<!-- Source: docs/changelog/0.1.0.md -->
|
|
2080
1645
|
|
|
2081
|
-
|
|
1646
|
+
# 0.1.0
|
|
2082
1647
|
|
|
2083
|
-
|
|
1648
|
+
`0.1.0` replaces the model published in `0.0.4` wholesale. The old model had three orthogonal axes with per-component clamps and no chosen default: a plain element got whatever `var()` fallback each component happened to declare. This release makes each decision explicitly and is the baseline the `0.x` line builds on. Nearly everything below is breaking against `0.0.4`; there are no compatibility aliases.
|
|
2084
1649
|
|
|
2085
|
-
|
|
2086
|
-
| --------------------------------------- | -------------------------------------------------------------- |
|
|
2087
|
-
| `.tooltip` | Tooltip host. Uses `data-tooltip` as pseudo-element content. |
|
|
2088
|
-
| `.tooltip.tooltip-icon` | Circular icon-style tooltip host. |
|
|
2089
|
-
| `[data-tooltip-position="top"]` | Positions tooltip above host. |
|
|
2090
|
-
| `[data-tooltip-position="bottom"]` | Positions tooltip below host. |
|
|
2091
|
-
| `[data-tooltip-position="left"]` | Positions tooltip left of host. |
|
|
2092
|
-
| `[data-tooltip-position="right"]` | Positions tooltip right of host. |
|
|
2093
|
-
| No `data-tooltip-position` | Defaults to top placement. |
|
|
2094
|
-
| `[data-state="open"]` | Shows tooltip without hover. |
|
|
2095
|
-
| `.tooltip.raised` / `.tooltip.floating` | Adds one or two units of depth. The bubble is flat by default. |
|
|
1650
|
+
## Changed
|
|
2096
1651
|
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
1652
|
+
- **Every element now composes from three named axes.** _Intent_ (`.primary`, `.success`, `.destructive`, …) sets hue only. _Presentation_ sets how much of that hue fills the element and whether it draws an edge. _Aesthetic_ sets the material — radius, edge width, shadow, silhouette, type. Intent is redeclared per component; presentation and aesthetic cascade, so a container can set the look of a subtree while any element opts out. [Concepts](docs/concepts.md) and [Composing](docs/usage/composing.md) describe the full model.
|
|
1653
|
+
- **Presentation is two independent questions.** Fill is `.solid` / `.soft` / `.ghost`; edge is `.edged` / `.edgeless`. Exactly one of each applies, and they never decide each other. The common web button — a subtle fill with a border — is `.soft.edged`, which had no spelling before.
|
|
1654
|
+
- **`.bare` is renamed `.ghost`.** `.bare` and `.edgeless` both read as "less of something", so the name is now a fill and only a fill: no fill at rest, a tint on hover.
|
|
1655
|
+
- **Hover is derived, not declared.** A hovered element takes its resting fill plus one published step and its `--intent-hover` colour. There are no hover tokens to set. An outline button therefore tints on hover rather than filling completely.
|
|
1656
|
+
- **A sunk text field is `.soft.edgeless`.** Two classes saying two things, where `.soft` alone used to silently suppress the field's border.
|
|
1657
|
+
- **Table row rules are opt-in via `.ruled`.** Rules no longer arrive by implication from a component's edge default. The head and foot separators stay at every presentation.
|
|
1658
|
+
- **Depth is a modifier, not part of a component.** `surface` no longer carries a structural shadow, so cards, buttons, and chips on a plain page rest flat. Use `.raised` / `.floating` (or `.elevation-sm` / `.elevation-md`) to add depth, and `.flat` to remove an aesthetic's.
|
|
1659
|
+
- **The Tailwind v4 entrypoint moved from `/overrides` to `/native`.**
|
|
2101
1660
|
|
|
2102
|
-
|
|
2103
|
-
zeroes an aesthetic's part-based depth (such as `.neobrutalism`'s slab) the
|
|
2104
|
-
same way `.flat` does elsewhere. Add [`.raised` or
|
|
2105
|
-
`.floating`](docs/usage/composing.md#elevation) to lift it — `.tooltip.floating` is the
|
|
2106
|
-
pre-0.1.0 look. An aesthetic whose shadow is a complete value, like `.glass`,
|
|
2107
|
-
still reaches the bubble as it reaches any surface.
|
|
1661
|
+
## Added
|
|
2108
1662
|
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
</button>
|
|
2118
|
-
```
|
|
1663
|
+
- **Opt-in aesthetics.** `.neobrutalism`, `.glass`, `.pixel`, and `.chunky-tile`, each shipped as its own entrypoint (`@codenhub/styles/aesthetics/pixel`, …) and as an aggregate (`@codenhub/styles/aesthetics`). An aesthetic sets material tokens only; it never repaints hue. See [Aesthetics](docs/usage/aesthetics.md).
|
|
1664
|
+
- **An elevation modifier.** `.flat` / `.raised` / `.floating` (and the `.elevation-none` / `-sm` / `-md` names) multiply an aesthetic's shadow geometry. Unitless, so a container can flatten a whole toolbar and any element can opt back in.
|
|
1665
|
+
- **Granular Tailwind v4 source entrypoints.** `@codenhub/styles/tw` and per-family subpaths (`/tw/button`, `/tw/form`, `/tw/feedback`, `/tw/tooltip`, `/tw/utilities`, `/tw/aesthetics/*`, …) for consumers compiling their own build. `package.json` is also exported.
|
|
1666
|
+
- **`.input-group`.** A wrapper that draws one box and lets the control inside give up its own paint, so an icon can sit alongside a field. The package ships no icons — any element works in the slot.
|
|
1667
|
+
- **`registry.json`.** A machine-readable record of every supported class, each component's default fill/edge/elevation, the axes it reads, and every bound and exception with its reason.
|
|
1668
|
+
- **`--intent-strong`**, the intent tone chosen to be read on a page, used wherever a fill is partial.
|
|
1669
|
+
|
|
1670
|
+
## Removed
|
|
2119
1671
|
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
1672
|
+
- **`.out` and `.fill`.** Outline is now `.ghost.edged`; there is no class that makes an outline button fill completely on hover.
|
|
1673
|
+
- **`--ui-border-scale` / `.out`'s doubled border.** The edge width comes from the aesthetic and nothing else, which removed the per-component border ceilings small components needed.
|
|
1674
|
+
- **`--color-text-subtle`**, which nothing read.
|
|
1675
|
+
- **`--layout-stack-gap` and `--layout-cluster-gap`**, replaced by a single `--layout-gap`.
|
|
1676
|
+
- **The bundled input-field icons.** Icons were a `background-image` data URI with a light and a dark copy per glyph; they are gone, and `.input-group` carries a consumer-supplied icon instead.
|