@skriv/ads 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/bin/ads.mjs +1 -1
- package/dist/manifest.json +22 -5
- package/dist/skills/ads-init/SKILL.md +2 -0
- package/dist/skills/ads-init/profile.md +1 -1
- 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/routing.md +2 -0
- package/dist/templates/theming.md +26 -0
- package/package.json +21 -6
- package/src/install.mjs +3 -2
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Using HeroUI Styles Without React
|
|
2
|
+
|
|
3
|
+
`@heroui/styles` has no React dependency. It ships plain CSS (theme tokens + BEM component classes) and framework-agnostic variant functions. Any markup that carries the right classes and state attributes gets HeroUI's look: plain HTML, Vue, Svelte, Angular, Astro, server templates, web components.
|
|
4
|
+
|
|
5
|
+
**What you get:** the visual design, including hover, pressed, focus-visible, disabled, and selected styles.
|
|
6
|
+
**What you do not get:** behavior. Keyboard navigation, focus management, ARIA wiring, overlay positioning, and enter/exit state come from React Aria in `@heroui/react`. On other stacks you provide them (native elements first, then a headless library).
|
|
7
|
+
|
|
8
|
+
## Three ways to load the CSS
|
|
9
|
+
|
|
10
|
+
| Setup | How | Tailwind utilities | `@apply` in your CSS |
|
|
11
|
+
| --------------------- | ---------------------------------------------------------------------------------------------------- | ------------------ | -------------------- |
|
|
12
|
+
| Tailwind CSS v4 build | `@import "tailwindcss"; @import "@heroui/styles";` in the main CSS file | Yes | Yes |
|
|
13
|
+
| Prebuilt file | Link `node_modules/@heroui/styles/dist/heroui.min.css` (copy it to your static assets) | No | No |
|
|
14
|
+
| CDN | `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@heroui/styles@3/dist/heroui.min.css" />` | No | No |
|
|
15
|
+
|
|
16
|
+
Notes:
|
|
17
|
+
|
|
18
|
+
- Pin the CDN version in production (`@heroui/styles@3.2.7`), since component markup and CSS must match.
|
|
19
|
+
- `dist/heroui.min.css` is not in the package's `exports` map. Bundlers that enforce `exports` reject `import "@heroui/styles/dist/heroui.min.css"`; copy or link the file by path instead.
|
|
20
|
+
- The prebuilt file contains HeroUI's component classes, theme tokens, and Tailwind's base reset (preflight: margins, borders, and heading sizes are reset page-wide). It does **not** contain Tailwind utilities, so `class="flex gap-4 bg-background"` does nothing there. Write layout CSS yourself or use the Tailwind build.
|
|
21
|
+
|
|
22
|
+
### Selective imports (Tailwind build)
|
|
23
|
+
|
|
24
|
+
Import only what a page needs. Use explicit file paths; directory specifiers such as `@heroui/styles/components` are not exported.
|
|
25
|
+
|
|
26
|
+
```css
|
|
27
|
+
@layer theme, base, components, utilities;
|
|
28
|
+
|
|
29
|
+
@import "tailwindcss";
|
|
30
|
+
@import "@heroui/styles/base" layer(base);
|
|
31
|
+
@import "@heroui/styles/themes/default" layer(theme);
|
|
32
|
+
@import "@heroui/styles/utilities";
|
|
33
|
+
@import "@heroui/styles/variants";
|
|
34
|
+
|
|
35
|
+
@import "@heroui/styles/components/button.css" layer(components);
|
|
36
|
+
@import "@heroui/styles/components/card.css" layer(components);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`utilities` is required: component CSS applies `status-focused`, `status-disabled`, `no-highlight`, and others from it. `themes/default` brings both the token values and the Tailwind mapping. Shared primitives (`label.css`, `description.css`, `field-error.css`, `close-button.css`) go before the components that restyle them; `components/index.css` shows the full order.
|
|
40
|
+
|
|
41
|
+
## Minimal working example (no build step)
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<!doctype html>
|
|
45
|
+
<html lang="en" data-theme="light">
|
|
46
|
+
<head>
|
|
47
|
+
<meta charset="utf-8" />
|
|
48
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
49
|
+
<title>HeroUI without React</title>
|
|
50
|
+
<link
|
|
51
|
+
rel="stylesheet"
|
|
52
|
+
href="https://cdn.jsdelivr.net/npm/@heroui/styles@3/dist/heroui.min.css"
|
|
53
|
+
/>
|
|
54
|
+
<style>
|
|
55
|
+
/* The prebuilt file has no utilities: paint the canvas with tokens */
|
|
56
|
+
body {
|
|
57
|
+
background: var(--background);
|
|
58
|
+
color: var(--foreground);
|
|
59
|
+
font-family: var(--font-sans);
|
|
60
|
+
padding: 2rem;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.stack {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-wrap: wrap;
|
|
66
|
+
align-items: center;
|
|
67
|
+
gap: 1rem;
|
|
68
|
+
margin-bottom: 1.5rem;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Global customization works exactly as with React */
|
|
72
|
+
@layer theme {
|
|
73
|
+
:root {
|
|
74
|
+
--accent: oklch(0.55 0.2 300);
|
|
75
|
+
--radius: 0.375rem;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@layer components {
|
|
80
|
+
.button {
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
</head>
|
|
86
|
+
<body>
|
|
87
|
+
<div class="stack">
|
|
88
|
+
<button class="button button--primary">Save</button>
|
|
89
|
+
<button class="button button--secondary">Cancel</button>
|
|
90
|
+
<button class="button button--outline button--sm">Small outline</button>
|
|
91
|
+
<button class="button button--danger" disabled>Disabled</button>
|
|
92
|
+
<span class="chip chip--accent chip--soft"><span class="chip__label">New</span></span>
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<div class="stack">
|
|
96
|
+
<div class="card card--default" style="width: 20rem">
|
|
97
|
+
<div class="card__header">
|
|
98
|
+
<h3 class="card__title">Notifications</h3>
|
|
99
|
+
<p class="card__description">Choose what you want to hear about.</p>
|
|
100
|
+
</div>
|
|
101
|
+
<div class="card__content">
|
|
102
|
+
<input class="input input--full-width" type="email" placeholder="you@example.com" />
|
|
103
|
+
</div>
|
|
104
|
+
<div class="card__footer">
|
|
105
|
+
<button class="switch" role="switch" aria-checked="false" type="button">
|
|
106
|
+
<span class="switch__content">
|
|
107
|
+
<span class="switch__control"><span class="switch__thumb"></span></span>
|
|
108
|
+
Email me updates
|
|
109
|
+
</span>
|
|
110
|
+
</button>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<button class="button button--tertiary" id="mode" type="button">Toggle dark mode</button>
|
|
116
|
+
|
|
117
|
+
<script>
|
|
118
|
+
// State is yours to manage: HeroUI styles the ARIA / data attributes you set.
|
|
119
|
+
for (const el of document.querySelectorAll('[role="switch"]')) {
|
|
120
|
+
el.addEventListener("click", () => {
|
|
121
|
+
el.setAttribute("aria-checked", String(el.getAttribute("aria-checked") !== "true"));
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
document.getElementById("mode").addEventListener("click", () => {
|
|
126
|
+
const root = document.documentElement;
|
|
127
|
+
|
|
128
|
+
root.dataset.theme = root.dataset.theme === "dark" ? "light" : "dark";
|
|
129
|
+
});
|
|
130
|
+
</script>
|
|
131
|
+
</body>
|
|
132
|
+
</html>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## The markup contract
|
|
136
|
+
|
|
137
|
+
1. **Classes.** Root gets the block plus modifiers (`button button--primary button--lg`); parts get element classes (`card__header`). Look them up with `node scripts/list_component_classes.mjs <component>` or in [components.md](components.md).
|
|
138
|
+
2. **Native state is free.** `:hover`, `:active`, `:focus-visible`, `:disabled`, `:focus` on inputs all work on real `<button>`, `<a>`, `<input>` elements with no attributes.
|
|
139
|
+
3. **Non-native state is an attribute you set.** HeroUI's CSS reads the same attributes React Aria writes:
|
|
140
|
+
|
|
141
|
+
| State | Set on the block |
|
|
142
|
+
| --------------------------- | ----------------------------------------------------------------------------- |
|
|
143
|
+
| Selected / on | `aria-checked="true"` or `data-selected="true"` |
|
|
144
|
+
| Disabled (non-form element) | `aria-disabled="true"` or `data-disabled="true"` |
|
|
145
|
+
| Invalid | `data-invalid="true"` (fields also accept `aria-invalid="true"` where listed) |
|
|
146
|
+
| Loading | `data-pending="true"` |
|
|
147
|
+
| Overlay animation | `data-entering="true"` / `data-exiting="true"`, `data-placement="top | bottom | left | right"` |
|
|
148
|
+
|
|
149
|
+
4. **Structure matters for compound parts.** Selectors such as `.switch[aria-checked="true"] .switch__control` expect the documented nesting. Mirror the anatomy from the component docs (`https://heroui.com/docs/react/components/<name>.mdx`).
|
|
150
|
+
5. **Use real elements.** A `<button>` gets focus, keyboard activation, and `:disabled` for free; a `<div class="button">` gets none of it.
|
|
151
|
+
|
|
152
|
+
## Variant functions (any JS framework)
|
|
153
|
+
|
|
154
|
+
The JS entry exports the same `tailwind-variants` functions the React components use. They return class strings, so they work anywhere.
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
import {buttonVariants, cardVariants} from "@heroui/styles";
|
|
158
|
+
|
|
159
|
+
buttonVariants({variant: "primary"}); // "button button--md button--primary"
|
|
160
|
+
buttonVariants({variant: "secondary", size: "lg", isIconOnly: true});
|
|
161
|
+
|
|
162
|
+
// Compound components return one function per part
|
|
163
|
+
const card = cardVariants({variant: "secondary"});
|
|
164
|
+
|
|
165
|
+
card.base(); // "card card--secondary"
|
|
166
|
+
card.header(); // "card__header"
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```vue
|
|
170
|
+
<script setup lang="ts">
|
|
171
|
+
import {buttonVariants} from "@heroui/styles";
|
|
172
|
+
</script>
|
|
173
|
+
|
|
174
|
+
<template>
|
|
175
|
+
<button :class="buttonVariants({variant: 'primary'})">Save</button>
|
|
176
|
+
</template>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```svelte
|
|
180
|
+
<script lang="ts">
|
|
181
|
+
import {buttonVariants} from "@heroui/styles";
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<button class={buttonVariants({variant: "primary"})}>Save</button>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Theming in this mode
|
|
188
|
+
|
|
189
|
+
Everything in the skill applies unchanged — tokens, component custom properties, BEM overrides, named themes — because none of it depends on React.
|
|
190
|
+
|
|
191
|
+
- **Tailwind build:** follow [theme-recipe.md](theme-recipe.md) as written.
|
|
192
|
+
- **Prebuilt / CDN:** same files, plain CSS only. Replace `@apply` with declarations, and put the rules in the layers by hand:
|
|
193
|
+
|
|
194
|
+
```css
|
|
195
|
+
@layer theme {
|
|
196
|
+
[data-theme="brand-light"] {
|
|
197
|
+
color-scheme: light;
|
|
198
|
+
--accent: oklch(0.55 0.2 300);
|
|
199
|
+
--accent-foreground: var(--snow);
|
|
200
|
+
--radius: 0.25rem;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
[data-theme="brand-dark"] {
|
|
204
|
+
color-scheme: dark;
|
|
205
|
+
/* full dark palette: see theme-recipe.md, step 2 */
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
@layer components {
|
|
210
|
+
.button {
|
|
211
|
+
font-weight: 600;
|
|
212
|
+
letter-spacing: 0.02em;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Load this after `heroui.min.css`. The layer names already exist in the prebuilt file, so your rules join them in the right order.
|
|
218
|
+
|
|
219
|
+
Tokens that only `@heroui/react` reads (`--skeleton-animation`, `--tooltip-delay`, `--tooltip-close-delay`) have no effect without React.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# HeroUI Component CSS: Finding What to Override
|
|
2
|
+
|
|
3
|
+
Every HeroUI component is styled by one plain CSS file of BEM classes. This file explains how to read those files and what the conventions are, so an override targets selectors that really exist.
|
|
4
|
+
|
|
5
|
+
## Source of truth
|
|
6
|
+
|
|
7
|
+
Never guess a class name. Read it from the installed package:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
node scripts/list_component_classes.mjs # all component stylesheets
|
|
11
|
+
node scripts/list_component_classes.mjs button # blocks, elements, modifiers, states, custom properties, tokens
|
|
12
|
+
node scripts/list_component_classes.mjs modal --css # plus the raw CSS
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
| What | Where |
|
|
16
|
+
| ------------------------------ | ---------------------------------------------------------------------------------------- |
|
|
17
|
+
| Component CSS (installed) | `node_modules/@heroui/styles/dist/components/<name>.css` |
|
|
18
|
+
| Import order of all components | `node_modules/@heroui/styles/dist/components/index.css` |
|
|
19
|
+
| Class ↔ prop mapping | `node_modules/@heroui/styles/dist/components/<name>/<name>.styles.js` (variant function) |
|
|
20
|
+
| Human docs | `https://heroui.com/docs/react/components/<name>.mdx` → "CSS Classes" section |
|
|
21
|
+
| Latest source | `https://github.com/heroui-inc/heroui/tree/v3/packages/styles/components` |
|
|
22
|
+
|
|
23
|
+
`<name>` is kebab-case: `button`, `date-picker`, `list-box-item`, `alert-dialog`.
|
|
24
|
+
|
|
25
|
+
## Naming conventions
|
|
26
|
+
|
|
27
|
+
| Kind | Pattern | Example | Comes from |
|
|
28
|
+
| ---------------- | -------------------- | ---------------------------------------------- | ------------------------------------------------- |
|
|
29
|
+
| Block | `.name` | `.button`, `.card`, `.date-picker` | The component root |
|
|
30
|
+
| Element | `.name__part` | `.card__header`, `.switch__thumb` | A compound part (`<Card.Header>`) |
|
|
31
|
+
| Nested element | `.name__part__part` | `.tabs__list-container__scroll-next` | A part inside a part |
|
|
32
|
+
| Modifier | `.name--value` | `.button--primary`, `.button--lg` | A variant prop (`variant="primary"`, `size="lg"`) |
|
|
33
|
+
| Element modifier | `.name__part--value` | `.modal__dialog--lg`, `.modal__backdrop--blur` | A variant prop that styles one part |
|
|
34
|
+
| Boolean modifier | `.name--flag` | `.button--icon-only`, `.input--full-width` | A boolean prop (`isIconOnly`, `fullWidth`) |
|
|
35
|
+
| Compound | `.name--a.name--b` | `.chip--primary.chip--accent` | Two variant props combined (`variant` + `color`) |
|
|
36
|
+
|
|
37
|
+
Design rules the base CSS follows (keep them when you override):
|
|
38
|
+
|
|
39
|
+
- **Default size lives in the block.** `.button` already has the medium dimensions; `.button--md` is empty. Size modifiers only override.
|
|
40
|
+
- **Color variants only assign custom properties.** `.button--primary` sets `--button-bg`, `--button-bg-hover`, `--button-bg-pressed`, `--button-fg`; `.button` paints them. Prefer re-assigning those properties over re-declaring `background-color`.
|
|
41
|
+
- **Component custom properties are declared on the component class**, so setting `--button-bg` on `:root` does nothing. Set them on the block/modifier selector.
|
|
42
|
+
- **Colors come from theme tokens**, through utilities (`bg-surface`) or `var(--accent)`. Hardcoded colors are rare and usually deliberate (white switch thumb).
|
|
43
|
+
|
|
44
|
+
## State selectors
|
|
45
|
+
|
|
46
|
+
HeroUI styles each state twice: the native pseudo-class **and** the `data-*`/ARIA attribute that `@heroui/react` (React Aria) sets. Override both, or your style will apply on one platform and not the other.
|
|
47
|
+
|
|
48
|
+
| State | Pseudo-class | Attribute | Notes |
|
|
49
|
+
| -------------- | ---------------- | --------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
50
|
+
| Hover | `:hover` | `[data-hovered="true"]` | Wrapped in `@media (hover: hover)` |
|
|
51
|
+
| Pressed | `:active` | `[data-pressed="true"]` | |
|
|
52
|
+
| Keyboard focus | `:focus-visible` | `[data-focus-visible="true"]` | Base form: `&:focus-visible:not([data-focused]), &[data-focus-visible="true"]` |
|
|
53
|
+
| Field focus | `:focus` | `[data-focused="true"]` | Inputs show focus for pointer too |
|
|
54
|
+
| Focus within | `:focus-within` | `[data-focus-within="true"]` | Field groups |
|
|
55
|
+
| Disabled | `:disabled` | `[data-disabled="true"]`, `[aria-disabled="true"]` | |
|
|
56
|
+
| Selected / on | — | `[data-selected="true"]`, `[aria-checked="true"]`, `[aria-selected="true"]` | Switch, Checkbox, Radio, Tabs, ListBox |
|
|
57
|
+
| Invalid | — | `[data-invalid="true"]`, `[aria-invalid="true"]` | |
|
|
58
|
+
| Pending | — | `[data-pending="true"]` | Loading buttons |
|
|
59
|
+
| Open | — | `[data-open="true"]`, `[data-expanded="true"]` | Triggers, disclosures |
|
|
60
|
+
| Enter / exit | — | `[data-entering="true"]`, `[data-exiting="true"]` | Overlay animations |
|
|
61
|
+
| Placement | — | `[data-placement="top"]` (`bottom`, `left`, `right`) | Popover, Tooltip |
|
|
62
|
+
| Orientation | — | `[data-orientation="horizontal"]` / `"vertical"` | Tabs, Slider, RadioGroup, ListBox |
|
|
63
|
+
|
|
64
|
+
A parent's state often styles a child: `.switch[data-selected="true"] .switch__thumb`. The script prints the exact list per component.
|
|
65
|
+
|
|
66
|
+
The base file is the authority on the exact selector. Some rules add guards (`.tabs__tab:not([data-selected="true"]):not([data-disabled="true"]):hover`), and a few deliberately use one form only (the accordion trigger hover keys off `:hover` alone). Copy the base selector, then change the declarations.
|
|
67
|
+
|
|
68
|
+
### State utilities
|
|
69
|
+
|
|
70
|
+
Shared state styles come from `@heroui/styles/utilities`, applied with `@apply`:
|
|
71
|
+
|
|
72
|
+
| Utility | Does | Tokens |
|
|
73
|
+
| ---------------------- | ----------------------------------------------------- | ------------------------------------------------ |
|
|
74
|
+
| `status-focused` | 2px focus ring with an offset | `--focus`, `--ring-offset-width`, `--background` |
|
|
75
|
+
| `status-focused-field` | 2px focus ring with no offset | `--focus` |
|
|
76
|
+
| `status-invalid-field` | 1px danger outline; 2px danger ring when focused | `--danger` |
|
|
77
|
+
| `status-disabled` | Opacity, `not-allowed` cursor, `pointer-events: none` | `--disabled-opacity`, `--cursor-disabled` |
|
|
78
|
+
| `status-pending` | `pointer-events: none` | |
|
|
79
|
+
|
|
80
|
+
To restyle focus or disabled globally, change the tokens. Do not remove these rules.
|
|
81
|
+
|
|
82
|
+
### `data-slot` hooks
|
|
83
|
+
|
|
84
|
+
Parts that have no BEM class of their own are reached through `data-slot`: `[data-slot="overlay-arrow"]` inside `.tooltip`, `[data-slot="label"]` and `[data-slot="description"]` inside `.switch`, `[data-slot="spinner"]` inside `.button`.
|
|
85
|
+
|
|
86
|
+
## Writing an override that wins
|
|
87
|
+
|
|
88
|
+
All HeroUI component CSS is in `@layer components`. Put overrides in the same layer so they come later in source order and so utilities on an element (`className="rounded-none"`) still beat them:
|
|
89
|
+
|
|
90
|
+
```css
|
|
91
|
+
@layer components {
|
|
92
|
+
.card {
|
|
93
|
+
@apply rounded-lg;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
1. **Match the base selector's specificity.** Same layer + same specificity → the later rule (yours) wins. `.switch__thumb { … }` does not beat `.switch[data-selected="true"] .switch__thumb { … }`; repeat the stronger selector.
|
|
99
|
+
2. **Re-assert modifiers your block override clobbers.** A new `border` on `.card` also lands on `.card--transparent` (which the base sets to `border-none` earlier in the file). Add `.card--transparent { @apply border-none; }` after it.
|
|
100
|
+
3. **Keep the paired selectors.** Copy the selector list from the base file (`&:hover, &[data-hovered="true"]`), then change the declarations.
|
|
101
|
+
4. **Do not write raw `box-shadow` in a state rule of a focusable component.** The focus ring is a `box-shadow`. Use shadow utilities (`@apply shadow-[…]`), which set `--tw-shadow` and compose with the ring, or check that the ring still shows.
|
|
102
|
+
5. **Keep reduced motion.** If you add or replace a `transition`, follow it with `@apply motion-reduce:transition-none;` (after, not before).
|
|
103
|
+
6. **Do not put overrides outside a layer.** Unlayered CSS beats `utilities`, so per-instance `className` overrides would stop working.
|
|
104
|
+
7. **Check for pseudo-elements before adding one.** Several parts already draw with `::before` or `::after` (the checkbox control's fill, the radio indicator's dot, the slider thumb's knob). Grep the component's file first; a second `::before` rule replaces the first.
|
|
105
|
+
|
|
106
|
+
## Representative components
|
|
107
|
+
|
|
108
|
+
Listed from `@heroui/styles` 3.2.x. Re-run the script for your version.
|
|
109
|
+
|
|
110
|
+
### Button — `button.css`
|
|
111
|
+
|
|
112
|
+
| Kind | Selectors |
|
|
113
|
+
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
114
|
+
| Block | `.button` |
|
|
115
|
+
| Variants | `.button--primary`, `.button--secondary`, `.button--tertiary`, `.button--outline`, `.button--ghost`, `.button--danger`, `.button--danger-soft` |
|
|
116
|
+
| Sizes | `.button--sm`, `.button--md` (empty), `.button--lg` |
|
|
117
|
+
| Flags | `.button--icon-only`, `.button--full-width`; compound `.button--icon-only.button--sm` / `.button--lg` |
|
|
118
|
+
| States | `:hover` / `[data-hovered="true"]`, `:active` / `[data-pressed="true"]`, `:focus-visible:not([data-focused])` / `[data-focus-visible="true"]`, `:disabled` / `[aria-disabled="true"]`, `[data-pending="true"]` |
|
|
119
|
+
| Slots | `svg` (icons), `[data-slot="spinner"]`, `[data-slot="link-icon"]` |
|
|
120
|
+
|
|
121
|
+
| Custom property | Default | Painted as |
|
|
122
|
+
| --------------------- | ------------------------ | ------------------ |
|
|
123
|
+
| `--button-bg` | `transparent` | `background-color` |
|
|
124
|
+
| `--button-bg-hover` | `var(--button-bg)` | hover background |
|
|
125
|
+
| `--button-bg-pressed` | `var(--button-bg-hover)` | pressed background |
|
|
126
|
+
| `--button-fg` | `currentColor` | `color` |
|
|
127
|
+
|
|
128
|
+
Pressed also applies `transform: scale(0.97)` (`0.98` for `--sm`, `0.96` for `--lg`). Shape: `rounded-3xl`, height `h-10 md:h-9`.
|
|
129
|
+
|
|
130
|
+
### Card — `card.css`
|
|
131
|
+
|
|
132
|
+
| Kind | Selectors |
|
|
133
|
+
| -------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
|
134
|
+
| Block | `.card` (padding, gap, `shadow-surface`, radius `min(32px, var(--radius-3xl))`) |
|
|
135
|
+
| Elements | `.card__header`, `.card__title`, `.card__description`, `.card__content`, `.card__footer` |
|
|
136
|
+
| Variants | `.card--default` (`bg-surface`), `.card--secondary`, `.card--tertiary`, `.card--transparent` (no border, background, or shadow) |
|
|
137
|
+
|
|
138
|
+
No states and no custom properties: restyle through `--surface*`, `--surface-shadow`, `--radius`, or the block.
|
|
139
|
+
|
|
140
|
+
### Chip — `chip.css`
|
|
141
|
+
|
|
142
|
+
| Kind | Selectors |
|
|
143
|
+
| -------- | --------------------------------------------------------------------------------------------- |
|
|
144
|
+
| Block | `.chip`; element `.chip__label` |
|
|
145
|
+
| Colors | `.chip--default`, `.chip--accent`, `.chip--success`, `.chip--warning`, `.chip--danger` |
|
|
146
|
+
| Variants | `.chip--primary`, `.chip--secondary`, `.chip--soft`, `.chip--tertiary` |
|
|
147
|
+
| Sizes | `.chip--sm`, `.chip--md` (empty), `.chip--lg` |
|
|
148
|
+
| Compound | `.chip--primary.chip--accent` (solid), `.chip--accent.chip--soft` (soft) — one pair per color |
|
|
149
|
+
|
|
150
|
+
Custom properties: `--chip-bg` (default `var(--default)`), `--chip-fg` (default `currentColor`).
|
|
151
|
+
|
|
152
|
+
### Switch — `switch.css`
|
|
153
|
+
|
|
154
|
+
| Kind | Selectors |
|
|
155
|
+
| -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
156
|
+
| Block | `.switch` (the label wrapper; carries the state attributes) |
|
|
157
|
+
| Elements | `.switch__content`, `.switch__control` (track), `.switch__thumb` |
|
|
158
|
+
| Sizes | `.switch--sm`, `.switch--md` (empty), `.switch--lg` |
|
|
159
|
+
| States | On the block: `[data-selected="true"]` / `[aria-checked="true"]`, `[data-disabled="true"]`, `:hover` / `[data-hovered="true"]`, `:active` / `[data-pressed="true"]`, `:focus-visible` / `[data-focus-visible="true"]` — styled on the children, e.g. `.switch[data-selected="true"] .switch__control` |
|
|
160
|
+
| Slots | `[data-slot="switch-content"]`, `[data-slot="label"]`, `[data-slot="description"]`, `[data-slot="field-error"]` |
|
|
161
|
+
|
|
162
|
+
| Custom property (on `.switch`) | Default |
|
|
163
|
+
| ----------------------------------- | ---------------------------------------------------------------- |
|
|
164
|
+
| `--switch-control-bg` | `var(--default)` |
|
|
165
|
+
| `--switch-control-bg-hover` | `color-mix(in oklab, var(--switch-control-bg), transparent 20%)` |
|
|
166
|
+
| `--switch-control-bg-pressed` | `var(--switch-control-bg-hover)` |
|
|
167
|
+
| `--switch-control-bg-checked` | `var(--accent)` |
|
|
168
|
+
| `--switch-control-bg-checked-hover` | `var(--accent-hover)` |
|
|
169
|
+
|
|
170
|
+
The thumb is positioned with `--switch-thumb-offset`; the track has `overflow-hidden`, so borders on the track change the thumb's travel (draw outlines with shadows instead).
|
|
171
|
+
|
|
172
|
+
### Input — `input.css`
|
|
173
|
+
|
|
174
|
+
| Kind | Selectors |
|
|
175
|
+
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| Block | `.input` |
|
|
177
|
+
| Variants | `.input--primary` (empty, default), `.input--secondary` (filled with `--default`, no shadow) |
|
|
178
|
+
| Flags | `.input--full-width` |
|
|
179
|
+
| States | `:hover` / `[data-hovered="true"]` (only while not focused), `:focus` / `[data-focused="true"]`, `[data-invalid="true"]`, `:disabled` / `[data-disabled="true"]` / `[aria-disabled="true"]`, `:autofill` |
|
|
180
|
+
|
|
181
|
+
Custom properties: `--input-bg` (current fill, default `var(--color-field)`), `--input-bg-hover`, `--input-bg-focus`. Everything else is a field token (`--field-background`, `--field-border`, `--field-border-width`, `--field-radius`, `--field-shadow`, `--field-placeholder`), which also drive `.textarea`, `.input-group`, `.number-field__group`, `.search-field__group`, `.date-input-group`, `.select__trigger`, `.autocomplete__trigger`, `.input-otp__slot`. Prefer the tokens: one change covers every field.
|
|
182
|
+
|
|
183
|
+
## Which class is the overlay surface
|
|
184
|
+
|
|
185
|
+
Overlays have wrappers for positioning and animation; the visible panel is one specific class.
|
|
186
|
+
|
|
187
|
+
| Component | Panel (background, radius, `--overlay-shadow`) | Other parts |
|
|
188
|
+
| -------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
|
189
|
+
| Popover | `.popover` | `.popover__dialog`, `.popover__heading` |
|
|
190
|
+
| Tooltip | `.tooltip` | arrow: `[data-slot="overlay-arrow"]` |
|
|
191
|
+
| Dropdown | `.dropdown__popover` | `.dropdown__menu`, items: `.menu-item` |
|
|
192
|
+
| Select / ComboBox / Autocomplete | `.select__popover`, `.combo-box__popover`, `.autocomplete__popover` | items: `.list-box-item` |
|
|
193
|
+
| DatePicker / DateRangePicker | `.date-picker__popover`, `.date-range-picker__popover` | `.calendar`, `.range-calendar` |
|
|
194
|
+
| ColorPicker | `.color-picker__popover` | |
|
|
195
|
+
| Modal | `.modal__dialog` | `.modal__backdrop`, `.modal__container`, `.modal__header`, `.modal__body`, `.modal__footer` |
|
|
196
|
+
| AlertDialog | `.alert-dialog__dialog` | `.alert-dialog__backdrop`, `.alert-dialog__container` |
|
|
197
|
+
| Drawer / Sheet | `.drawer__dialog`, `.sheet__dialog` | `.drawer__backdrop`, `.sheet__backdrop` |
|
|
198
|
+
| Toast | `.toast` | `.toast__title`, `.toast__description` |
|
|
199
|
+
|
|
200
|
+
To restyle all of them at once, change `--overlay`, `--overlay-shadow`, `--backdrop`, and `--radius`. Overlays render in a portal on `<body>`, so they only inherit a theme applied on `<html>`.
|
|
201
|
+
|
|
202
|
+
## Components with color custom properties
|
|
203
|
+
|
|
204
|
+
Re-assign these on the block or modifier instead of re-declaring colors.
|
|
205
|
+
|
|
206
|
+
| Component | Custom properties |
|
|
207
|
+
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
208
|
+
| Button | `--button-bg`, `--button-bg-hover`, `--button-bg-pressed`, `--button-fg` |
|
|
209
|
+
| ToggleButton | `--toggle-button-bg` (+ `-hover`, `-pressed`), `--toggle-button-fg`, `--toggle-button-bg-selected` (+ `-hover`, `-pressed`), `--toggle-button-fg-selected` |
|
|
210
|
+
| Chip | `--chip-bg`, `--chip-fg` |
|
|
211
|
+
| Badge | `--badge-bg`, `--badge-fg`, `--badge-border` |
|
|
212
|
+
| Switch | `--switch-control-bg` (+ `-hover`, `-pressed`, `-checked`, `-checked-hover`) |
|
|
213
|
+
| Pagination | `--pagination-link-bg` (+ `-hover`, `-pressed`), `--pagination-link-fg` |
|
|
214
|
+
| Input, TextArea | `--input-bg`, `--textarea-bg` (+ `-hover`, `-focus`) |
|
|
215
|
+
| Field groups | `--input-group-bg`, `--number-field-group-bg`, `--search-field-group-bg`, `--date-input-group-bg`, `--color-input-group-bg`, `--select-trigger-bg`, `--autocomplete-trigger-bg`, `--input-otp-slot-bg` (+ `-hover`, `-focus`) |
|
|
216
|
+
| Meter, ProgressBar | `--meter-fill`, `--progress-bar-fill` |
|
|
217
|
+
| ProgressCircle | `--progress-circle-stroke`, `--progress-circle-track-stroke` |
|
|
218
|
+
| Avatar | `--avatar-size`, `--avatar-radius` |
|
|
219
|
+
|
|
220
|
+
Components not listed read theme tokens directly.
|
|
221
|
+
|
|
222
|
+
## Adding a variant
|
|
223
|
+
|
|
224
|
+
A new modifier is just another class in `@layer components`. Reuse the component's custom properties so hover, pressed, focus, and disabled keep working. Assign all of them: the component's default variant modifier (`.button--primary`) is still on the element.
|
|
225
|
+
|
|
226
|
+
```css
|
|
227
|
+
@layer components {
|
|
228
|
+
.button--brand {
|
|
229
|
+
--button-bg: var(--success);
|
|
230
|
+
--button-bg-hover: var(--success-hover);
|
|
231
|
+
--button-bg-pressed: var(--success-hover);
|
|
232
|
+
--button-fg: var(--success-foreground);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Use it with `className` (the block class is added by the component): `<Button className="button--brand">` or, on plain HTML, `<button class="button button--brand">`. For a typed prop, extend the variant function: `tv({extend: buttonVariants, variants: {variant: {brand: "button--brand"}}})` (see the Styling guide: `https://heroui.com/docs/react/getting-started/styling.mdx`).
|