@codenhub/styles 0.0.4 → 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.
Files changed (74) hide show
  1. package/LICENSE +201 -201
  2. package/NOTICE +27 -0
  3. package/README.md +22 -116
  4. package/dist/aesthetics/chunky-tile.css +1 -0
  5. package/dist/aesthetics/glass.css +1 -0
  6. package/dist/aesthetics/index.css +2 -0
  7. package/dist/aesthetics/neobrutalism.css +1 -0
  8. package/dist/aesthetics/pixel.css +1 -0
  9. package/dist/components.css +2 -2
  10. package/dist/index.css +2 -2
  11. package/dist/native.css +2 -0
  12. package/dist/theme.css +2 -2
  13. package/dist/tw/aesthetics/chunky-tile.css +109 -0
  14. package/dist/tw/aesthetics/glass.css +66 -0
  15. package/dist/tw/aesthetics/index.css +9 -0
  16. package/dist/tw/aesthetics/neobrutalism.css +63 -0
  17. package/dist/tw/aesthetics/pixel.css +88 -0
  18. package/dist/tw/box.css +206 -0
  19. package/dist/tw/components/button.css +108 -0
  20. package/dist/tw/components/feedback.css +163 -0
  21. package/dist/tw/components/form.css +599 -0
  22. package/dist/tw/components/index.css +28 -0
  23. package/dist/tw/components/loader.css +122 -0
  24. package/dist/tw/components/surface.css +122 -0
  25. package/dist/tw/components/tooltip.css +132 -0
  26. package/dist/tw/elevation.css +46 -0
  27. package/dist/tw/index.css +27 -0
  28. package/dist/tw/intent.css +209 -0
  29. package/dist/tw/native.css +187 -0
  30. package/dist/tw/presentation.css +77 -0
  31. package/dist/tw/reset.css +129 -0
  32. package/dist/tw/theme.css +223 -0
  33. package/dist/tw/typography.css +34 -0
  34. package/dist/tw/utilities/content.css +361 -0
  35. package/dist/tw/utilities/index.css +6 -0
  36. package/dist/tw/utilities/layout.css +107 -0
  37. package/docs/accessibility.md +92 -0
  38. package/docs/changelog/0.1.0.md +37 -0
  39. package/docs/changelog/0.1.1.md +10 -0
  40. package/docs/changelog/index.md +10 -0
  41. package/docs/concepts.md +68 -0
  42. package/docs/index.md +35 -0
  43. package/docs/integrating/astro.md +35 -0
  44. package/docs/integrating/index.md +41 -0
  45. package/docs/integrating/nextjs.md +67 -0
  46. package/docs/integrating/svelte.md +43 -0
  47. package/docs/integrating/tailwind.md +56 -0
  48. package/docs/integrating/vue.md +31 -0
  49. package/docs/setup.md +96 -0
  50. package/docs/usage/aesthetics.md +120 -0
  51. package/docs/usage/buttons.md +58 -0
  52. package/docs/usage/composing.md +143 -0
  53. package/docs/usage/content-and-layout.md +175 -0
  54. package/docs/usage/customizing.md +148 -0
  55. package/docs/usage/feedback.md +79 -0
  56. package/docs/usage/forms.md +135 -0
  57. package/docs/usage/index.md +24 -0
  58. package/docs/usage/theming.md +154 -0
  59. package/docs/usage/tooltips.md +39 -0
  60. package/llms-full.txt +1676 -0
  61. package/llms.txt +26 -0
  62. package/package.json +176 -33
  63. package/src/components/button.css +0 -155
  64. package/src/components/feedback.css +0 -214
  65. package/src/components/form.css +0 -303
  66. package/src/components/index.css +0 -9
  67. package/src/components/loader.css +0 -56
  68. package/src/components/surface.css +0 -6
  69. package/src/components/tooltip.css +0 -60
  70. package/src/index.css +0 -7
  71. package/src/overrides.css +0 -76
  72. package/src/theme.css +0 -234
  73. package/src/typography.css +0 -30
  74. package/src/utilities.css +0 -40
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: Concepts
3
+ description: The three-axis model, the token system, and how theme selection works.
4
+ order: 2
5
+ ---
6
+
7
+ # Concepts
8
+
9
+ Read this before the usage guides. It explains the mental model every component, token, and class in this package shares.
10
+
11
+ ## The three axes
12
+
13
+ Every component separates three independent choices, so each can change without a component-specific variant:
14
+
15
+ | Axis | Question | Classes | Inheritance |
16
+ | ------------ | --------------- | ----------------------------------------------------------------------------------------- | ------------ |
17
+ | Intent | Which color? | `.primary`, `.secondary`, `.success`, `.warning`, `.destructive`, `.info` | Element only |
18
+ | Presentation | How much of it? | `.solid`, `.soft`, `.ghost`, `.edged`, `.edgeless` | Cascades |
19
+ | Aesthetic | Made of what? | `.neobrutalism`, `.glass`, `.pixel`, `.chunky-tile` from an optional aesthetic stylesheet | Cascades |
20
+
21
+ ```html
22
+ <section class="soft pixel">
23
+ <button class="btn primary">Soft primary pixel button</button>
24
+ <button class="btn destructive ghost edged">Outlined destructive override</button>
25
+ </section>
26
+ ```
27
+
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.
29
+
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.
31
+
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.
34
+
35
+ ## The token system
36
+
37
+ Tokens are CSS custom properties, grouped by what they control rather than where they're used:
38
+
39
+ | Category | Controls | Reference |
40
+ | ------------ | ------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
41
+ | Color | The palette: primary, accent, success, warning, destructive, info, text, borders, surfaces. | [Usage → Theming](./usage/theming.md#color-tokens) |
42
+ | Intent | Which color slot a component reads once an intent class is applied. | [Usage → Theming](./usage/theming.md#intent-tokens) |
43
+ | Foundation | Layout, shape, motion, focus, depth, and layering defaults shared across components. | [Usage → Theming](./usage/theming.md#foundation-tokens) |
44
+ | Presentation | How much of an intent a component shows — fill and border percentages. | [Usage → Customizing](./usage/customizing.md#presentation-tokens) |
45
+ | Material | What a component is made of — radius, border width, shadow geometry, translucency. | [Usage → Customizing](./usage/customizing.md#material-tokens) |
46
+ | Aesthetic | Per-aesthetic knobs such as `--pixel-unit` or `--tile-lift`. | [Usage → Customizing](./usage/customizing.md#aesthetic-tokens) |
47
+
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.
49
+
50
+ ## Theme selection
51
+
52
+ The root follows the operating-system `color-scheme` preference until an explicit selector overrides it.
53
+
54
+ | Theme | Equivalent selectors |
55
+ | ----- | ------------------------------------------------ |
56
+ | Light | `.light`, `.theme-light`, `[data-theme="light"]` |
57
+ | Dark | `.dark`, `.theme-dark`, `[data-theme="dark"]` |
58
+
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
+
66
+ 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.
67
+
68
+ 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 ADDED
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Introduction
3
+ description: What @codenhub/styles is, what it covers, and where to go next.
4
+ ---
5
+
6
+ # @codenhub/styles
7
+
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.
11
+
12
+ ## What it does
13
+
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.
19
+ - Publishes Tailwind CSS v4 source entrypoints alongside the compiled output.
20
+
21
+ ## What it does not do
22
+
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.
28
+
29
+ ## Next steps
30
+
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.
@@ -0,0 +1,35 @@
1
+ ---
2
+ title: Astro
3
+ description: Loading the stylesheet in an Astro app.
4
+ order: 5
5
+ ---
6
+
7
+ # Astro
8
+
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
12
+
13
+ ```astro
14
+ ---
15
+ // src/layouts/Layout.astro
16
+ import "@codenhub/styles";
17
+ ---
18
+
19
+ <html lang="en">
20
+ <body>
21
+ <slot />
22
+ </body>
23
+ </html>
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
33
+
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.
@@ -0,0 +1,41 @@
1
+ ---
2
+ title: Overview
3
+ description: How the stylesheet loads in a framework build, and which guide to follow.
4
+ group: Integrating
5
+ order: 4
6
+ ---
7
+
8
+ # Integrating
9
+
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.
11
+
12
+ ## The shared model
13
+
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
22
+
23
+ | Stack | Guide |
24
+ | ---------------------------------------- | -------------------------------- |
25
+ | A Tailwind CSS v4 project on any bundler | [Tailwind CSS v4](./tailwind.md) |
26
+ | Next.js / React | [Next.js](./nextjs.md) |
27
+ | Vue | [Vue](./vue.md) |
28
+ | Svelte / SvelteKit | [Svelte](./svelte.md) |
29
+ | Astro | [Astro](./astro.md) |
30
+
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).
@@ -0,0 +1,67 @@
1
+ ---
2
+ title: Next.js
3
+ description: Loading the stylesheet in a Next.js / React app.
4
+ order: 2
5
+ ---
6
+
7
+ # Next.js
8
+
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**
20
+
21
+ ```tsx
22
+ // app/layout.tsx
23
+ import "@codenhub/styles";
24
+
25
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
26
+ return (
27
+ <html lang="en">
28
+ <body>{children}</body>
29
+ </html>
30
+ );
31
+ }
32
+ ```
33
+
34
+ **Pages Router**
35
+
36
+ ```tsx
37
+ // pages/_app.tsx
38
+ import "@codenhub/styles";
39
+ import type { AppProps } from "next/app";
40
+
41
+ export default function App({ Component, pageProps }: AppProps) {
42
+ return <Component {...pageProps} />;
43
+ }
44
+ ```
45
+
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).
51
+
52
+ ```tsx
53
+ <html lang="en" className="dark">
54
+ ```
55
+
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.
@@ -0,0 +1,43 @@
1
+ ---
2
+ title: Svelte
3
+ description: Loading the stylesheet in a Svelte / SvelteKit app.
4
+ order: 4
5
+ ---
6
+
7
+ # Svelte
8
+
9
+ ## Import the stylesheet
10
+
11
+ **SvelteKit** — import from the root layout so it loads once for every route:
12
+
13
+ ```svelte
14
+ <!-- src/routes/+layout.svelte -->
15
+ <script>
16
+ import "@codenhub/styles";
17
+ let { children } = $props();
18
+ </script>
19
+
20
+ {@render children()}
21
+ ```
22
+
23
+ **Plain Svelte + Vite** — import from the entry file instead:
24
+
25
+ ```ts
26
+ // main.ts
27
+ import "@codenhub/styles";
28
+ import { mount } from "svelte";
29
+ import App from "./App.svelte";
30
+
31
+ mount(App, { target: document.getElementById("app")! });
32
+ ```
33
+
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
41
+
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.
@@ -0,0 +1,56 @@
1
+ ---
2
+ title: Tailwind CSS v4
3
+ description: Using the /tw source entrypoints in a Tailwind CSS v4 project.
4
+ order: 1
5
+ ---
6
+
7
+ # Tailwind CSS v4
8
+
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
16
+
17
+ ```css
18
+ @import "tailwindcss";
19
+ @import "@codenhub/styles/tw";
20
+
21
+ @source "./src";
22
+ ```
23
+
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
+
26
+ ## Add aesthetics
27
+
28
+ Add an aesthetic from the source entrypoint the same way as the compiled one, after the base import:
29
+
30
+ ```css
31
+ @import "tailwindcss";
32
+ @import "@codenhub/styles/tw";
33
+ @import "@codenhub/styles/tw/aesthetics";
34
+
35
+ @source "./src";
36
+ ```
37
+
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.
@@ -0,0 +1,31 @@
1
+ ---
2
+ title: Vue
3
+ description: Loading the stylesheet in a Vue / Vite app.
4
+ order: 3
5
+ ---
6
+
7
+ # Vue
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
12
+
13
+ ```ts
14
+ // main.ts
15
+ import "@codenhub/styles";
16
+ import { createApp } from "vue";
17
+ import App from "./App.vue";
18
+
19
+ createApp(App).mount("#app");
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
29
+
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 ADDED
@@ -0,0 +1,96 @@
1
+ ---
2
+ title: Setup
3
+ description: Install the package, pick an entrypoint, and render a first component.
4
+ order: 1
5
+ ---
6
+
7
+ # Setup
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ pnpm add @codenhub/styles
13
+ ```
14
+
15
+ ## Quick start
16
+
17
+ Import the compiled stylesheet for the complete token, reset, utility, and component-class surface, then compose helper classes in markup:
18
+
19
+ ```css
20
+ @import "@codenhub/styles";
21
+ ```
22
+
23
+ ```html
24
+ <main class="stack">
25
+ <p class="text-label">Status</p>
26
+ <h1 class="text-title">Ready to publish</h1>
27
+ <button class="btn primary">Continue</button>
28
+ </main>
29
+ ```
30
+
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.
32
+
33
+ Aesthetics are opt-in. Import the combined aesthetics stylesheet, or one aesthetic on its own, after the base stylesheet so its rules win:
34
+
35
+ ```css
36
+ @import "@codenhub/styles";
37
+ @import "@codenhub/styles/aesthetics";
38
+ ```
39
+
40
+ ```html
41
+ <section class="neobrutalism">
42
+ <button class="btn primary">Thick ink and a hard shadow</button>
43
+ </section>
44
+ ```
45
+
46
+ A project already running Tailwind CSS v4 imports the source entrypoint instead; see [Integrating → Tailwind CSS v4](./integrating/tailwind.md).
47
+
48
+ ## Configuration
49
+
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.
51
+
52
+ ```html
53
+ <html class="dark">
54
+ <body>
55
+ <button class="btn primary">Dark themed button</button>
56
+ </body>
57
+ </html>
58
+ ```
59
+
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
+ ## Import paths
63
+
64
+ 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.
65
+
66
+ | Import path | Composition and effects |
67
+ | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
68
+ | `@codenhub/styles` | Compiled complete surface: Tailwind base/theme output, tokens, typography, utilities, components, and reset. Applies global reset, root theme, and focus rules. |
69
+ | `@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. |
70
+ | `@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. |
71
+ | `@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. |
72
+ | `@codenhub/styles/aesthetics` | Compiled `.neobrutalism`, `.glass`, `.pixel`, and `.chunky-tile` classes. Adds no tokens or components of its own; import after the base stylesheet. |
73
+ | `@codenhub/styles/aesthetics/*` | One compiled aesthetic: `/neobrutalism`, `/glass`, `/pixel`, or `/chunky-tile`. Same rules and ordering as the combined file. |
74
+ | `@codenhub/styles/tw` | Source equivalent of the complete stylesheet. Imports Tailwind itself, theme, typography, utilities, components, and reset; applies the same global rules. |
75
+ | `@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. |
76
+ | `@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. |
77
+ | `@codenhub/styles/tw/surface` | Source theme plus `.surface`, `.card`, and `.panel`. |
78
+ | `@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. |
79
+ | `@codenhub/styles/tw/form` | Source theme plus field, public `text-control`, input, textarea, select, checkbox, radio, and switch utilities. |
80
+ | `@codenhub/styles/tw/feedback` | Source theme plus alert, badge, skeleton, and progress utilities and their keyframes. |
81
+ | `@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`. |
82
+ | `@codenhub/styles/tw/tooltip` | Source theme plus tooltip utilities. |
83
+ | `@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. |
84
+ | `@codenhub/styles/tw/native` | Source complete surface plus reset and classless native-element mappings; broadest global effects. |
85
+ | `@codenhub/styles/tw/typography` | Source theme plus typography utilities; sets theme selectors but no reset or classless mappings. |
86
+ | `@codenhub/styles/tw/utilities` | Source theme and typography composition plus layout and content utilities; safelists the package utility names. |
87
+ | `@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. |
88
+
89
+ Avoid importing overlapping entrypoints in the same build unless duplicate generated CSS is acceptable; pick the narrowest entrypoint that covers what a page needs.
90
+
91
+ ## Requirements
92
+
93
+ - Consumer tooling must resolve package CSS imports.
94
+ - 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).
95
+ - Tailwind CSS 4 or newer is required only for `/tw` source entrypoints.
96
+ - The package has no JavaScript runtime. Apps must provide semantic HTML, ARIA, keyboard behavior, focus management, validation, and announcements; see [Accessibility](./accessibility.md).
@@ -0,0 +1,120 @@
1
+ ---
2
+ title: Aesthetics
3
+ description: The four shipped aesthetics in depth, including their documented exceptions.
4
+ order: 4
5
+ ---
6
+
7
+ # Aesthetics
8
+
9
+ 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:
10
+
11
+ ```css
12
+ @import "@codenhub/styles";
13
+ @import "@codenhub/styles/aesthetics";
14
+ ```
15
+
16
+ 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.
17
+
18
+ Like presentation, an aesthetic class cascades to any subtree:
19
+
20
+ ```html
21
+ <section class="neobrutalism">
22
+ <button class="btn primary">Thick ink and a hard shadow</button>
23
+ <div class="card destructive">The intent still wins over the aesthetic ink</div>
24
+ </section>
25
+ ```
26
+
27
+ | Class | Look |
28
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------- |
29
+ | `.neobrutalism` | No radius, a thick ink outline, a hard unblurred offset shadow, and a press that moves the element into it. |
30
+ | `.glass` | Translucent surfaces over a blurred backdrop with a hairline highlight edge. |
31
+ | `.pixel` | Corners cut by one grid unit, a chunky outline drawn as an inset ring, and the consumer-supplied `--font-pixel` over monospace. |
32
+ | `.chunky-tile` | Rounded slabs seated on a darker shade of themselves, with a press that moves the element down into its own bar. |
33
+
34
+ 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.
35
+
36
+ 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.
37
+
38
+ 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.
39
+
40
+ Each aesthetic that scales from one number publishes it as a knob — see [Customizing → Aesthetic tokens](./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.
41
+
42
+ ## Neobrutalism
43
+
44
+ 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.
45
+
46
+ `--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.
47
+
48
+ ```html
49
+ <section class="neobrutalism" style="--neo-offset: 6px">
50
+ <button class="btn primary">A longer throw</button>
51
+ </section>
52
+ ```
53
+
54
+ **Exceptions:**
55
+
56
+ - 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.
57
+ - 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.
58
+ - 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.
59
+
60
+ ## Glass
61
+
62
+ `.glass` needs something behind it to blur. On a flat page background it renders as a plain translucent panel.
63
+
64
+ `--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.
65
+
66
+ ```html
67
+ <section class="glass" style="--glass-radius-surface: 1.5rem">
68
+ <div class="card">Softer</div>
69
+ </section>
70
+ ```
71
+
72
+ **Exceptions:**
73
+
74
+ - 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.
75
+ - Under `prefers-reduced-transparency: reduce`, glass surfaces drop the blur and become opaque.
76
+
77
+ ## Pixel
78
+
79
+ `--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.
80
+
81
+ ```html
82
+ <section class="pixel" style="--pixel-unit: 6px">
83
+ <button class="btn primary">Chunkier</button>
84
+ </section>
85
+ ```
86
+
87
+ **Exceptions:**
88
+
89
+ - 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.
90
+ - 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.
91
+ - 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.
92
+ - `--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.
93
+
94
+ ## Chunky tile
95
+
96
+ 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.
97
+
98
+ `--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.
99
+
100
+ ```html
101
+ <section class="chunky-tile" style="--tile-lift: 6px; --tile-radius: 0.5rem">
102
+ <button class="btn success">Continue</button>
103
+ </section>
104
+ ```
105
+
106
+ 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.
107
+
108
+ **Exceptions:**
109
+
110
+ - 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:
111
+
112
+ ```html
113
+ <div class="card soft edgeless info flat">Promo panel, deliberately flat</div>
114
+ ```
115
+
116
+ - `--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.
117
+ - 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.
118
+ - `.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.
119
+ - 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.
120
+ - Depth in this aesthetic is the bar, never a blurred drop shadow. Anything the registry rests flat sits flush on the page.