@codenhub/styles 0.0.4 → 0.1.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/LICENSE +201 -201
- package/NOTICE +27 -0
- package/README.md +60 -92
- package/dist/aesthetics/chunky-tile.css +1 -0
- package/dist/aesthetics/glass.css +1 -0
- package/dist/aesthetics/index.css +2 -0
- package/dist/aesthetics/neobrutalism.css +1 -0
- package/dist/aesthetics/pixel.css +1 -0
- package/dist/components.css +2 -2
- package/dist/index.css +2 -2
- package/dist/native.css +2 -0
- package/dist/theme.css +2 -2
- package/dist/tw/aesthetics/chunky-tile.css +107 -0
- package/dist/tw/aesthetics/glass.css +66 -0
- package/dist/tw/aesthetics/index.css +9 -0
- package/dist/tw/aesthetics/neobrutalism.css +63 -0
- package/dist/tw/aesthetics/pixel.css +88 -0
- package/dist/tw/box.css +185 -0
- package/dist/tw/components/button.css +88 -0
- package/dist/tw/components/feedback.css +163 -0
- package/dist/tw/components/form.css +601 -0
- package/dist/tw/components/index.css +18 -0
- package/dist/tw/components/loader.css +122 -0
- package/dist/tw/components/surface.css +98 -0
- package/dist/tw/components/tooltip.css +132 -0
- package/dist/tw/elevation.css +39 -0
- package/dist/tw/index.css +12 -0
- package/dist/tw/intent.css +189 -0
- package/dist/tw/native.css +203 -0
- package/dist/tw/presentation.css +77 -0
- package/dist/tw/reset.css +142 -0
- package/dist/tw/theme.css +218 -0
- package/dist/tw/typography.css +34 -0
- package/dist/tw/utilities/content.css +349 -0
- package/dist/tw/utilities/index.css +6 -0
- package/dist/tw/utilities/layout.css +107 -0
- package/docs/accessibility.md +82 -0
- package/docs/concepts.md +94 -0
- package/docs/index.md +62 -0
- package/docs/integrating/astro.md +29 -0
- package/docs/integrating/index.md +32 -0
- package/docs/integrating/nextjs.md +44 -0
- package/docs/integrating/svelte.md +37 -0
- package/docs/integrating/tailwind.md +40 -0
- package/docs/integrating/vue.md +25 -0
- package/docs/setup.md +116 -0
- package/docs/usage/aesthetics.md +197 -0
- package/docs/usage/buttons.md +74 -0
- package/docs/usage/composing.md +218 -0
- package/docs/usage/content-and-layout.md +200 -0
- package/docs/usage/customizing.md +213 -0
- package/docs/usage/feedback.md +117 -0
- package/docs/usage/forms.md +177 -0
- package/docs/usage/index.md +32 -0
- package/docs/usage/theming.md +210 -0
- package/docs/usage/tooltips.md +45 -0
- package/llms-full.txt +2122 -0
- package/llms.txt +26 -0
- package/package.json +95 -29
- package/src/components/button.css +0 -155
- package/src/components/feedback.css +0 -214
- package/src/components/form.css +0 -303
- package/src/components/index.css +0 -9
- package/src/components/loader.css +0 -56
- package/src/components/surface.css +0 -6
- package/src/components/tooltip.css +0 -60
- package/src/index.css +0 -7
- package/src/overrides.css +0 -76
- package/src/theme.css +0 -234
- package/src/typography.css +0 -30
- package/src/utilities.css +0 -40
package/docs/index.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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
|
|
9
|
+
layout utilities, and composable classes for buttons, forms, feedback,
|
|
10
|
+
surfaces, and tooltips. Every component separates three independent choices —
|
|
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.
|
|
19
|
+
|
|
20
|
+
## What it does
|
|
21
|
+
|
|
22
|
+
- Publishes color, foundation, intent, presentation, and material design
|
|
23
|
+
tokens as CSS custom properties, themed with `light-dark()`.
|
|
24
|
+
- Provides a reset, focus-visible handling, and responsive layout/content
|
|
25
|
+
utilities.
|
|
26
|
+
- Provides composable classes for buttons, form controls and toggles, alerts,
|
|
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.
|
|
33
|
+
- Publishes Tailwind CSS v4 source entrypoints alongside the compiled output.
|
|
34
|
+
|
|
35
|
+
## What it does not do
|
|
36
|
+
|
|
37
|
+
- No JavaScript. There is no runtime, no framework bindings, and no build-time
|
|
38
|
+
code generation beyond the CSS itself.
|
|
39
|
+
- No semantic HTML, ARIA, keyboard behavior, focus management, validation, or
|
|
40
|
+
announcement timing. See [Accessibility](./accessibility.md) for the exact
|
|
41
|
+
line between what the CSS provides and what an application must still add.
|
|
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.
|
|
50
|
+
|
|
51
|
+
## Next steps
|
|
52
|
+
|
|
53
|
+
- [Setup](./setup.md): Install the package, choose an entrypoint, and render a
|
|
54
|
+
first component.
|
|
55
|
+
- [Concepts](./concepts.md): The three-axis model, the token system, and how
|
|
56
|
+
theme selection works — read this before the usage guides.
|
|
57
|
+
- [Usage](./usage/index.md): Guides for composing axes, theming, customizing,
|
|
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.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Astro
|
|
3
|
+
description: Loading the stylesheet in an Astro app.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Astro
|
|
7
|
+
|
|
8
|
+
Import the package from a shared layout's frontmatter so every page that
|
|
9
|
+
uses that layout loads it once:
|
|
10
|
+
|
|
11
|
+
```astro
|
|
12
|
+
---
|
|
13
|
+
// src/layouts/Layout.astro
|
|
14
|
+
import "@codenhub/styles";
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<html lang="en">
|
|
18
|
+
<body>
|
|
19
|
+
<slot />
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following
|
|
25
|
+
the system preference; see [Setup → Configuration](../setup.md#configuration).
|
|
26
|
+
|
|
27
|
+
A project running Tailwind CSS v4 imports `@codenhub/styles/tw` through
|
|
28
|
+
Astro's Tailwind integration instead; see [Tailwind CSS v4](./tailwind.md)
|
|
29
|
+
for the `@source` directive Astro needs to scan `src/`.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Integrating
|
|
3
|
+
description: Wiring the stylesheet into a framework or build target.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Integrating
|
|
7
|
+
|
|
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.
|
|
12
|
+
|
|
13
|
+
Every stack does the same two things:
|
|
14
|
+
|
|
15
|
+
1. Import one [entrypoint](../setup.md#import-paths) — the compiled
|
|
16
|
+
`@codenhub/styles` for any build, or `@codenhub/styles/tw` when the
|
|
17
|
+
project already runs Tailwind CSS v4 — from wherever that framework loads
|
|
18
|
+
global CSS.
|
|
19
|
+
2. Import `@codenhub/styles/aesthetics` (or `/tw/aesthetics`) after it, only
|
|
20
|
+
if the project uses an [aesthetic](../usage/aesthetics.md).
|
|
21
|
+
|
|
22
|
+
| Stack | Guide |
|
|
23
|
+
| ---------------------------------------- | -------------------------------- |
|
|
24
|
+
| A Tailwind CSS v4 project on any bundler | [Tailwind CSS v4](./tailwind.md) |
|
|
25
|
+
| Next.js / React | [Next.js](./nextjs.md) |
|
|
26
|
+
| Vue | [Vue](./vue.md) |
|
|
27
|
+
| Svelte / SvelteKit | [Svelte](./svelte.md) |
|
|
28
|
+
| Astro | [Astro](./astro.md) |
|
|
29
|
+
|
|
30
|
+
A project with no framework — a plain Vite, webpack, or Parcel build — needs
|
|
31
|
+
nothing beyond [Setup](../setup.md#quick-start): import the compiled
|
|
32
|
+
stylesheet from the project's existing global CSS entry.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Next.js
|
|
3
|
+
description: Loading the stylesheet in a Next.js / React app.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Next.js
|
|
7
|
+
|
|
8
|
+
Next.js only allows global CSS to be imported from one place. Import the
|
|
9
|
+
package from the root layout in the App Router, or from the custom App in
|
|
10
|
+
the Pages Router — not from a page or component further down the tree.
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
// app/layout.tsx
|
|
14
|
+
import "@codenhub/styles";
|
|
15
|
+
|
|
16
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
17
|
+
return (
|
|
18
|
+
<html lang="en">
|
|
19
|
+
<body>{children}</body>
|
|
20
|
+
</html>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
// pages/_app.tsx
|
|
27
|
+
import "@codenhub/styles";
|
|
28
|
+
import type { AppProps } from "next/app";
|
|
29
|
+
|
|
30
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
31
|
+
return <Component {...pageProps} />;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Apply `.dark` or `.light` on `<html>` to force a theme instead of following
|
|
36
|
+
the system preference; see [Setup → Configuration](../setup.md#configuration).
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<html lang="en" className="dark">
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
A project running Tailwind CSS v4 imports `@codenhub/styles/tw` from the
|
|
43
|
+
same file instead; see [Tailwind CSS v4](./tailwind.md) for the `@source`
|
|
44
|
+
directive Next.js needs to scan its own `app`/`src` directories.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Svelte
|
|
3
|
+
description: Loading the stylesheet in a Svelte / SvelteKit app.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Svelte
|
|
7
|
+
|
|
8
|
+
In SvelteKit, import the package from the root layout so it loads once for
|
|
9
|
+
every route:
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<!-- src/routes/+layout.svelte -->
|
|
13
|
+
<script>
|
|
14
|
+
import "@codenhub/styles";
|
|
15
|
+
let { children } = $props();
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
{@render children()}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In a plain Svelte + Vite app, import it from the entry file instead:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// main.ts
|
|
25
|
+
import "@codenhub/styles";
|
|
26
|
+
import { mount } from "svelte";
|
|
27
|
+
import App from "./App.svelte";
|
|
28
|
+
|
|
29
|
+
mount(App, { target: document.getElementById("app")! });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Apply `.dark` or `.light` on `<html>` (edit `src/app.html` in SvelteKit) to
|
|
33
|
+
force a theme instead of following the system preference; see
|
|
34
|
+
[Setup → Configuration](../setup.md#configuration).
|
|
35
|
+
|
|
36
|
+
A project running Tailwind CSS v4 imports `@codenhub/styles/tw` from the
|
|
37
|
+
app's CSS entry instead; see [Tailwind CSS v4](./tailwind.md).
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Tailwind CSS v4
|
|
3
|
+
description: Using the /tw source entrypoints in a Tailwind CSS v4 project.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tailwind CSS v4
|
|
7
|
+
|
|
8
|
+
A project that already runs Tailwind CSS v4 can process this package's
|
|
9
|
+
source instead of its compiled output. `/tw` entrypoints publish copied,
|
|
10
|
+
uncompiled source from `dist/tw`; your own Tailwind build compiles it
|
|
11
|
+
alongside your app, so its `@theme`, `@utility`, and `@apply` directives
|
|
12
|
+
resolve together with yours.
|
|
13
|
+
|
|
14
|
+
```css
|
|
15
|
+
@import "tailwindcss";
|
|
16
|
+
@import "@codenhub/styles/tw";
|
|
17
|
+
|
|
18
|
+
@source "./src";
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`@source` tells Tailwind's build where to scan for the utility and component
|
|
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.
|
|
25
|
+
|
|
26
|
+
Add aesthetics from the source entrypoint the same way as the compiled one,
|
|
27
|
+
after the base import:
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
@import "tailwindcss";
|
|
31
|
+
@import "@codenhub/styles/tw";
|
|
32
|
+
@import "@codenhub/styles/tw/aesthetics";
|
|
33
|
+
|
|
34
|
+
@source "./src";
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Import a focused `/tw/*` entrypoint instead of the combined one — such as
|
|
38
|
+
`/tw/button` or `/tw/form` — when a build only needs one component family;
|
|
39
|
+
see the full [import path table](../setup.md#import-paths) for what each one
|
|
40
|
+
composes. Tailwind CSS 4 or newer is required for every `/tw` entrypoint.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Vue
|
|
3
|
+
description: Loading the stylesheet in a Vue / Vite app.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Vue
|
|
7
|
+
|
|
8
|
+
Import the package once, from the app's entry file, before the app mounts:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
// main.ts
|
|
12
|
+
import "@codenhub/styles";
|
|
13
|
+
import { createApp } from "vue";
|
|
14
|
+
import App from "./App.vue";
|
|
15
|
+
|
|
16
|
+
createApp(App).mount("#app");
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Apply `.dark` or `.light` on the root element to force a theme instead of
|
|
20
|
+
following the system preference; see
|
|
21
|
+
[Setup → Configuration](../setup.md#configuration).
|
|
22
|
+
|
|
23
|
+
A project running Tailwind CSS v4 imports `@codenhub/styles/tw` from a CSS
|
|
24
|
+
entry file instead of `main.ts`, using the `@tailwindcss/vite` plugin; see
|
|
25
|
+
[Tailwind CSS v4](./tailwind.md).
|
package/docs/setup.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Setup
|
|
3
|
+
description: Install the package, pick an entrypoint, and render a first component.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Setup
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
pnpm add @codenhub/styles
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick start
|
|
15
|
+
|
|
16
|
+
Import the compiled stylesheet for the complete token, reset, utility, and
|
|
17
|
+
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
|
|
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.
|
|
35
|
+
|
|
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:
|
|
38
|
+
|
|
39
|
+
```css
|
|
40
|
+
@import "@codenhub/styles";
|
|
41
|
+
@import "@codenhub/styles/aesthetics";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<section class="neobrutalism">
|
|
46
|
+
<button class="btn primary">Thick ink and a hard shadow</button>
|
|
47
|
+
</section>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A project already running Tailwind CSS v4 imports the source entrypoint
|
|
51
|
+
instead; see [Integrating → Tailwind CSS v4](./integrating/tailwind.md).
|
|
52
|
+
|
|
53
|
+
## Configuration
|
|
54
|
+
|
|
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.
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<html class="dark">
|
|
61
|
+
<body>
|
|
62
|
+
<button class="btn primary">Dark themed button</button>
|
|
63
|
+
</body>
|
|
64
|
+
</html>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See [Concepts → Theme selection](./concepts.md#theme-selection) for how
|
|
68
|
+
selectors resolve and [Usage → Theming](./usage/theming.md) for the full color
|
|
69
|
+
token reference.
|
|
70
|
+
|
|
71
|
+
## Import paths
|
|
72
|
+
|
|
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.
|
|
78
|
+
|
|
79
|
+
| Import path | Composition and effects |
|
|
80
|
+
| -------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
81
|
+
| `@codenhub/styles` | Compiled complete surface: Tailwind base/theme output, tokens, typography, utilities, components, and reset. Applies global reset, root theme, and focus rules. |
|
|
82
|
+
| `@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. |
|
|
83
|
+
| `@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. |
|
|
84
|
+
| `@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. |
|
|
85
|
+
| `@codenhub/styles/aesthetics` | Compiled `.neobrutalism`, `.glass`, `.pixel`, and `.chunky-tile` classes. Adds no tokens or components of its own; import after the base stylesheet. |
|
|
86
|
+
| `@codenhub/styles/aesthetics/*` | One compiled aesthetic: `/neobrutalism`, `/glass`, `/pixel`, or `/chunky-tile`. Same rules and ordering as the combined file. |
|
|
87
|
+
| `@codenhub/styles/tw` | Source equivalent of the complete stylesheet. Imports Tailwind itself, theme, typography, utilities, components, and reset; applies the same global rules. |
|
|
88
|
+
| `@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
|
+
| `@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
|
+
| `@codenhub/styles/tw/surface` | Source theme plus `.surface`, `.card`, and `.panel`. |
|
|
91
|
+
| `@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. |
|
|
92
|
+
| `@codenhub/styles/tw/form` | Source theme plus field, public `text-control`, input, textarea, select, checkbox, radio, and switch utilities. |
|
|
93
|
+
| `@codenhub/styles/tw/feedback` | Source theme plus alert, badge, skeleton, and progress utilities and their keyframes. |
|
|
94
|
+
| `@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`. |
|
|
95
|
+
| `@codenhub/styles/tw/tooltip` | Source theme plus tooltip utilities. |
|
|
96
|
+
| `@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. |
|
|
97
|
+
| `@codenhub/styles/tw/native` | Source complete surface plus reset and classless native-element mappings; broadest global effects. |
|
|
98
|
+
| `@codenhub/styles/tw/typography` | Source theme plus typography utilities; sets theme selectors but no reset or classless mappings. |
|
|
99
|
+
| `@codenhub/styles/tw/utilities` | Source theme and typography composition plus layout and content utilities; safelists the package utility names. |
|
|
100
|
+
| `@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
|
+
|
|
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.
|
|
105
|
+
|
|
106
|
+
## Requirements
|
|
107
|
+
|
|
108
|
+
- 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
|
+
- 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).
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Aesthetics
|
|
3
|
+
description: The four shipped aesthetics in depth, including their documented exceptions.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Aesthetics
|
|
7
|
+
|
|
8
|
+
An aesthetic decides what a component is _made of_: its radius, border
|
|
9
|
+
thickness, shadow, and shape. Aesthetics ship from opt-in entrypoints, so
|
|
10
|
+
importing the stylesheet is what makes the classes available:
|
|
11
|
+
|
|
12
|
+
```css
|
|
13
|
+
@import "@codenhub/styles";
|
|
14
|
+
@import "@codenhub/styles/aesthetics";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Import them after the base stylesheet. `.neobrutalism` and `.pixel` replace
|
|
18
|
+
the neutral border color, and they do so at zero specificity, so source order
|
|
19
|
+
is what lets them win.
|
|
20
|
+
|
|
21
|
+
Like presentation, an aesthetic class cascades to any subtree:
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<section class="neobrutalism">
|
|
25
|
+
<button class="btn primary">Thick ink and a hard shadow</button>
|
|
26
|
+
<div class="card destructive">The intent still wins over the aesthetic ink</div>
|
|
27
|
+
</section>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Class | Look |
|
|
31
|
+
| --------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| `.neobrutalism` | No radius, a thick ink outline, a hard unblurred offset shadow, and a press that moves the element into it. |
|
|
33
|
+
| `.glass` | Translucent surfaces over a blurred backdrop with a hairline highlight edge. |
|
|
34
|
+
| `.pixel` | Corners cut by one grid unit, a chunky outline drawn as an inset ring, and the consumer-supplied `--font-pixel` over monospace. |
|
|
35
|
+
| `.chunky-tile` | Rounded slabs seated on a darker shade of themselves, with a press that moves the element down into its own bar. |
|
|
36
|
+
|
|
37
|
+
Aesthetics compose with every supported fill and edge pair. `.ghost.edgeless`
|
|
38
|
+
intentionally removes the visible material traits from components whose
|
|
39
|
+
aesthetic is expressed only through their fill, edge, or elevation.
|
|
40
|
+
|
|
41
|
+
An explicit presentation on the element still wins over the aesthetic's
|
|
42
|
+
defaults. The aesthetic supplies edge thickness; presentation only decides
|
|
43
|
+
whether that edge is drawn.
|
|
44
|
+
|
|
45
|
+
An aesthetic directly on a component likewise wins over an inherited
|
|
46
|
+
aesthetic. This includes tooltip pseudo-elements: `.tooltip.glass` gets the
|
|
47
|
+
complete glass bubble under a pixel ancestor, and `.tooltip.pixel` gets the
|
|
48
|
+
complete stepped bubble under a glass ancestor.
|
|
49
|
+
|
|
50
|
+
Each aesthetic that scales from one number publishes it as a knob — see
|
|
51
|
+
[Customizing → Aesthetic tokens](./customizing.md#aesthetic-tokens) for how
|
|
52
|
+
knobs resolve and where they can be set. This page covers what each
|
|
53
|
+
aesthetic looks like and where it makes documented exceptions.
|
|
54
|
+
|
|
55
|
+
## Neobrutalism
|
|
56
|
+
|
|
57
|
+
The shadow is cast in the component's own intent, so a success button throws
|
|
58
|
+
a green shadow and a destructive card a red one. With no intent, both the
|
|
59
|
+
outline and the shadow use the ink, which follows the theme rather than the
|
|
60
|
+
palette.
|
|
61
|
+
|
|
62
|
+
`--neo-offset` is the knob: the shadow offset and the distance the press
|
|
63
|
+
travels are the same number, so scaling the look scales both at once.
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<section class="neobrutalism" style="--neo-offset: 6px">
|
|
67
|
+
<button class="btn primary">A longer throw</button>
|
|
68
|
+
</section>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**Exceptions:**
|
|
72
|
+
|
|
73
|
+
- Content chips are left alone. A `.kbd`, `.code`, or `.pre` is content
|
|
74
|
+
rather than structure, and an ink edge on one reads as a defect: a key cap
|
|
75
|
+
keeps the quiet border color and a code chip keeps no border at all.
|
|
76
|
+
- Only `.btn` and `.card.interactive` respond to hover and press. A card
|
|
77
|
+
becomes a control when it opts in with `.interactive`; a plain card, an
|
|
78
|
+
alert, or a panel is a container and stays put.
|
|
79
|
+
- An alert rests on the slab under this aesthetic and nowhere else. Here the
|
|
80
|
+
slab is a second ink line rather than depth, and an alert is the only
|
|
81
|
+
container the package rests flat, so without it a neobrutalist alert is
|
|
82
|
+
the one box on the page that reads as unfinished. It is a resting default,
|
|
83
|
+
so `.flat` still takes it off and `.floating` still doubles it.
|
|
84
|
+
|
|
85
|
+
## Glass
|
|
86
|
+
|
|
87
|
+
`.glass` needs something behind it to blur. On a flat page background it
|
|
88
|
+
renders as a plain translucent panel.
|
|
89
|
+
|
|
90
|
+
`--glass-radius` and `--glass-radius-surface` are the corners, at `0.75rem`
|
|
91
|
+
and `1rem`. Glass is rounder than the base geometry because a translucent
|
|
92
|
+
panel with a tight corner reads as a cut-out rather than as a pane.
|
|
93
|
+
|
|
94
|
+
```html
|
|
95
|
+
<section class="glass" style="--glass-radius-surface: 1.5rem">
|
|
96
|
+
<div class="card">Softer</div>
|
|
97
|
+
</section>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Exceptions:**
|
|
101
|
+
|
|
102
|
+
- The blur applies to `.card`, `.panel`, `.alert`, and the tooltip bubble
|
|
103
|
+
only. Controls stay solid and sit on the glass: a blur under every control
|
|
104
|
+
of a dense cluster costs a composited layer apiece and reads as noise.
|
|
105
|
+
Controls still take the aesthetic's radius, border, and shadow.
|
|
106
|
+
- Under `prefers-reduced-transparency: reduce`, glass surfaces drop the blur
|
|
107
|
+
and become opaque.
|
|
108
|
+
|
|
109
|
+
## Pixel
|
|
110
|
+
|
|
111
|
+
`--pixel-unit` is one pixel of the imaginary low-resolution grid, `4px` by
|
|
112
|
+
default. One square unit is cut from each corner and the outline is one unit
|
|
113
|
+
thick, so the cut and what covers it are the same size.
|
|
114
|
+
|
|
115
|
+
```html
|
|
116
|
+
<section class="pixel" style="--pixel-unit: 6px">
|
|
117
|
+
<button class="btn primary">Chunkier</button>
|
|
118
|
+
</section>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Exceptions:**
|
|
122
|
+
|
|
123
|
+
- Corners are one unit or nothing. Chips square instead of stepping —
|
|
124
|
+
badges, key caps, code, checkboxes, and switches all read
|
|
125
|
+
`--ui-clip-tight`, which this aesthetic sets to none, because one unit off
|
|
126
|
+
each corner of a 24px badge is a bite rather than a corner. Tables,
|
|
127
|
+
progress bars, and skeletons square too, each for its own reason: a
|
|
128
|
+
table's `overflow: hidden` fights the clip and the corners square off
|
|
129
|
+
where the two meet, and progress and skeleton never read a clip at all —
|
|
130
|
+
a squaring aesthetic reaches them through `border-radius` alone. `.pre` is
|
|
131
|
+
the one exception that steps: it carries no clip override, so it inherits
|
|
132
|
+
the same polygon a button or a card gets, and with no border by default
|
|
133
|
+
the cut shows with no ring around it.
|
|
134
|
+
- The outline is an inset ring, because a clip removes a real border — and
|
|
135
|
+
the focus ring, for the same reason, is a second inset layer rather than
|
|
136
|
+
an outline. Both are the element's own edge rather than a shadow, so the
|
|
137
|
+
border answers `.edged` and `.edgeless` the way a border does: a
|
|
138
|
+
`.edgeless` badge and a `.solid` button draw none, a `.edged` card draws
|
|
139
|
+
one, and a field keeps one whatever a container asks for.
|
|
140
|
+
- The tooltip trigger and `.radio` are hardcoded past the clip rather than
|
|
141
|
+
reached by it. `.tooltip-icon` forces `clip-path: none`, since a stepped
|
|
142
|
+
badge would clip its own bubble away with it. `.radio` forces the same,
|
|
143
|
+
because the circle is the only thing telling it from a checkbox at a
|
|
144
|
+
glance, and a stepped polygon would square it.
|
|
145
|
+
- `--font-pixel` is yours to supply. The package ships no font binary, so the
|
|
146
|
+
aesthetic has no network side effect and falls back to the monospace
|
|
147
|
+
stack.
|
|
148
|
+
|
|
149
|
+
## Chunky tile
|
|
150
|
+
|
|
151
|
+
Rounded slabs sitting on a darker shade of themselves, pressed flat on
|
|
152
|
+
click. The look mobile learning and game apps use; it is named for what it
|
|
153
|
+
is made of rather than for any one product.
|
|
154
|
+
|
|
155
|
+
`--tile-lift` is how deep the bar is and how far a press travels, `4px` by
|
|
156
|
+
default. One number drives both, so the top edge drops by exactly the bar's
|
|
157
|
+
depth and the bottom edge does not move. `--tile-radius` is the corner,
|
|
158
|
+
`0.75rem`, and it is one value rather than a control/surface pair on
|
|
159
|
+
purpose — the shared corner is what makes a button and the card it sits in
|
|
160
|
+
read as the same object.
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<section class="chunky-tile" style="--tile-lift: 6px; --tile-radius: 0.5rem">
|
|
164
|
+
<button class="btn success">Continue</button>
|
|
165
|
+
</section>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The bar is a darker shade of the element's own colour rather than a shadow
|
|
169
|
+
under it, so it follows every intent: a success button sits on a dark green
|
|
170
|
+
edge, a destructive one on a dark red edge, and a plain card on a grey edge
|
|
171
|
+
that matches the line it already draws. Measured on the light palette,
|
|
172
|
+
`.btn.success` is `#007a55` on `#004c34`. On a dark page a near-black
|
|
173
|
+
surface cannot go darker, so its bar lands lighter and reads as a rim.
|
|
174
|
+
|
|
175
|
+
**Exceptions:**
|
|
176
|
+
|
|
177
|
+
- Only what the registry rests above zero sits on a bar — buttons and cards.
|
|
178
|
+
A badge, chip, field, or tooltip is flat until it asks for depth with
|
|
179
|
+
`.raised`, and `.flat` takes the bar off anything:
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<div class="card soft edgeless info flat">Promo panel, deliberately flat</div>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- `--font-rounded` is yours to supply. A heavy rounded grotesque is most of
|
|
186
|
+
this look and the package ships no font binary, so with nothing supplied
|
|
187
|
+
the page's own stack is used.
|
|
188
|
+
- Action labels are drawn heavier and slightly tracked. Casing is left
|
|
189
|
+
alone: how a label is worded is the application's decision, so if you want
|
|
190
|
+
uppercase buttons, write that rule in your own stylesheet.
|
|
191
|
+
- `.card.interactive` presses like a `.btn`, so a chunky answer tile drops
|
|
192
|
+
onto its bar on click. A plain `.card` stays put.
|
|
193
|
+
- The shipped `.primary` is a near-black monochrome, which leaves a primary
|
|
194
|
+
button's bar almost invisible against its own plate; give `.primary` a hue
|
|
195
|
+
if it is the call to action.
|
|
196
|
+
- Depth in this aesthetic is the bar, never a blurred drop shadow. Anything
|
|
197
|
+
the registry rests flat sits flush on the page.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Buttons
|
|
3
|
+
description: Button classes, intents, sizes, and states.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Buttons
|
|
7
|
+
|
|
8
|
+
Use `.btn` with one optional intent class, one optional fill class, one
|
|
9
|
+
optional edge class, optional size class, and optional state. See
|
|
10
|
+
[Composing](./composing.md) for how the intent, presentation, and aesthetic
|
|
11
|
+
axes combine on any component.
|
|
12
|
+
|
|
13
|
+
Intent classes map color tokens into button tone slots.
|
|
14
|
+
[Presentation](./composing.md#presentation) decides how much of that intent
|
|
15
|
+
reaches background, text, border, and hover.
|
|
16
|
+
|
|
17
|
+
Intent classes:
|
|
18
|
+
|
|
19
|
+
| Class | Meaning |
|
|
20
|
+
| ----------------------------------- | ------------------------------ |
|
|
21
|
+
| `.neutral` _(default)_ | No specific intent. |
|
|
22
|
+
| `.primary` | Primary action. |
|
|
23
|
+
| `.secondary` | Secondary/accent action. |
|
|
24
|
+
| `.success` | Successful or positive action. |
|
|
25
|
+
| `.warning` | Warning/caution action. |
|
|
26
|
+
| `.destructive`, `.danger`, `.error` | Destructive or error action. |
|
|
27
|
+
| `.info` | Informational action. |
|
|
28
|
+
|
|
29
|
+
Every component that supports intent accepts the same list and reads the
|
|
30
|
+
same [intent tokens](./theming.md#intent-tokens), so a custom intent class
|
|
31
|
+
works everywhere without touching a component.
|
|
32
|
+
|
|
33
|
+
`.neutral` is the only intent that does not fill all the way. Its color is
|
|
34
|
+
the page's own text color, so a full fill of it would be a black or white
|
|
35
|
+
slab — the loudest element on the page, for the intent that means nothing in
|
|
36
|
+
particular. It stops at `--intent-fill-max`, which is why a `.solid` neutral
|
|
37
|
+
is a quiet plate a step past `.soft` rather than a block of ink. Set the slot
|
|
38
|
+
on your own intent classes; see [Theming → Intent tokens](./theming.md#intent-tokens).
|
|
39
|
+
|
|
40
|
+
Size and shape classes:
|
|
41
|
+
|
|
42
|
+
| Class | Purpose |
|
|
43
|
+
| ---------------------------------------------------------------------- | ----------------------------------------------------------- |
|
|
44
|
+
| `.pill` | Fully rounded button corners (`border-radius: 9999px`). |
|
|
45
|
+
| `.sm` | Smaller button. |
|
|
46
|
+
| `.lg` | Larger button. |
|
|
47
|
+
| `.p-sm`, `.compact` | Compact padding modifier (`px-2.5 py-1`). |
|
|
48
|
+
| `.p-lg`, `.spacious` | Spacious padding modifier (`px-6 py-3`). |
|
|
49
|
+
| `.icon` | Square icon button. Use an accessible name in HTML. |
|
|
50
|
+
| `.loading` | Loading state. Hides text and shows CSS activity indicator. |
|
|
51
|
+
| `.disabled`, `[disabled]`, `[aria-disabled="true"]`, `[data-disabled]` | Disabled styling. |
|
|
52
|
+
|
|
53
|
+
Examples:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<button class="btn primary">Primary</button>
|
|
57
|
+
<button class="btn success ghost edged">Success outline</button>
|
|
58
|
+
<button class="btn warning soft">Warning soft</button>
|
|
59
|
+
<button class="btn destructive ghost edgeless">Danger ghost</button>
|
|
60
|
+
<button class="btn icon primary" aria-label="Create">+</button>
|
|
61
|
+
<button class="btn primary loading" disabled>Saving</button>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`.loading` is a state, not a color or presentation class. Prefer combining
|
|
65
|
+
it with disabled behavior so users cannot trigger duplicate work. Loading
|
|
66
|
+
buttons keep only opacity and transform transitions active so spinner and
|
|
67
|
+
surface colors stay synchronized when theme tokens change.
|
|
68
|
+
|
|
69
|
+
On the base look a press scales the button down a little
|
|
70
|
+
(`--ui-active-transform`, `scale(0.97)`). [Aesthetics](./aesthetics.md) swap
|
|
71
|
+
in their own press gesture, and `prefers-reduced-motion` turns it off.
|
|
72
|
+
|
|
73
|
+
Use `<button>` for actions or an accessible link for navigation; see
|
|
74
|
+
[Accessibility](../accessibility.md).
|