@codenhub/styles 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -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 +20 -2
- package/dist/tw/box.css +45 -2
- package/dist/tw/components/button.css +38 -29
- package/dist/tw/components/feedback.css +58 -41
- package/dist/tw/components/form.css +139 -47
- package/dist/tw/components/index.css +16 -6
- package/dist/tw/components/loader.css +2 -16
- package/dist/tw/components/surface.css +122 -5
- package/dist/tw/components/tooltip.css +102 -91
- package/dist/tw/elevation.css +57 -14
- package/dist/tw/index.css +23 -5
- package/dist/tw/intent.css +36 -12
- package/dist/tw/native.css +4 -20
- package/dist/tw/reset.css +40 -32
- package/dist/tw/theme.css +46 -8
- package/dist/tw/utilities/content.css +104 -18
- package/dist/tw/utilities/index.css +1 -1
- package/dist/tw/utilities/layout.css +33 -0
- package/docs/accessibility.md +68 -48
- package/docs/changelog/0.1.0.md +37 -0
- package/docs/changelog/0.1.1.md +10 -0
- package/docs/changelog/0.2.0.md +41 -0
- package/docs/changelog/index.md +11 -0
- package/docs/concepts.md +21 -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 +31 -32
- package/docs/usage/aesthetics.md +31 -107
- package/docs/usage/buttons.md +24 -36
- package/docs/usage/composing.md +31 -102
- package/docs/usage/content-and-layout.md +65 -83
- package/docs/usage/customizing.md +25 -90
- package/docs/usage/feedback.md +25 -56
- package/docs/usage/forms.md +48 -80
- package/docs/usage/index.md +9 -17
- package/docs/usage/theming.md +25 -81
- package/docs/usage/tooltips.md +55 -35
- package/llms-full.txt +1193 -1510
- package/package.json +121 -44
package/docs/concepts.md
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Concepts
|
|
3
3
|
description: The three-axis model, the token system, and how theme selection works.
|
|
4
|
+
order: 2
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Concepts
|
|
7
8
|
|
|
8
|
-
Read this before the usage guides. It explains the mental model every
|
|
9
|
-
component, token, and class in this package shares.
|
|
9
|
+
Read this before the usage guides. It explains the mental model every component, token, and class in this package shares.
|
|
10
10
|
|
|
11
11
|
## The three axes
|
|
12
12
|
|
|
13
|
-
Every component separates three independent choices, so each can change
|
|
14
|
-
without a component-specific variant:
|
|
13
|
+
Every component separates three independent choices, so each can change without a component-specific variant:
|
|
15
14
|
|
|
16
15
|
| Axis | Question | Classes | Inheritance |
|
|
17
16
|
| ------------ | --------------- | ----------------------------------------------------------------------------------------- | ------------ |
|
|
@@ -26,25 +25,16 @@ without a component-specific variant:
|
|
|
26
25
|
</section>
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
Intent stays on the component so a semantic container cannot accidentally
|
|
30
|
-
recolor nested controls. Presentation and aesthetic cascade from a container;
|
|
31
|
-
putting either class directly on a component overrides the inherited choice.
|
|
32
|
-
Components apply documented clamps when an axis would remove an essential edge
|
|
33
|
-
or overwhelm compact geometry.
|
|
28
|
+
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.
|
|
34
29
|
|
|
35
|
-
The maintained contract is the intersection of the combinations documented in
|
|
36
|
-
[Usage](./usage/index.md) and demonstrated by the playground. Undocumented and
|
|
37
|
-
undemonstrated combinations may produce CSS but are not supported behavior.
|
|
30
|
+
The maintained contract is the intersection of the combinations documented in [Usage](./usage/index.md) and demonstrated by the playground. Undocumented and undemonstrated combinations may produce CSS but are not supported behavior.
|
|
38
31
|
|
|
39
|
-
- [Usage → Composing](./usage/composing.md) shows how the three axes combine
|
|
40
|
-
|
|
41
|
-
- [Usage → Aesthetics](./usage/aesthetics.md) covers each aesthetic and its
|
|
42
|
-
documented exceptions in depth.
|
|
32
|
+
- [Usage → Composing](./usage/composing.md) shows how the three axes combine on each component, with the full axis-support matrix.
|
|
33
|
+
- [Usage → Aesthetics](./usage/aesthetics.md) covers each aesthetic and its documented exceptions in depth.
|
|
43
34
|
|
|
44
35
|
## The token system
|
|
45
36
|
|
|
46
|
-
Tokens are CSS custom properties, grouped by what they control rather than
|
|
47
|
-
where they're used:
|
|
37
|
+
Tokens are CSS custom properties, grouped by what they control rather than where they're used:
|
|
48
38
|
|
|
49
39
|
| Category | Controls | Reference |
|
|
50
40
|
| ------------ | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
@@ -55,40 +45,25 @@ where they're used:
|
|
|
55
45
|
| Material | What a component is made of — radius, border width, shadow geometry, translucency. | [Usage → Customizing](./usage/customizing.md#material-tokens) |
|
|
56
46
|
| Aesthetic | Per-aesthetic knobs such as `--pixel-unit` or `--tile-lift`. | [Usage → Customizing](./usage/customizing.md#aesthetic-tokens) |
|
|
57
47
|
|
|
58
|
-
Color and foundation tokens are the ones most apps touch first, to match a
|
|
59
|
-
brand palette or spacing scale. Intent, presentation, and material tokens are
|
|
60
|
-
lower-level: components read them, and only presentation classes, aesthetic
|
|
61
|
-
classes, or a consumer override should set them.
|
|
48
|
+
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.
|
|
62
49
|
|
|
63
50
|
## Theme selection
|
|
64
51
|
|
|
65
|
-
The root follows the operating-system `color-scheme` preference until an
|
|
66
|
-
explicit selector overrides it.
|
|
52
|
+
The root follows the operating-system `color-scheme` preference until an explicit selector overrides it.
|
|
67
53
|
|
|
68
54
|
| Theme | Equivalent selectors |
|
|
69
55
|
| ----- | ------------------------------------------------ |
|
|
70
56
|
| Light | `.light`, `.theme-light`, `[data-theme="light"]` |
|
|
71
57
|
| Dark | `.dark`, `.theme-dark`, `[data-theme="dark"]` |
|
|
72
58
|
|
|
73
|
-
- Theme selectors set `color-scheme` and nothing else. Because `color-scheme`
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
- Component colors resolve from tokens or `currentColor`, so they follow the
|
|
85
|
-
theme without separate dark-variant rules, with no exception: every glyph
|
|
86
|
-
the package draws is a `currentColor` mask. Icon artwork a consumer brings
|
|
87
|
-
is theirs to theme.
|
|
88
|
-
|
|
89
|
-
Setting `color-scheme` yourself on an element also re-themes the tokens below
|
|
90
|
-
it, because that is the only signal the palette reads. This also themes native
|
|
91
|
-
UI such as scrollbars and form-control internals to match.
|
|
92
|
-
|
|
93
|
-
This mechanism works from Chrome 123, Safari 17.5, and Firefox 120; the package
|
|
94
|
-
overall requires Firefox 121 for `:has()` (see [Setup](./setup.md#requirements)).
|
|
59
|
+
- Theme selectors set `color-scheme` and nothing else. Because `color-scheme` inherits, a selector themes its entire subtree.
|
|
60
|
+
- With no explicit selector, `:root` uses `color-scheme: light dark`, so the system preference decides.
|
|
61
|
+
- A theme selector on `:root` overrides the system preference in either direction.
|
|
62
|
+
- A nested explicit selector overrides an inherited theme, so the nearest themed ancestor controls that subtree at any depth.
|
|
63
|
+
- 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.
|
|
64
|
+
- 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.
|
|
65
|
+
- The Tailwind source entrypoints' `dark:` variant tracks this rule for the explicit-selector-versus-system-preference choice: it fires under an explicit dark selector, or under the system preference when the subtree carries no explicit selector at all. It does not track the previous rule the same way: that one holds because `color-scheme` inherits, so the nearest declaration always wins regardless of depth, while `dark:` matches by selector -- `.dark *` matches every descendant of a `.dark` element, with no way to stop at a nearer `.light` in between. A `.light` subtree nested inside `.dark` themes its tokens correctly but still matches `dark:`'s explicit arm. See [Setup → Dark variant](./setup.md#dark-variant).
|
|
66
|
+
|
|
67
|
+
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.
|
|
68
|
+
|
|
69
|
+
This mechanism works from Chrome 123, Safari 17.5, and Firefox 120; the package overall requires Firefox 121 for `:has()` (see [Setup](./setup.md#requirements)).
|
package/docs/index.md
CHANGED
|
@@ -5,58 +5,31 @@ description: What @codenhub/styles is, what it covers, and where to go next.
|
|
|
5
5
|
|
|
6
6
|
# @codenhub/styles
|
|
7
7
|
|
|
8
|
-
`@codenhub/styles` is a CSS-only design system: tokens, a reset, typography and
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
which color, how much of it, and what it's made of — so changing one never
|
|
12
|
-
requires a component-specific variant. Four optional aesthetics
|
|
13
|
-
(`.neobrutalism`, `.glass`, `.pixel`, `.chunky-tile`) restyle that same
|
|
14
|
-
component set without touching markup.
|
|
15
|
-
|
|
16
|
-
The package ships as ready-to-import compiled CSS, or as Tailwind CSS v4
|
|
17
|
-
source entrypoints for a project that already runs Tailwind. Both cover the
|
|
18
|
-
same classes; the difference is which build processes them.
|
|
8
|
+
`@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.
|
|
9
|
+
|
|
10
|
+
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.
|
|
19
11
|
|
|
20
12
|
## What it does
|
|
21
13
|
|
|
22
|
-
- Publishes color, foundation, intent, presentation, and material design
|
|
23
|
-
|
|
24
|
-
- Provides
|
|
25
|
-
|
|
26
|
-
- Provides
|
|
27
|
-
badges, loaders, progress, cards/panels, tables, quotes, code, and
|
|
28
|
-
tooltips.
|
|
29
|
-
- Provides four opt-in aesthetics that restyle the same components by setting
|
|
30
|
-
material tokens, not by adding component variants.
|
|
31
|
-
- Provides classless mappings so plain HTML elements pick up base styling
|
|
32
|
-
without added classes, from a dedicated entrypoint.
|
|
14
|
+
- Publishes color, foundation, intent, presentation, and material design tokens as CSS custom properties, themed with `light-dark()`.
|
|
15
|
+
- Provides a reset, focus-visible handling, and responsive layout/content utilities.
|
|
16
|
+
- Provides composable classes for buttons, form controls and toggles, alerts, badges, loaders, progress, cards/panels, tables, quotes, code, and tooltips.
|
|
17
|
+
- Provides four opt-in aesthetics that restyle the same components by setting material tokens, not by adding component variants.
|
|
18
|
+
- Provides classless mappings so plain HTML elements pick up base styling without added classes, from a dedicated entrypoint.
|
|
33
19
|
- Publishes Tailwind CSS v4 source entrypoints alongside the compiled output.
|
|
34
20
|
|
|
35
21
|
## What it does not do
|
|
36
22
|
|
|
37
|
-
- No JavaScript. There is no runtime, no framework bindings, and no build-time
|
|
38
|
-
|
|
39
|
-
- No
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
- No theme-toggling logic. Theme selection is a class or attribute a consumer
|
|
43
|
-
applies; wiring a toggle to system preference, storage, or a user setting is
|
|
44
|
-
outside this package. The `@codenhub/theme` package covers that need for
|
|
45
|
-
consumers who want it.
|
|
46
|
-
- No shipped font binaries. `.pixel` and `.chunky-tile` accept a
|
|
47
|
-
consumer-supplied font and fall back to a system stack when none is given.
|
|
48
|
-
- No compatibility layer for removed tokens or classes. Breaking changes are
|
|
49
|
-
documented, not silently aliased.
|
|
23
|
+
- No JavaScript. There is no runtime, no framework bindings, and no build-time code generation beyond the CSS itself.
|
|
24
|
+
- No semantic HTML, ARIA, keyboard behavior, focus management, validation, or announcement timing. See [Accessibility](./accessibility.md) for the exact line between what the CSS provides and what an application must still add.
|
|
25
|
+
- 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.
|
|
26
|
+
- No shipped font binaries. `.pixel` and `.chunky-tile` accept a consumer-supplied font and fall back to a system stack when none is given.
|
|
27
|
+
- No compatibility layer for removed tokens or classes. Breaking changes are documented, not silently aliased.
|
|
50
28
|
|
|
51
29
|
## Next steps
|
|
52
30
|
|
|
53
|
-
- [Setup](./setup.md): Install the package, choose an entrypoint, and render a
|
|
54
|
-
|
|
55
|
-
- [
|
|
56
|
-
|
|
57
|
-
- [
|
|
58
|
-
aesthetics, and each component family.
|
|
59
|
-
- [Integrating](./integrating/index.md): Wiring the stylesheet into Next.js,
|
|
60
|
-
Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
61
|
-
- [Accessibility](./accessibility.md): CSS accessibility hooks and what
|
|
62
|
-
remains an application responsibility.
|
|
31
|
+
- [Setup](./setup.md): Install the package, choose an entrypoint, and render a first component.
|
|
32
|
+
- [Concepts](./concepts.md): The three-axis model, the token system, and how theme selection works — read this before the usage guides.
|
|
33
|
+
- [Usage](./usage/index.md): Guides for composing axes, theming, customizing, aesthetics, and each component family.
|
|
34
|
+
- [Integrating](./integrating/index.md): Wiring the stylesheet into Next.js, Vue, Svelte, Astro, or a Tailwind CSS v4 build.
|
|
35
|
+
- [Accessibility](./accessibility.md): CSS accessibility hooks and what remains an application responsibility.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Astro
|
|
3
3
|
description: Loading the stylesheet in an Astro app.
|
|
4
|
+
order: 5
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Astro
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Import the stylesheet
|
|
10
12
|
|
|
11
13
|
```astro
|
|
12
14
|
---
|
|
@@ -21,9 +23,13 @@ import "@codenhub/styles";
|
|
|
21
23
|
</html>
|
|
22
24
|
```
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
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](./tailwind.md), including when an explicit `@source` is actually needed.
|
|
27
|
+
|
|
28
|
+
## Force a theme
|
|
29
|
+
|
|
30
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following the system preference; see [Setup → Configuration](../setup.md#configuration).
|
|
31
|
+
|
|
32
|
+
## See also
|
|
26
33
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
for the `@source` directive Astro needs to scan `src/`.
|
|
34
|
+
- [Setup → Import paths](../setup.md#import-paths): every entrypoint this package publishes.
|
|
35
|
+
- [Usage](../usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
---
|
|
2
|
-
title:
|
|
3
|
-
description:
|
|
2
|
+
title: Overview
|
|
3
|
+
description: How the stylesheet loads in a framework build, and which guide to follow.
|
|
4
|
+
group: Integrating
|
|
5
|
+
order: 4
|
|
4
6
|
---
|
|
5
7
|
|
|
6
8
|
# Integrating
|
|
7
9
|
|
|
8
|
-
This package has no JavaScript and no framework bindings; see
|
|
9
|
-
[Introduction](../index.md#what-it-does-not-do). Integrating it into a
|
|
10
|
-
framework is entirely about where that framework loads a global stylesheet,
|
|
11
|
-
and whether the project runs Tailwind CSS v4.
|
|
10
|
+
This package has no JavaScript and no framework bindings; see [Introduction](../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.
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
## The shared model
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
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:
|
|
15
|
+
|
|
16
|
+
1. One [entrypoint](../setup.md#import-paths) — the compiled `@codenhub/styles` for any build, or `@codenhub/styles/tw` when the project already runs Tailwind CSS v4.
|
|
17
|
+
2. `@codenhub/styles/aesthetics` (or `/tw/aesthetics`) after it, only if the project uses an [aesthetic](../usage/aesthetics.md).
|
|
18
|
+
|
|
19
|
+
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](./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.
|
|
20
|
+
|
|
21
|
+
## Which guide to follow
|
|
21
22
|
|
|
22
23
|
| Stack | Guide |
|
|
23
24
|
| ---------------------------------------- | -------------------------------- |
|
|
@@ -27,6 +28,14 @@ Every stack does the same two things:
|
|
|
27
28
|
| Svelte / SvelteKit | [Svelte](./svelte.md) |
|
|
28
29
|
| Astro | [Astro](./astro.md) |
|
|
29
30
|
|
|
30
|
-
A project with no framework — a plain Vite, webpack, or Parcel build — needs
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
A project with no framework — a plain Vite, webpack, or Parcel build — needs nothing beyond [Setup → Quick start](../setup.md#quick-start): import the compiled stylesheet from the project's existing global CSS entry.
|
|
32
|
+
|
|
33
|
+
## Verifying it worked
|
|
34
|
+
|
|
35
|
+
After the import, render one styled element and confirm it picked up the package's tokens rather than the browser default:
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<button class="btn primary">Continue</button>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
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](../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](../setup.md#requirements).
|
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Next.js
|
|
3
3
|
description: Loading the stylesheet in a Next.js / React app.
|
|
4
|
+
order: 2
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Next.js
|
|
7
8
|
|
|
8
|
-
Next.js
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
Next.js has two router architectures, and they treat global CSS differently:
|
|
10
|
+
|
|
11
|
+
- **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.
|
|
12
|
+
- **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).
|
|
13
|
+
- **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.
|
|
14
|
+
|
|
15
|
+
## Import the stylesheet
|
|
16
|
+
|
|
17
|
+
Add the import to the root file for your router:
|
|
18
|
+
|
|
19
|
+
**App Router**
|
|
11
20
|
|
|
12
21
|
```tsx
|
|
13
22
|
// app/layout.tsx
|
|
@@ -22,6 +31,8 @@ export default function RootLayout({ children }: { children: React.ReactNode })
|
|
|
22
31
|
}
|
|
23
32
|
```
|
|
24
33
|
|
|
34
|
+
**Pages Router**
|
|
35
|
+
|
|
25
36
|
```tsx
|
|
26
37
|
// pages/_app.tsx
|
|
27
38
|
import "@codenhub/styles";
|
|
@@ -32,13 +43,25 @@ export default function App({ Component, pageProps }: AppProps) {
|
|
|
32
43
|
}
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
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](./tailwind.md).
|
|
47
|
+
|
|
48
|
+
## Force a theme
|
|
49
|
+
|
|
50
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following the system preference; see [Setup → Configuration](../setup.md#configuration).
|
|
37
51
|
|
|
38
52
|
```tsx
|
|
39
53
|
<html lang="en" className="dark">
|
|
40
54
|
```
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
56
|
+
## Troubleshooting
|
|
57
|
+
|
|
58
|
+
**Pages Router build fails with "Global CSS cannot be imported from files other than your Custom `<App>`"**
|
|
59
|
+
|
|
60
|
+
- **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.
|
|
61
|
+
- **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.
|
|
62
|
+
- **Fix:** move the `import "@codenhub/styles"` line to `pages/_app.tsx`, and remove it from wherever it currently is.
|
|
63
|
+
|
|
64
|
+
## See also
|
|
65
|
+
|
|
66
|
+
- [Setup → Import paths](../setup.md#import-paths): every entrypoint this package publishes.
|
|
67
|
+
- [Usage](../usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Svelte
|
|
3
3
|
description: Loading the stylesheet in a Svelte / SvelteKit app.
|
|
4
|
+
order: 4
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Svelte
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
## Import the stylesheet
|
|
10
|
+
|
|
11
|
+
**SvelteKit** — import from the root layout so it loads once for every route:
|
|
10
12
|
|
|
11
13
|
```svelte
|
|
12
14
|
<!-- src/routes/+layout.svelte -->
|
|
@@ -18,7 +20,7 @@ every route:
|
|
|
18
20
|
{@render children()}
|
|
19
21
|
```
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
**Plain Svelte + Vite** — import from the entry file instead:
|
|
22
24
|
|
|
23
25
|
```ts
|
|
24
26
|
// main.ts
|
|
@@ -29,9 +31,13 @@ import App from "./App.svelte";
|
|
|
29
31
|
mount(App, { target: document.getElementById("app")! });
|
|
30
32
|
```
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
Running Tailwind CSS v4? Import `@codenhub/styles/tw` from the app's CSS entry instead — see [Tailwind CSS v4](./tailwind.md).
|
|
35
|
+
|
|
36
|
+
## Force a theme
|
|
37
|
+
|
|
38
|
+
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](../setup.md#configuration).
|
|
39
|
+
|
|
40
|
+
## See also
|
|
35
41
|
|
|
36
|
-
|
|
37
|
-
|
|
42
|
+
- [Setup → Import paths](../setup.md#import-paths): every entrypoint this package publishes.
|
|
43
|
+
- [Usage](../usage/index.md): component classes to compose once the stylesheet is loaded.
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Tailwind CSS v4
|
|
3
3
|
description: Using the /tw source entrypoints in a Tailwind CSS v4 project.
|
|
4
|
+
order: 1
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Tailwind CSS v4
|
|
7
8
|
|
|
8
|
-
A project that already runs Tailwind CSS v4 can process this package's
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
resolve together with yours.
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Why source instead of compiled
|
|
12
|
+
|
|
13
|
+
`/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.
|
|
14
|
+
|
|
15
|
+
## Import the source entrypoint
|
|
13
16
|
|
|
14
17
|
```css
|
|
15
18
|
@import "tailwindcss";
|
|
@@ -18,13 +21,11 @@ resolve together with yours.
|
|
|
18
21
|
@source "./src";
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
`@source`
|
|
22
|
-
class names actually used in your markup, so it can generate only what is
|
|
23
|
-
referenced. Point it at your app's source, not at this package — `/tw`
|
|
24
|
-
already ships every class definition it publishes.
|
|
24
|
+
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.
|
|
25
25
|
|
|
26
|
-
Add aesthetics
|
|
27
|
-
|
|
26
|
+
## Add aesthetics
|
|
27
|
+
|
|
28
|
+
Add an aesthetic from the source entrypoint the same way as the compiled one, after the base import:
|
|
28
29
|
|
|
29
30
|
```css
|
|
30
31
|
@import "tailwindcss";
|
|
@@ -34,7 +35,22 @@ after the base import:
|
|
|
34
35
|
@source "./src";
|
|
35
36
|
```
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
see the full [import path table](../setup.md#import-paths) for what each one
|
|
40
|
-
|
|
38
|
+
## Using a focused entrypoint
|
|
39
|
+
|
|
40
|
+
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](../setup.md#import-paths) for what each one composes.
|
|
41
|
+
|
|
42
|
+
## Troubleshooting
|
|
43
|
+
|
|
44
|
+
**Classes resolve to no styling**
|
|
45
|
+
|
|
46
|
+
- **What happened:** components use documented classes like `.btn.primary`, but no styling appears even though `@import "@codenhub/styles/tw"` is in the stylesheet.
|
|
47
|
+
- **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.
|
|
48
|
+
- **Fix:** add an explicit `@source` pointing at that directory, resolved relative to this stylesheet — matching the [example above](#import-the-source-entrypoint).
|
|
49
|
+
|
|
50
|
+
**Duplicate token and reset rules**
|
|
51
|
+
|
|
52
|
+
- **What happened:** the built stylesheet is larger than expected, and browser devtools show the same custom properties or reset rules defined twice.
|
|
53
|
+
- **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.
|
|
54
|
+
- **Fix:** pick one path per project — `/tw` entrypoints for a project running Tailwind CSS v4, compiled entrypoints everywhere else.
|
|
55
|
+
|
|
56
|
+
Tailwind CSS 4 or newer is required for every `/tw` entrypoint.
|
package/docs/integrating/vue.md
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Vue
|
|
3
3
|
description: Loading the stylesheet in a Vue / Vite app.
|
|
4
|
+
order: 3
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Vue
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
|
+
## Import the stylesheet
|
|
9
12
|
|
|
10
13
|
```ts
|
|
11
14
|
// main.ts
|
|
@@ -16,10 +19,13 @@ import App from "./App.vue";
|
|
|
16
19
|
createApp(App).mount("#app");
|
|
17
20
|
```
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
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](./tailwind.md).
|
|
23
|
+
|
|
24
|
+
## Force a theme
|
|
25
|
+
|
|
26
|
+
Apply `.dark` or `.light` on the root element to force a theme instead of following the system preference; see [Setup → Configuration](../setup.md#configuration).
|
|
27
|
+
|
|
28
|
+
## See also
|
|
22
29
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[Tailwind CSS v4](./tailwind.md).
|
|
30
|
+
- [Setup → Import paths](../setup.md#import-paths): every entrypoint this package publishes.
|
|
31
|
+
- [Usage](../usage/index.md): component classes to compose once the stylesheet is loaded.
|
package/docs/setup.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: Setup
|
|
3
3
|
description: Install the package, pick an entrypoint, and render a first component.
|
|
4
|
+
order: 1
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
# Setup
|
|
@@ -13,8 +14,7 @@ pnpm add @codenhub/styles
|
|
|
13
14
|
|
|
14
15
|
## Quick start
|
|
15
16
|
|
|
16
|
-
Import the compiled stylesheet for the complete token, reset, utility, and
|
|
17
|
-
component-class surface, then compose helper classes in markup:
|
|
17
|
+
Import the compiled stylesheet for the complete token, reset, utility, and component-class surface, then compose helper classes in markup:
|
|
18
18
|
|
|
19
19
|
```css
|
|
20
20
|
@import "@codenhub/styles";
|
|
@@ -28,13 +28,9 @@ component-class surface, then compose helper classes in markup:
|
|
|
28
28
|
</main>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
The full stylesheet applies global reset and focus-visible rules, but does not
|
|
32
|
-
apply the optional classless native-element mappings, and does not include
|
|
33
|
-
aesthetics. Import focused entrypoints when global rules are not appropriate;
|
|
34
|
-
see [Import paths](#import-paths) below.
|
|
31
|
+
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.
|
|
35
32
|
|
|
36
|
-
Aesthetics are opt-in. Import the combined aesthetics stylesheet, or one
|
|
37
|
-
aesthetic on its own, after the base stylesheet so its rules win:
|
|
33
|
+
Aesthetics are opt-in. Import the combined aesthetics stylesheet, or one aesthetic on its own, after the base stylesheet so its rules win:
|
|
38
34
|
|
|
39
35
|
```css
|
|
40
36
|
@import "@codenhub/styles";
|
|
@@ -47,14 +43,11 @@ aesthetic on its own, after the base stylesheet so its rules win:
|
|
|
47
43
|
</section>
|
|
48
44
|
```
|
|
49
45
|
|
|
50
|
-
A project already running Tailwind CSS v4 imports the source entrypoint
|
|
51
|
-
instead; see [Integrating → Tailwind CSS v4](./integrating/tailwind.md).
|
|
46
|
+
A project already running Tailwind CSS v4 imports the source entrypoint instead; see [Integrating → Tailwind CSS v4](./integrating/tailwind.md).
|
|
52
47
|
|
|
53
48
|
## Configuration
|
|
54
49
|
|
|
55
|
-
The root follows the operating-system color-scheme preference. Apply `.light`
|
|
56
|
-
or `.dark` to the root or any ancestor to force token values for that subtree.
|
|
57
|
-
`.theme-light`, `.theme-dark`, and `data-theme="light|dark"` are aliases.
|
|
50
|
+
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.
|
|
58
51
|
|
|
59
52
|
```html
|
|
60
53
|
<html class="dark">
|
|
@@ -64,17 +57,30 @@ or `.dark` to the root or any ancestor to force token values for that subtree.
|
|
|
64
57
|
</html>
|
|
65
58
|
```
|
|
66
59
|
|
|
67
|
-
See [Concepts → Theme selection](./concepts.md#theme-selection) for how
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
See [Concepts → Theme selection](./concepts.md#theme-selection) for how selectors resolve and [Usage → Theming](./usage/theming.md) for the full color token reference.
|
|
61
|
+
|
|
62
|
+
### Dark variant
|
|
63
|
+
|
|
64
|
+
`/tw` source entrypoints define a custom `dark:` variant for your own utilities. It fires under an explicit dark selector (`.dark`, `.theme-dark`, or `[data-theme="dark"]`, on the element or an ancestor), or under the system preference when nothing under it forces a theme explicitly:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<html>
|
|
68
|
+
<body>
|
|
69
|
+
<p class="dark:text-white">Follows the OS preference here</p>
|
|
70
|
+
<div class="light">
|
|
71
|
+
<p class="dark:text-white">Stays light -- this subtree forced it</p>
|
|
72
|
+
</div>
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
An explicit selector at any depth wins over the system preference, in either direction, the same as the token theme it tracks.
|
|
78
|
+
|
|
79
|
+
The one place it does not track the token theme: nesting an explicit selector inside the opposite one. `color-scheme` inherits, so a `.light` nested inside `.dark` themes its own tokens correctly regardless of depth -- the nearest declaration always wins. `dark:` matches by selector instead, and `.dark *` matches every descendant of a `.dark` element with no way to stop at a nearer `.light` in between, so a `dark:` utility inside that nested `.light` still fires even though the tokens around it are light. Apply one theme per subtree rather than nesting opposite ones if a page uses both tokens and `dark:` utilities together.
|
|
70
80
|
|
|
71
81
|
## Import paths
|
|
72
82
|
|
|
73
|
-
Compiled entrypoints are ready-to-import CSS and require only tooling that can
|
|
74
|
-
resolve package CSS imports. `/tw` entrypoints publish copied, uncompiled
|
|
75
|
-
source from `dist/tw`; a Tailwind v4 build must still process their `@theme`,
|
|
76
|
-
`@utility`, `@apply`, and related directives. Focused source component
|
|
77
|
-
entrypoints include theme tokens so their classes can work independently.
|
|
83
|
+
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.
|
|
78
84
|
|
|
79
85
|
| Import path | Composition and effects |
|
|
80
86
|
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -88,7 +94,7 @@ entrypoints include theme tokens so their classes can work independently.
|
|
|
88
94
|
| `@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. |
|
|
89
95
|
| `@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. |
|
|
90
96
|
| `@codenhub/styles/tw/surface` | Source theme plus `.surface`, `.card`, and `.panel`. |
|
|
91
|
-
| `@codenhub/styles/tw/button` | Published Tailwind source for theme
|
|
97
|
+
| `@codenhub/styles/tw/button` | Published Tailwind source for theme and `.btn`. Pair it with `/tw/loader` for a loading state composed from `.loader`. |
|
|
92
98
|
| `@codenhub/styles/tw/form` | Source theme plus field, public `text-control`, input, textarea, select, checkbox, radio, and switch utilities. |
|
|
93
99
|
| `@codenhub/styles/tw/feedback` | Source theme plus alert, badge, skeleton, and progress utilities and their keyframes. |
|
|
94
100
|
| `@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`. |
|
|
@@ -99,18 +105,11 @@ entrypoints include theme tokens so their classes can work independently.
|
|
|
99
105
|
| `@codenhub/styles/tw/utilities` | Source theme and typography composition plus layout and content utilities; safelists the package utility names. |
|
|
100
106
|
| `@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. |
|
|
101
107
|
|
|
102
|
-
Avoid importing overlapping entrypoints in the same build unless duplicate
|
|
103
|
-
generated CSS is acceptable; pick the narrowest entrypoint that covers what a
|
|
104
|
-
page needs.
|
|
108
|
+
Avoid importing overlapping entrypoints in the same build unless duplicate generated CSS is acceptable; pick the narrowest entrypoint that covers what a page needs.
|
|
105
109
|
|
|
106
110
|
## Requirements
|
|
107
111
|
|
|
108
112
|
- Consumer tooling must resolve package CSS imports.
|
|
109
|
-
- Chrome 123, Safari 17.5, or Firefox 121 and newer. Color tokens are declared
|
|
110
|
-
with `light-dark()` and selected by `color-scheme` (Firefox 120), and
|
|
111
|
-
`.input-group` propagates a nested control's invalid and disabled state with
|
|
112
|
-
`:has()` (Firefox 121).
|
|
113
|
+
- 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).
|
|
113
114
|
- Tailwind CSS 4 or newer is required only for `/tw` source entrypoints.
|
|
114
|
-
- The package has no JavaScript runtime. Apps must provide semantic HTML,
|
|
115
|
-
ARIA, keyboard behavior, focus management, validation, and announcements;
|
|
116
|
-
see [Accessibility](./accessibility.md).
|
|
115
|
+
- The package has no JavaScript runtime. Apps must provide semantic HTML, ARIA, keyboard behavior, focus management, validation, and announcements; see [Accessibility](./accessibility.md).
|