@skriv/ads 0.0.0-stage → 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 +47 -2
- package/bin/ads.mjs +59 -0
- package/dist/manifest.json +53 -0
- package/dist/skills/ads-code-review/SKILL.md +12 -0
- package/dist/skills/ads-code-to-figma/SKILL.md +10 -0
- package/dist/skills/ads-figma-to-code/SKILL.md +10 -0
- package/dist/skills/ads-init/SKILL.md +16 -0
- package/dist/skills/ads-init/profile.md +11 -0
- package/dist/skills/ads-init/scripts/connect.py +75 -0
- package/dist/skills/ads-record/SKILL.md +12 -0
- package/dist/skills/heroui-react/LICENSE.txt +199 -0
- package/dist/skills/heroui-react/SKILL.md +234 -0
- package/dist/skills/heroui-react/scripts/get_component_docs.mjs +157 -0
- package/dist/skills/heroui-react/scripts/get_docs.mjs +148 -0
- package/dist/skills/heroui-react/scripts/get_source.mjs +160 -0
- package/dist/skills/heroui-react/scripts/get_styles.mjs +160 -0
- package/dist/skills/heroui-react/scripts/get_theme.mjs +177 -0
- package/dist/skills/heroui-react/scripts/list_components.mjs +134 -0
- package/dist/skills/heroui-theming/LICENSE.txt +199 -0
- package/dist/skills/heroui-theming/SKILL.md +268 -0
- package/dist/skills/heroui-theming/references/any-framework.md +219 -0
- package/dist/skills/heroui-theming/references/components.md +237 -0
- package/dist/skills/heroui-theming/references/theme-recipe.md +701 -0
- package/dist/skills/heroui-theming/references/tokens.md +258 -0
- package/dist/skills/heroui-theming/scripts/_styles_dir.mjs +112 -0
- package/dist/skills/heroui-theming/scripts/list_component_classes.mjs +319 -0
- package/dist/skills/heroui-theming/scripts/list_tokens.mjs +157 -0
- package/dist/templates/flow.md +12 -0
- package/dist/templates/project.md +13 -0
- package/dist/templates/review.md +14 -0
- package/dist/templates/routing.md +11 -0
- package/dist/templates/theming.md +26 -0
- package/package.json +32 -4
- package/src/doctor.mjs +38 -0
- package/src/install.mjs +140 -0
- package/src/video.mjs +18 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# HeroUI Theme Tokens
|
|
2
|
+
|
|
3
|
+
Every theme variable in the open-source default theme, grouped by purpose. Defaults below are from `@heroui/styles` 3.2.x. **The installed version is the source of truth** — list it with:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
node scripts/list_tokens.mjs # shared + light + dark + Tailwind mapping
|
|
7
|
+
node scripts/list_tokens.mjs --mode dark
|
|
8
|
+
node scripts/list_tokens.mjs --names # names only
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or read the files directly:
|
|
12
|
+
|
|
13
|
+
| File (published package) | Contains |
|
|
14
|
+
| --------------------------------------------------------------- | ------------------------------------------ |
|
|
15
|
+
| `node_modules/@heroui/styles/dist/themes/default/variables.css` | Token values: shared, light, dark |
|
|
16
|
+
| `node_modules/@heroui/styles/dist/themes/shared/theme.css` | Token → Tailwind mapping (`@theme inline`) |
|
|
17
|
+
| `node_modules/@heroui/styles/dist/utilities/index.css` | `focus-ring`, `status-*`, `scrollbar*` |
|
|
18
|
+
|
|
19
|
+
## How a token becomes a utility
|
|
20
|
+
|
|
21
|
+
`theme.css` maps each token into a Tailwind theme namespace with `@theme inline`:
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
@theme inline {
|
|
25
|
+
--color-accent: var(--accent); /* bg-accent, text-accent, border-accent, ring-accent, fill-accent… */
|
|
26
|
+
--shadow-surface: var(--surface-shadow); /* shadow-surface */
|
|
27
|
+
--radius-field: var(--field-radius, calc(var(--radius) * 1.5)); /* rounded-field */
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
So you override the **short name** (`--accent`), and every utility and component that uses `bg-accent` follows. Do not override `--color-*` names.
|
|
32
|
+
|
|
33
|
+
Naming rule: a color without a suffix is a **background**; the same name with `-foreground` is the **text/icon color placed on it**. Always change them as a pair.
|
|
34
|
+
|
|
35
|
+
## Which selectors hold the defaults
|
|
36
|
+
|
|
37
|
+
| Block | Selector |
|
|
38
|
+
| ------ | ----------------------------------------------------------------------- |
|
|
39
|
+
| Shared | `:root, :host` |
|
|
40
|
+
| Light | `:root, .light, .default, [data-theme="light"], [data-theme="default"]` |
|
|
41
|
+
| Dark | `.dark, [data-theme="dark"]` |
|
|
42
|
+
|
|
43
|
+
(Each also has a `:host(...)` twin for shadow DOM.) Light and dark blocks set `color-scheme`.
|
|
44
|
+
|
|
45
|
+
## Primitives
|
|
46
|
+
|
|
47
|
+
Not mapped to Tailwind utilities (there is no `bg-snow`); reference them with `var()`.
|
|
48
|
+
|
|
49
|
+
| Token | Default | Used for |
|
|
50
|
+
| ----------- | ----------------------------- | --------------------------------------------------------------------- |
|
|
51
|
+
| `--white` | `oklch(100% 0 0)` | Light `--surface`, `--overlay`, `--field-background` |
|
|
52
|
+
| `--black` | `oklch(0% 0 0)` | Reserved primitive |
|
|
53
|
+
| `--snow` | `oklch(0.9911 0 0)` | Light text on dark fills (`--accent-foreground`, dark `--foreground`) |
|
|
54
|
+
| `--eclipse` | `oklch(0.2103 0.0059 285.89)` | Dark text (`--foreground` in light, `--success-foreground`…) |
|
|
55
|
+
|
|
56
|
+
Tinting `--snow` / `--eclipse` tints every foreground that references them.
|
|
57
|
+
|
|
58
|
+
## Canvas and text
|
|
59
|
+
|
|
60
|
+
| Token | Light | Dark | Utility | Affects |
|
|
61
|
+
| -------------- | ----------------------------- | ---------------------------- | ----------------- | ------------------------------------------------ |
|
|
62
|
+
| `--background` | `oklch(0.9702 0 0)` | `oklch(12% 0.005 285.823)` | `bg-background` | Page canvas (put on `<body>`), focus ring offset |
|
|
63
|
+
| `--foreground` | `var(--eclipse)` | `var(--snow)` | `text-foreground` | Default text; input to most calculated tokens |
|
|
64
|
+
| `--muted` | `oklch(0.5517 0.0138 285.94)` | `oklch(70.5% 0.015 286.067)` | `text-muted` | Descriptions, placeholders, secondary text |
|
|
65
|
+
| `--link` | `var(--foreground)` | `var(--foreground)` | `text-link` | Link, breadcrumbs, prose links |
|
|
66
|
+
|
|
67
|
+
## Surfaces (non-floating containers)
|
|
68
|
+
|
|
69
|
+
| Token | Light | Dark | Utility | Affects |
|
|
70
|
+
| -------------------------------- | ----------------------------- | ----------------------------- | ----------------------------------- | --------------------------------------------- |
|
|
71
|
+
| `--surface` | `var(--white)` | `oklch(0.2103 0.0059 285.89)` | `bg-surface` | Card, Accordion, Alert, Table, Toast, Toolbar |
|
|
72
|
+
| `--surface-foreground` | `var(--foreground)` | `var(--foreground)` | `text-surface-foreground` | Text on surfaces |
|
|
73
|
+
| `--surface-secondary` | `oklch(0.9524 0.0013 286.37)` | `oklch(0.257 0.0037 286.14)` | `bg-surface-secondary` | `card--secondary`, Surface, Table |
|
|
74
|
+
| `--surface-secondary-foreground` | `var(--foreground)` | `var(--foreground)` | `text-surface-secondary-foreground` | |
|
|
75
|
+
| `--surface-tertiary` | `oklch(0.9373 0.0013 286.37)` | `oklch(0.2721 0.0024 247.91)` | `bg-surface-tertiary` | `card--tertiary`, Skeleton |
|
|
76
|
+
| `--surface-tertiary-foreground` | `var(--foreground)` | `var(--foreground)` | `text-surface-tertiary-foreground` | |
|
|
77
|
+
|
|
78
|
+
## Overlays (floating layers)
|
|
79
|
+
|
|
80
|
+
| Token | Light | Dark | Utility | Affects |
|
|
81
|
+
| ---------------------- | -------------------- | ----------------------------- | ------------------------- | -------------------------------------------------------------------------- |
|
|
82
|
+
| `--overlay` | `var(--white)` | `oklch(0.2103 0.0059 285.89)` | `bg-overlay` | Popover, Tooltip, Dropdown, Select/ComboBox popovers, Modal, Drawer, Sheet |
|
|
83
|
+
| `--overlay-foreground` | `var(--foreground)` | `var(--foreground)` | `text-overlay-foreground` | Text on overlays |
|
|
84
|
+
| `--backdrop` | `rgba(0, 0, 0, 0.5)` | `rgba(0, 0, 0, 0.6)` | `bg-backdrop` | Modal, AlertDialog, Drawer, Sheet backdrops |
|
|
85
|
+
|
|
86
|
+
## Neutral fill
|
|
87
|
+
|
|
88
|
+
| Token | Light | Dark | Utility | Affects |
|
|
89
|
+
| ---------------------- | -------------------------- | ---------------------------- | ------------------------- | ---------------------------------------------------------------------------- |
|
|
90
|
+
| `--default` | `oklch(94% 0.001 286.375)` | `oklch(27.4% 0.006 286.033)` | `bg-default` | Secondary/tertiary buttons, chips, tabs list, switch track, kbd, hover fills |
|
|
91
|
+
| `--default-foreground` | `var(--eclipse)` | `var(--snow)` | `text-default-foreground` | Text on `--default` |
|
|
92
|
+
| `--segment` | `var(--white)` | `oklch(0.3964 0.01 285.93)` | `bg-segment` | Selected tab indicator |
|
|
93
|
+
| `--segment-foreground` | `var(--eclipse)` | `var(--foreground)` | `text-segment-foreground` | Text on the selected segment |
|
|
94
|
+
|
|
95
|
+
## Accent and status
|
|
96
|
+
|
|
97
|
+
`--accent` and `--success` are declared once in the shared block; `--warning` and `--danger` per mode.
|
|
98
|
+
|
|
99
|
+
| Token | Light | Dark | Utility | Affects |
|
|
100
|
+
| ---------------------- | ----------------------------- | ---------------------------- | -------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| `--accent` | `oklch(0.6204 0.195 253.83)` | same | `bg-accent`, `text-accent` | Primary button, checked Switch/Checkbox/Radio, Slider, Progress, selected dates, default `--focus` |
|
|
102
|
+
| `--accent-foreground` | `var(--snow)` | same | `text-accent-foreground` | Text/icons on accent |
|
|
103
|
+
| `--success` | `oklch(0.7329 0.1935 150.81)` | same | `bg-success` | Success chips/badges/meters/progress |
|
|
104
|
+
| `--success-foreground` | `var(--eclipse)` | same | `text-success-foreground` | |
|
|
105
|
+
| `--warning` | `oklch(0.7819 0.1585 72.33)` | `oklch(0.8203 0.1388 76.34)` | `bg-warning` | Warning chips/badges/meters/progress |
|
|
106
|
+
| `--warning-foreground` | `var(--eclipse)` | `var(--eclipse)` | `text-warning-foreground` | |
|
|
107
|
+
| `--danger` | `oklch(0.6532 0.2328 25.74)` | `oklch(0.594 0.1967 24.63)` | `bg-danger`, `text-danger` | Danger button, invalid field ring, error text |
|
|
108
|
+
| `--danger-foreground` | `var(--snow)` | `var(--snow)` | `text-danger-foreground` | |
|
|
109
|
+
|
|
110
|
+
## Form fields
|
|
111
|
+
|
|
112
|
+
One group restyles every field: Input, TextArea, InputGroup, NumberField, SearchField, Select, ComboBox, Autocomplete, DateField, InputOTP, ColorField, and the Checkbox/Radio controls.
|
|
113
|
+
|
|
114
|
+
| Token | Light | Dark | Utility / variable | Affects |
|
|
115
|
+
| ---------------------- | ----------------------------- | ----------------------------- | ---------------------------------------- | ------------------------- |
|
|
116
|
+
| `--field-background` | `var(--white)` | `oklch(0.2103 0.0059 285.89)` | `bg-field` | Field fill |
|
|
117
|
+
| `--field-foreground` | `oklch(0.2103 0.0059 285.89)` | `var(--foreground)` | `text-field-foreground` | Typed text, caret |
|
|
118
|
+
| `--field-placeholder` | `var(--muted)` | `var(--muted)` | `placeholder:text-field-placeholder` | Placeholder |
|
|
119
|
+
| `--field-border` | `transparent` (shared) | same | `border-field-border` | Field outline color |
|
|
120
|
+
| `--field-border-width` | `0px` (shared) | same | `var(--border-width-field)` (no utility) | Field outline width |
|
|
121
|
+
| `--field-radius` | `calc(var(--radius) * 1.5)` | same | `rounded-field` | Field corners |
|
|
122
|
+
| `--field-shadow` | see Elevation | see Elevation | `shadow-field` | Field depth, switch thumb |
|
|
123
|
+
|
|
124
|
+
Fields are borderless by default (`0px`, `transparent`). For outlined fields set **both** `--field-border-width` and `--field-border`.
|
|
125
|
+
|
|
126
|
+
## Lines and focus
|
|
127
|
+
|
|
128
|
+
| Token | Light | Dark | Utility | Affects |
|
|
129
|
+
| ------------- | ------------------------- | -------------------------- | ---------------------------------- | ----------------------------------------------------- |
|
|
130
|
+
| `--border` | `oklch(90% 0.004 286.32)` | `oklch(28% 0.006 286.033)` | `border-border` | Default border color of every element, outline button |
|
|
131
|
+
| `--separator` | `oklch(92% 0.004 286.32)` | `oklch(25% 0.006 286.033)` | `bg-separator`, `border-separator` | Separator, Accordion/Table/Drawer dividers |
|
|
132
|
+
| `--focus` | `var(--accent)` | `var(--accent)` | `ring-focus` | Focus ring of every interactive component |
|
|
133
|
+
|
|
134
|
+
`base.css` sets `border-color: var(--border, currentColor)` on `*`, so any `border` you add picks up `--border` automatically.
|
|
135
|
+
|
|
136
|
+
## Shape
|
|
137
|
+
|
|
138
|
+
| Token | Default | Utility | Affects |
|
|
139
|
+
| ---------------- | ---------------------------------- | ---------------------------- | ------------------------------------------------------------------------------- |
|
|
140
|
+
| `--radius` | `0.5rem` | `rounded-xs` … `rounded-4xl` | Base of the whole radius scale (below) |
|
|
141
|
+
| `--font-sans` | Tailwind default (system UI stack) | `font-sans` | Tailwind's token, not HeroUI's: set it in the theme block to change the UI font |
|
|
142
|
+
| `--field-radius` | `calc(var(--radius) * 1.5)` | `rounded-field` | Form fields |
|
|
143
|
+
|
|
144
|
+
| Utility | Value | At default |
|
|
145
|
+
| ------------- | ---------------------------- | ---------- |
|
|
146
|
+
| `rounded-xs` | `calc(var(--radius) * 0.25)` | 2px |
|
|
147
|
+
| `rounded-sm` | `calc(var(--radius) * 0.5)` | 4px |
|
|
148
|
+
| `rounded-md` | `calc(var(--radius) * 0.75)` | 6px |
|
|
149
|
+
| `rounded-lg` | `calc(var(--radius) * 1)` | 8px |
|
|
150
|
+
| `rounded-xl` | `calc(var(--radius) * 1.5)` | 12px |
|
|
151
|
+
| `rounded-2xl` | `calc(var(--radius) * 2)` | 16px |
|
|
152
|
+
| `rounded-3xl` | `calc(var(--radius) * 3)` | 24px |
|
|
153
|
+
| `rounded-4xl` | `calc(var(--radius) * 4)` | 32px |
|
|
154
|
+
|
|
155
|
+
Buttons use `rounded-3xl`, chips `rounded-2xl`, cards/popovers `min(32px, var(--radius-3xl))`. `--radius: 0` squares everything that uses the scale. The few parts hard-coded to `rounded-full` (for example the sheet handle bar and the tab scroll buttons) or to fixed sizes need a component override.
|
|
156
|
+
|
|
157
|
+
## Elevation
|
|
158
|
+
|
|
159
|
+
| Token | Light | Dark | Utility | Affects |
|
|
160
|
+
| ------------------ | ------------------------------------------------------------------------------------------- | -------------------------------------- | ---------------- | -------------------------------------------- |
|
|
161
|
+
| `--surface-shadow` | `0 2px 4px 0 rgba(0,0,0,.04), 0 1px 2px 0 rgba(0,0,0,.06), 0 0 1px 0 rgba(0,0,0,.06)` | `0 0 0 0 transparent inset` | `shadow-surface` | Card, Alert, selected tab |
|
|
162
|
+
| `--overlay-shadow` | `0 2px 8px 0 rgba(0,0,0,.06), 0 -6px 12px 0 rgba(0,0,0,.03), 0 14px 28px 0 rgba(0,0,0,.08)` | `0 0 1px 0 rgba(255,255,255,.3) inset` | `shadow-overlay` | Every popover, tooltip, dialog, toast |
|
|
163
|
+
| `--field-shadow` | same as light `--surface-shadow` | `0 0 0 0 transparent inset` | `shadow-field` | Fields, checkbox/radio control, switch thumb |
|
|
164
|
+
|
|
165
|
+
**Never set a shadow token to `none`.** Tailwind composes `box-shadow` as a comma list (`…, var(--tw-ring-shadow), var(--tw-shadow)`); `none` inside a list is invalid, so the whole declaration is dropped and **the focus ring disappears** with it. For "no shadow" use `0 0 0 0 transparent`, as the default dark theme does.
|
|
166
|
+
|
|
167
|
+
## Sizing and interaction
|
|
168
|
+
|
|
169
|
+
| Token | Default | Affects |
|
|
170
|
+
| ---------------------- | ------------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
171
|
+
| `--spacing` | `0.25rem` | Tailwind's spacing unit: every `p-*`, `gap-*`, `h-*`, `size-*` in every component. Changing it rescales the whole UI |
|
|
172
|
+
| `--border-width` | `1px` | Fallback for `--field-border-width` |
|
|
173
|
+
| `--disabled-opacity` | `0.5` | Opacity of every disabled component (`status-disabled`) |
|
|
174
|
+
| `--ring-offset-width` | `2px` | Gap between a component and its focus ring (`focus-ring`) |
|
|
175
|
+
| `--cursor-interactive` | `pointer` | Cursor on buttons, switches, tabs, menu items… |
|
|
176
|
+
| `--cursor-disabled` | `not-allowed` | Cursor on disabled components |
|
|
177
|
+
|
|
178
|
+
## Scrollbars
|
|
179
|
+
|
|
180
|
+
| Token | Default | Affects |
|
|
181
|
+
| -------------------- | --------------------------------------------------------- | ------------------ |
|
|
182
|
+
| `--scrollbar-thumb` | `color-mix(in oklch, var(--foreground) 15%, transparent)` | Thumb color |
|
|
183
|
+
| `--scrollbar-track` | `transparent` | Track color |
|
|
184
|
+
| `--scrollbar-width` | `thin` | `scrollbar-width` |
|
|
185
|
+
| `--scrollbar-gutter` | `auto` | `scrollbar-gutter` |
|
|
186
|
+
| `--scrollbar-color` | `var(--scrollbar-thumb) var(--scrollbar-track)` | `scrollbar-color` |
|
|
187
|
+
| `--scrollbar` | `var(--scrollbar-thumb)` | Legacy alias |
|
|
188
|
+
|
|
189
|
+
Applied by the `scrollbar` utilities inside component scroll areas. `data-scrollbar="thin | default | none"` on any ancestor switches mode.
|
|
190
|
+
|
|
191
|
+
## Behavior tokens (read by `@heroui/react`, not by CSS)
|
|
192
|
+
|
|
193
|
+
| Token | Default | Values | Read by |
|
|
194
|
+
| ----------------------- | --------- | -------------------------- | -------------------------- |
|
|
195
|
+
| `--skeleton-animation` | `shimmer` | `shimmer`, `pulse`, `none` | Skeleton default animation |
|
|
196
|
+
| `--tooltip-delay` | `1500ms` | any time | Tooltip open delay |
|
|
197
|
+
| `--tooltip-close-delay` | `500ms` | any time | Tooltip close delay |
|
|
198
|
+
|
|
199
|
+
These have no effect on plain HTML.
|
|
200
|
+
|
|
201
|
+
## Calculated tokens
|
|
202
|
+
|
|
203
|
+
Derived with `color-mix()` from the tokens above, inside the light and dark blocks. You normally **do not set them** — change the inputs. Re-declare one only to tune a result (for example a soft foreground that lacks contrast on your background).
|
|
204
|
+
|
|
205
|
+
| Token | Formula (`in oklab`) | Utility |
|
|
206
|
+
| ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- | ------------------------------ |
|
|
207
|
+
| `--accent-hover`, `--success-hover`, `--warning-hover`, `--danger-hover` | 90% color + 10% its `-foreground` | `bg-accent-hover`… |
|
|
208
|
+
| `--default-hover` | 96% `--default` + 4% `--default-foreground` | `bg-default-hover` |
|
|
209
|
+
| `--surface-hover` | 92% `--surface` + 8% `--surface-foreground` | `bg-surface-hover` |
|
|
210
|
+
| `--background-secondary` / `-tertiary` | `--background` + 4% / 8% `--foreground` | `bg-background-secondary`… |
|
|
211
|
+
| `--background-inverse` | `var(--foreground)` | `bg-background-inverse` |
|
|
212
|
+
| `--accent-soft`, `--success-soft`, `--warning-soft` | color at 15% (light) / 12% (dark) over transparent | `bg-accent-soft`… |
|
|
213
|
+
| `--danger-soft` | `--danger` at 15% over transparent | `bg-danger-soft` |
|
|
214
|
+
| `--default-soft` | `--default` at 50% over transparent | `bg-default-soft` |
|
|
215
|
+
| `--*-soft-hover` | same color, a step more opaque (20% light / 16% dark; default 60%) | `bg-accent-soft-hover`… |
|
|
216
|
+
| `--*-soft-foreground` | color mixed toward `--foreground` for contrast (default: `--default-foreground`) | `text-accent-soft-foreground`… |
|
|
217
|
+
| `--field-hover` | 90% `--field-background` + 2% `--field-foreground` | `bg-field-hover` |
|
|
218
|
+
| `--field-focus` | `var(--field-background, var(--default))` | `bg-field-focus` |
|
|
219
|
+
| `--field-border-hover` / `--field-border-focus` | `--field-border` + 10% / 22% `--field-foreground` | `border-field-border-hover`… |
|
|
220
|
+
| `--separator-secondary` / `-tertiary` | `--surface` + 15% / 19% `--surface-foreground` | `bg-separator-secondary`… |
|
|
221
|
+
| `--border-secondary` / `-tertiary` | `--surface` + 22% / 34% `--surface-foreground` | `border-border-secondary`… |
|
|
222
|
+
|
|
223
|
+
`data-vibrant-palette="true"` on the root swaps the accent, success, warning and danger `*-soft-foreground` tokens for a more saturated mix (92% color + 8% foreground).
|
|
224
|
+
|
|
225
|
+
### Calculated tokens resolve where they are declared
|
|
226
|
+
|
|
227
|
+
`--accent-hover` is declared on the root element, so it mixes the **root's** `--accent`. The same is true for Tailwind theme variables that component CSS reads through `var()` (`--radius-3xl`, `--color-field`, `--border-width-field`).
|
|
228
|
+
|
|
229
|
+
- Theme applied on `<html>`: everything recomputes. This is the supported setup.
|
|
230
|
+
- Theme applied on a nested element: base tokens change, calculated tokens keep the root's values (a button inside gets the new `--accent` but the old `--accent-hover`). If you must scope a theme to a subtree, re-declare the calculated tokens in that block too.
|
|
231
|
+
|
|
232
|
+
## Tailwind theme variables without a HeroUI token
|
|
233
|
+
|
|
234
|
+
Defined directly in `theme.css`. Override with your own `@theme` block if needed.
|
|
235
|
+
|
|
236
|
+
| Variables | Utilities |
|
|
237
|
+
| ----------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
238
|
+
| `--ease-smooth`, `--ease-out-fluid`, `--ease-{in,out,in-out}-{quad,cubic,quart,quint,expo,circ}`, `--ease-linear` | `ease-smooth`, `ease-out-fluid`, `ease-out-quart`… (also usable as `var(--ease-smooth)`) |
|
|
239
|
+
| `--animate-spin-fast`, `--animate-skeleton`, `--animate-caret-blink` | `animate-spin-fast`, `animate-skeleton`, `animate-caret-blink` |
|
|
240
|
+
|
|
241
|
+
## Adding your own tokens
|
|
242
|
+
|
|
243
|
+
Theme-specific tokens use a `--<theme>-*` prefix and live in the theme's variable blocks (one value per mode). To get utilities for them, map them once in a file that is imported **without** `layer()`:
|
|
244
|
+
|
|
245
|
+
```css
|
|
246
|
+
@theme inline {
|
|
247
|
+
--color-info: var(--info);
|
|
248
|
+
--color-info-foreground: var(--info-foreground);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Now `bg-info` and `text-info-foreground` exist.
|
|
253
|
+
|
|
254
|
+
## Override precedence (who wins)
|
|
255
|
+
|
|
256
|
+
1. Utilities on the element (`className="rounded-none"`) beat everything in `components`.
|
|
257
|
+
2. **Unlayered CSS beats every layer.** A stray `:root { --accent: … }` outside a layer overrides a named theme's `--accent` even though the theme selector is more specific. When adopting a named theme, move or delete old unlayered token overrides.
|
|
258
|
+
3. Inside the `theme` layer, your `layer(theme)` import wins over the default theme (the defaults sit in a nested sub-layer).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locate the CSS root of the INSTALLED `@heroui/styles` package, so the output
|
|
3
|
+
* always matches the version the project actually runs. No network access.
|
|
4
|
+
*
|
|
5
|
+
* Resolution order:
|
|
6
|
+
* 1. `--dir <path>` argument or `HEROUI_STYLES_DIR` environment variable
|
|
7
|
+
* 2. `@heroui/styles` resolved from the current working directory
|
|
8
|
+
* 3. `@heroui/styles` resolved through `@heroui/react` (transitive install)
|
|
9
|
+
* 4. A `packages/styles` folder in a parent directory (HeroUI monorepo checkout)
|
|
10
|
+
*
|
|
11
|
+
* The published package keeps its CSS in `dist/`; a source checkout keeps it
|
|
12
|
+
* at the package root. Both layouts are supported (the package root wins when
|
|
13
|
+
* both exist, since `dist/` can be stale in a checkout).
|
|
14
|
+
*/
|
|
15
|
+
import fs from "node:fs";
|
|
16
|
+
import {createRequire} from "node:module";
|
|
17
|
+
import path from "node:path";
|
|
18
|
+
|
|
19
|
+
const hasCss = (dir) => fs.existsSync(path.join(dir, "components", "button.css"));
|
|
20
|
+
|
|
21
|
+
/** Returns the folder that holds `components/`, `themes/`, `base/`. */
|
|
22
|
+
const cssRootOf = (packageDir) => {
|
|
23
|
+
for (const candidate of [packageDir, path.join(packageDir, "dist")]) {
|
|
24
|
+
if (hasCss(candidate)) return candidate;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const resolvePackageDir = (specifier, fromDir) => {
|
|
31
|
+
try {
|
|
32
|
+
const require = createRequire(path.join(fromDir, "noop.js"));
|
|
33
|
+
|
|
34
|
+
return path.dirname(require.resolve(`${specifier}/package.json`));
|
|
35
|
+
} catch {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const readVersion = (cssRoot) => {
|
|
41
|
+
for (const dir of [cssRoot, path.dirname(cssRoot)]) {
|
|
42
|
+
try {
|
|
43
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
44
|
+
|
|
45
|
+
if (pkg.name === "@heroui/styles") return pkg.version;
|
|
46
|
+
} catch {
|
|
47
|
+
// keep looking
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return "unknown";
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Removes `--dir <path>` from an argv array and returns the remaining arguments
|
|
56
|
+
* together with the explicit directory, if one was given.
|
|
57
|
+
*/
|
|
58
|
+
export const takeDirArg = (argv) => {
|
|
59
|
+
const rest = [];
|
|
60
|
+
let dir = process.env.HEROUI_STYLES_DIR || null;
|
|
61
|
+
|
|
62
|
+
for (let i = 0; i < argv.length; i++) {
|
|
63
|
+
if (argv[i] === "--dir") {
|
|
64
|
+
dir = argv[++i] ?? null;
|
|
65
|
+
} else if (argv[i].startsWith("--dir=")) {
|
|
66
|
+
dir = argv[i].slice("--dir=".length);
|
|
67
|
+
} else {
|
|
68
|
+
rest.push(argv[i]);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {dir, rest};
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const findStylesDir = (explicitDir) => {
|
|
76
|
+
const cwd = process.cwd();
|
|
77
|
+
|
|
78
|
+
if (explicitDir) {
|
|
79
|
+
const cssRoot = cssRootOf(path.resolve(cwd, explicitDir));
|
|
80
|
+
|
|
81
|
+
if (!cssRoot) {
|
|
82
|
+
throw new Error(`No HeroUI CSS found in "${explicitDir}" (expected components/button.css).`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {cssRoot, version: readVersion(cssRoot)};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const packageDirs = [resolvePackageDir("@heroui/styles", cwd)];
|
|
89
|
+
const reactDir = resolvePackageDir("@heroui/react", cwd);
|
|
90
|
+
|
|
91
|
+
if (reactDir) packageDirs.push(resolvePackageDir("@heroui/styles", reactDir));
|
|
92
|
+
|
|
93
|
+
for (let dir = cwd; ; dir = path.dirname(dir)) {
|
|
94
|
+
packageDirs.push(path.join(dir, "node_modules", "@heroui", "styles"));
|
|
95
|
+
packageDirs.push(path.join(dir, "packages", "styles"));
|
|
96
|
+
if (dir === path.dirname(dir)) break;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
for (const packageDir of packageDirs) {
|
|
100
|
+
const cssRoot = packageDir && cssRootOf(packageDir);
|
|
101
|
+
|
|
102
|
+
if (cssRoot) return {cssRoot, version: readVersion(cssRoot)};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
throw new Error(
|
|
106
|
+
"Could not find an installed @heroui/styles. Run this from the project root " +
|
|
107
|
+
"(after installing dependencies), or pass --dir <path-to-@heroui/styles>.",
|
|
108
|
+
);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/** Strips block comments so selectors and declarations can be scanned safely. */
|
|
112
|
+
export const stripComments = (css) => css.replace(/\/\*[\s\S]*?\*\//g, "");
|