@greenharness/greenrack-cli 0.0.0-stage → 7.0.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 +335 -2
- package/agents/design-system-lookup.md +59 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +145 -0
- package/dist/bin.js.map +1 -0
- package/dist/catalog.d.ts +13 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +67 -0
- package/dist/catalog.js.map +1 -0
- package/dist/commands/context.d.ts +17 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +110 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/doctor.d.ts +75 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +1008 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/hook.d.ts +10 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +323 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/list.d.ts +4 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +59 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/lookup.d.ts +13 -0
- package/dist/commands/lookup.d.ts.map +1 -0
- package/dist/commands/lookup.js +66 -0
- package/dist/commands/lookup.js.map +1 -0
- package/dist/commands/manifest.d.ts +5 -0
- package/dist/commands/manifest.d.ts.map +1 -0
- package/dist/commands/manifest.js +33 -0
- package/dist/commands/manifest.js.map +1 -0
- package/dist/commands/mcp.d.ts +159 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +235 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/mockup.d.ts +80 -0
- package/dist/commands/mockup.d.ts.map +1 -0
- package/dist/commands/mockup.js +714 -0
- package/dist/commands/mockup.js.map +1 -0
- package/dist/commands/skill.d.ts +15 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +398 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/disambiguation.d.ts +24 -0
- package/dist/disambiguation.d.ts.map +1 -0
- package/dist/disambiguation.js +56 -0
- package/dist/disambiguation.js.map +1 -0
- package/dist/extension-pointer.d.ts +7 -0
- package/dist/extension-pointer.d.ts.map +1 -0
- package/dist/extension-pointer.js +30 -0
- package/dist/extension-pointer.js.map +1 -0
- package/dist/format.d.ts +19 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +213 -0
- package/dist/format.js.map +1 -0
- package/dist/hook-script.d.ts +73 -0
- package/dist/hook-script.d.ts.map +1 -0
- package/dist/hook-script.js +165 -0
- package/dist/hook-script.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/legacy-names.d.ts +26 -0
- package/dist/legacy-names.d.ts.map +1 -0
- package/dist/legacy-names.js +26 -0
- package/dist/legacy-names.js.map +1 -0
- package/dist/manifest.d.ts +51 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +229 -0
- package/dist/manifest.js.map +1 -0
- package/dist/registry-types.d.ts +106 -0
- package/dist/registry-types.d.ts.map +1 -0
- package/dist/registry-types.js +2 -0
- package/dist/registry-types.js.map +1 -0
- package/dist/registry.d.ts +52 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +95 -0
- package/dist/registry.js.map +1 -0
- package/dist/scan.d.ts +19 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +29 -0
- package/dist/scan.js.map +1 -0
- package/dist/search.d.ts +16 -0
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +75 -0
- package/dist/search.js.map +1 -0
- package/dist/skill-template.d.ts +24 -0
- package/dist/skill-template.d.ts.map +1 -0
- package/dist/skill-template.js +140 -0
- package/dist/skill-template.js.map +1 -0
- package/greenharness.toml +38 -0
- package/package.json +76 -3
- package/registry.json +12893 -0
- package/skills/colors/LICENSE +21 -0
- package/skills/colors/NOTICE.md +36 -0
- package/skills/colors/SKILL.md +101 -0
- package/skills/colors/color-formats.md +90 -0
- package/skills/colors/color-usage.md +109 -0
- package/skills/colors/contrast.md +70 -0
- package/skills/colors/palette-generation.md +108 -0
- package/skills/colors/palette-structure.md +72 -0
- package/skills/colors/token-naming.md +99 -0
- package/skills/greenrack-mockup/SKILL.md +115 -0
- package/skills/typography/LICENSE +21 -0
- package/skills/typography/NOTICE.md +36 -0
- package/skills/typography/SKILL.md +171 -0
- package/skills/typography/choosing-fonts.md +53 -0
- package/skills/typography/css-cheat-sheet.md +67 -0
- package/skills/typography/details-and-accessibility.md +84 -0
- package/skills/typography/spacing-and-sizing.md +87 -0
- package/skills/typography/variable-fonts-and-opentype.md +100 -0
- package/skills/typography/wrapping-and-punctuation.md +23 -0
- package/skills/ui/LICENSE +21 -0
- package/skills/ui/NOTICE.md +38 -0
- package/skills/ui/SKILL.md +141 -0
- package/skills/ui/animations.md +170 -0
- package/skills/ui/enter-exit.md +157 -0
- package/skills/ui/icon-transitions.md +72 -0
- package/skills/ui/icons.md +105 -0
- package/skills/ui/performance.md +63 -0
- package/skills/ui/surfaces.md +166 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Enter and exit animations
|
|
2
|
+
|
|
3
|
+
Recipes for staged entrances and the exits that follow them. For interactive state feedback see [animations.md](animations.md), and for icon swaps see [icon-transitions.md](icon-transitions.md).
|
|
4
|
+
|
|
5
|
+
## Enter animations
|
|
6
|
+
|
|
7
|
+
1. **Split** into semantic groups such as title, description and actions.
|
|
8
|
+
2. **Stagger** the groups `100ms` apart.
|
|
9
|
+
3. **Split a short display headline** into words, staggered `80ms` apart, where it should read word by word.
|
|
10
|
+
4. **Combine** `opacity`, `blur` and `translateY` for each group's enter.
|
|
11
|
+
|
|
12
|
+
### Motion
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
const item = {
|
|
16
|
+
hidden: { opacity: 0, y: 12, filter: "blur(4px)" },
|
|
17
|
+
visible: {
|
|
18
|
+
opacity: 1,
|
|
19
|
+
y: 0,
|
|
20
|
+
filter: "blur(0px)",
|
|
21
|
+
transition: { duration: 0.3, ease: "easeOut" },
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function PageHeader() {
|
|
26
|
+
return (
|
|
27
|
+
<motion.div
|
|
28
|
+
initial="hidden"
|
|
29
|
+
animate="visible"
|
|
30
|
+
variants={{ visible: { transition: { staggerChildren: 0.1 } } }}
|
|
31
|
+
>
|
|
32
|
+
<motion.h1 variants={item}>Welcome</motion.h1>
|
|
33
|
+
<motion.p variants={item}>A description of the page.</motion.p>
|
|
34
|
+
<motion.div variants={item}>
|
|
35
|
+
<Button>Get started</Button>
|
|
36
|
+
</motion.div>
|
|
37
|
+
</motion.div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### CSS
|
|
43
|
+
|
|
44
|
+
The hidden state lives in the `from` keyframe, so an item whose animation never runs stays visible. Reduced motion keeps only the opacity keyframe.
|
|
45
|
+
|
|
46
|
+
```css
|
|
47
|
+
.stagger-item {
|
|
48
|
+
animation: fade-in 300ms ease-out both;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
52
|
+
.stagger-item {
|
|
53
|
+
animation-name: fade-in-up;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.stagger-item:nth-child(2) { animation-delay: 100ms; }
|
|
58
|
+
.stagger-item:nth-child(3) { animation-delay: 200ms; }
|
|
59
|
+
|
|
60
|
+
@keyframes fade-in {
|
|
61
|
+
from { opacity: 0; }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@keyframes fade-in-up {
|
|
65
|
+
from {
|
|
66
|
+
opacity: 0;
|
|
67
|
+
transform: translateY(12px);
|
|
68
|
+
filter: blur(4px);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Entering from display: none
|
|
74
|
+
|
|
75
|
+
A popover, dialog or element toggled from `display: none` has no previous style to transition from. `@starting-style` supplies one, and `transition-behavior: allow-discrete` keeps it rendered through the exit. The open state's duration applies on enter and the closed state's on exit.
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
[popover] {
|
|
79
|
+
opacity: 0;
|
|
80
|
+
translate: 0 12px;
|
|
81
|
+
transition-property: opacity, translate, display, overlay;
|
|
82
|
+
transition-duration: 150ms;
|
|
83
|
+
transition-timing-function: ease-out;
|
|
84
|
+
transition-behavior: allow-discrete;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
[popover]:popover-open {
|
|
88
|
+
opacity: 1;
|
|
89
|
+
translate: 0 0;
|
|
90
|
+
transition-duration: 300ms;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@starting-style {
|
|
94
|
+
[popover]:popover-open {
|
|
95
|
+
opacity: 0;
|
|
96
|
+
translate: 0 12px;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`@starting-style` and discrete `display` transitions are Baseline 2024. `overlay` is Chromium only, and browsers without support show and hide instantly.
|
|
102
|
+
|
|
103
|
+
## Exit animations
|
|
104
|
+
|
|
105
|
+
### Subtle exit
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<motion.div
|
|
109
|
+
exit={{
|
|
110
|
+
opacity: 0,
|
|
111
|
+
y: -12,
|
|
112
|
+
filter: "blur(4px)",
|
|
113
|
+
transition: { duration: 0.15, ease: "easeOut" },
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
{content}
|
|
117
|
+
</motion.div>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Full exit
|
|
121
|
+
|
|
122
|
+
Slide fully out only where the destination carries meaning, such as a card returning to a list or a drawer closing:
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
<motion.div
|
|
126
|
+
exit={{
|
|
127
|
+
opacity: 0,
|
|
128
|
+
x: "-100%",
|
|
129
|
+
transition: { duration: 0.2, ease: "easeOut" },
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{content}
|
|
133
|
+
</motion.div>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Good and bad
|
|
137
|
+
|
|
138
|
+
```css
|
|
139
|
+
/* Good: subtle exit */
|
|
140
|
+
.item-exit {
|
|
141
|
+
opacity: 0;
|
|
142
|
+
transform: translateY(-12px);
|
|
143
|
+
transition: opacity 150ms ease-out, transform 150ms ease-out;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* Bad: dramatic exit that steals focus */
|
|
147
|
+
.item-exit {
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transform: translateY(-100%) scale(0.5);
|
|
150
|
+
transition: all 400ms ease-out;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/* Sometimes correct: remove at once when motion adds no information */
|
|
154
|
+
.item-exit {
|
|
155
|
+
display: none;
|
|
156
|
+
}
|
|
157
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Icon transitions
|
|
2
|
+
|
|
3
|
+
Cross-fade recipes for an icon that swaps on a state change, with and without a motion library. Icon weight, color and direction live in [icons.md](icons.md).
|
|
4
|
+
|
|
5
|
+
## Which library
|
|
6
|
+
|
|
7
|
+
Check the project's `package.json`. Import from `"motion/react"` when `motion` is installed, or `"framer-motion"` when that is. Where both exist, follow the imports the component or its nearest peers already use. Where neither is present, use the CSS cross-fade and never add a dependency just for icon transitions.
|
|
8
|
+
|
|
9
|
+
## Motion
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { AnimatePresence, motion } from "motion/react";
|
|
13
|
+
|
|
14
|
+
function IconButton({ isActive, icon: Icon }) {
|
|
15
|
+
return (
|
|
16
|
+
<button>
|
|
17
|
+
<AnimatePresence initial={false} mode="popLayout">
|
|
18
|
+
<motion.span
|
|
19
|
+
key={isActive ? "active" : "inactive"}
|
|
20
|
+
initial={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
21
|
+
animate={{ opacity: 1, scale: 1, filter: "blur(0px)" }}
|
|
22
|
+
exit={{ opacity: 0, scale: 0.25, filter: "blur(4px)" }}
|
|
23
|
+
transition={{ type: "spring", duration: 0.3, bounce: 0 }}
|
|
24
|
+
>
|
|
25
|
+
<Icon />
|
|
26
|
+
</motion.span>
|
|
27
|
+
</AnimatePresence>
|
|
28
|
+
</button>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`initial={false}` keeps the default icon from animating in on mount.
|
|
34
|
+
|
|
35
|
+
## CSS, both icons in the DOM
|
|
36
|
+
|
|
37
|
+
Both icons stay mounted in one grid cell, so enter and exit both animate and the larger icon sets the size. The `motion-reduce:` classes leave only the opacity fade under reduced motion.
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
const layer = cn(
|
|
41
|
+
"[grid-area:1/1] transition-[opacity,filter,scale] duration-300",
|
|
42
|
+
"ease-[cubic-bezier(0.2,0,0,1)]",
|
|
43
|
+
"motion-reduce:scale-100 motion-reduce:blur-[0px]"
|
|
44
|
+
);
|
|
45
|
+
const shown = "scale-100 opacity-100 blur-[0px]";
|
|
46
|
+
const hidden = "scale-[0.25] opacity-0 blur-[4px]";
|
|
47
|
+
|
|
48
|
+
function IconButton({ isActive, ActiveIcon, InactiveIcon }) {
|
|
49
|
+
return (
|
|
50
|
+
<button>
|
|
51
|
+
<span className="grid place-items-center">
|
|
52
|
+
<span className={cn(layer, isActive ? shown : hidden)}>
|
|
53
|
+
<ActiveIcon />
|
|
54
|
+
</span>
|
|
55
|
+
<span className={cn(layer, isActive ? hidden : shown)}>
|
|
56
|
+
<InactiveIcon />
|
|
57
|
+
</span>
|
|
58
|
+
</span>
|
|
59
|
+
</button>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Tailwind 4's `scale-*` utilities write the `scale` property, so `transition-[...scale]` animates them. Tailwind 3's write `transform`, so name `transform` in the transition instead.
|
|
65
|
+
|
|
66
|
+
## Which icons animate
|
|
67
|
+
|
|
68
|
+
| Animate | Don't animate |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| Infrequent state swaps such as play to pause, like to liked or copy to copied | Hover-revealed actions in list rows |
|
|
71
|
+
| Icons in a toolbar that appears on selection | Tab and navigation icon swaps |
|
|
72
|
+
| Loading and success indicators | Decorative or always-visible icons |
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Icons
|
|
2
|
+
|
|
3
|
+
Icon stroke weight, sizing, state colors, variants and RTL mirroring.
|
|
4
|
+
|
|
5
|
+
## Match icon stroke to text weight
|
|
6
|
+
|
|
7
|
+
| Adjacent text | Rendered stroke width |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| Regular (400), 14–16px | `1.5px` |
|
|
10
|
+
| Medium or semibold (500–600) | `2px` |
|
|
11
|
+
| Bold (700), or an emphasized standalone icon | `2.5px` |
|
|
12
|
+
|
|
13
|
+
The widths are rendered pixels. A 24px-grid icon drawn at 16px scales its stroke by 16/24, so `stroke-width="2"` paints about `1.33px`. Use the library's absolute-stroke option, such as Lucide's `absoluteStrokeWidth`, or set `vector-effect: non-scaling-stroke` on the SVG's shapes.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
// Good: stroke tuned to the semibold label
|
|
17
|
+
<button className="flex items-center gap-2 font-semibold">
|
|
18
|
+
<Plus size={16} strokeWidth={2} absoluteStrokeWidth />
|
|
19
|
+
New project
|
|
20
|
+
</button>
|
|
21
|
+
|
|
22
|
+
// Bad: 1.5px stroke against a bold label
|
|
23
|
+
<button className="flex items-center gap-2 font-bold">
|
|
24
|
+
<Plus size={16} strokeWidth={1.5} absoluteStrokeWidth />
|
|
25
|
+
New project
|
|
26
|
+
</button>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
- **One library per surface.** Never mix icon libraries on one toolbar. Where the library has no stroke variants, keep its native stroke and use size or color for emphasis.
|
|
30
|
+
- **Size inline icons at `1em`–`1.25em`** of the adjacent font size, so the pair scales together.
|
|
31
|
+
|
|
32
|
+
## One SVG, recolored per state
|
|
33
|
+
|
|
34
|
+
Draw every icon with `currentColor` and let CSS state drive the color. Strip hardcoded fills such as `fill="#666"` to `currentColor` when importing icons.
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<svg fill="none" stroke="currentColor" stroke-width="2">…</svg>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```css
|
|
41
|
+
/* Use the project's color tokens */
|
|
42
|
+
.icon-button { color: var(--icon-muted); }
|
|
43
|
+
.icon-button:hover { color: var(--icon-strong); }
|
|
44
|
+
.icon-button[aria-pressed="true"] { color: var(--icon-active); }
|
|
45
|
+
.icon-button:disabled { opacity: 0.4; }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```html
|
|
49
|
+
<!-- Tailwind, with the project's token names -->
|
|
50
|
+
<button class="text-icon-muted hover:text-icon-strong aria-pressed:text-icon-active disabled:opacity-40">
|
|
51
|
+
<BookmarkIcon />
|
|
52
|
+
</button>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Outline default, fill active
|
|
56
|
+
|
|
57
|
+
Where an icon set offers outline and filled variants, use them as a state pair, never interchangeably:
|
|
58
|
+
|
|
59
|
+
| Variant | Use for |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| Outline | Default state in toolbars, list rows and inline text |
|
|
62
|
+
| Fill | Selected or active state, such as the active tab, a toggled bookmark or a liked heart |
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
// Good: variant communicates state
|
|
66
|
+
<TabIcon variant={isActive ? "solid" : "outline"} />
|
|
67
|
+
|
|
68
|
+
// Bad: filled everywhere, so the active tab has no state signal
|
|
69
|
+
<TabIcon variant="solid" />
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Cross-fade the swap with the values in [icon-transitions.md](icon-transitions.md) only where the change is infrequent, such as a bookmark or a like. An active tab swaps instantly.
|
|
73
|
+
|
|
74
|
+
## Design at render size
|
|
75
|
+
|
|
76
|
+
- Test every icon at the smallest size it renders, often `16px`. It must stay recognizable there.
|
|
77
|
+
- Prefer a simplified glyph for small contexts over scaling down detailed artwork.
|
|
78
|
+
- Where the set ships per-size grids such as `16`, `20` and `24`, use the grid that matches the render size. A 24px drawing scaled to 16px lands off the pixel grid and renders soft.
|
|
79
|
+
- Always SVG, never raster.
|
|
80
|
+
|
|
81
|
+
## Icons in RTL
|
|
82
|
+
|
|
83
|
+
Under `dir="rtl"`, flip icons whose meaning is tied to reading direction, and leave the rest alone:
|
|
84
|
+
|
|
85
|
+
| Flip | Don't flip |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| Back and forward arrows, navigation chevrons | Logos and brand marks |
|
|
88
|
+
| Text-block glyphs for alignment, lists and indent | Checkmarks |
|
|
89
|
+
| Speaker and volume waves | Physical objects such as clocks, cups and pencils |
|
|
90
|
+
| Directional glyphs such as "send" | Media playback, which stays LTR by convention |
|
|
91
|
+
|
|
92
|
+
Use one mechanism per element. Two flips on one icon can compound back to unflipped.
|
|
93
|
+
|
|
94
|
+
```css
|
|
95
|
+
[dir="rtl"] .icon-directional {
|
|
96
|
+
scale: -1 1;
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// Tailwind
|
|
102
|
+
<ChevronRightIcon className="rtl:-scale-x-100" />
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Analyze composite icons part by part. A badge or slash overlay may keep its position while the base glyph flips. Accessible names for icon-only buttons belong to `accessibility`.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Performance
|
|
2
|
+
|
|
3
|
+
Recipes for transition specificity and compositing hints.
|
|
4
|
+
|
|
5
|
+
## Transition only what changes
|
|
6
|
+
|
|
7
|
+
`transition: all` animates properties nobody meant to animate, such as colors on a theme flip. On layout properties such as `width` and `padding` it re-runs layout on every frame. Tailwind's bare `transition` is a curated list rather than `all`, and still covers more than most elements change.
|
|
8
|
+
|
|
9
|
+
```css
|
|
10
|
+
/* Good: only what changes */
|
|
11
|
+
.button {
|
|
12
|
+
transition-property: scale, background-color;
|
|
13
|
+
transition-duration: 150ms;
|
|
14
|
+
transition-timing-function: ease-out;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Bad: everything */
|
|
18
|
+
.button {
|
|
19
|
+
transition: all 150ms ease-out;
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
// Good: explicit properties
|
|
25
|
+
<button className="transition-[scale,background-color] duration-150 ease-out">
|
|
26
|
+
|
|
27
|
+
// Bad: transition all
|
|
28
|
+
<button className="transition-all duration-150 ease-out">
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
In Tailwind 4, `transition-transform` covers `transform, translate, scale, rotate`, and in Tailwind 3 only `transform`. Use it when animating transforms alone. Mixing transform and other properties takes the bracket syntax, as in `transition-[scale,opacity,filter]`.
|
|
32
|
+
|
|
33
|
+
## Use will-change sparingly
|
|
34
|
+
|
|
35
|
+
`will-change` promotes an element to its own compositing layer ahead of time. Without it the browser promotes when the animation starts, and that one-time promotion can stutter on the first frame. Each extra layer costs memory, so never add it preemptively.
|
|
36
|
+
|
|
37
|
+
```css
|
|
38
|
+
/* Good: names the property that animates */
|
|
39
|
+
.animated-card {
|
|
40
|
+
will-change: scale, opacity;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* Bad: never all */
|
|
44
|
+
.animated-card {
|
|
45
|
+
will-change: all;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/* Bad: these never composite */
|
|
49
|
+
.animated-card {
|
|
50
|
+
will-change: background-color, padding;
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
| Property | Worth `will-change` |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `transform`, `translate`, `scale`, `rotate` | Yes |
|
|
57
|
+
| `opacity` | Yes |
|
|
58
|
+
| `filter` | Yes |
|
|
59
|
+
| `clip-path` | Rarely, since compositing it is not reliable across browsers |
|
|
60
|
+
| `top`, `left`, `width`, `height` | No |
|
|
61
|
+
| `background`, `border`, `color` | No |
|
|
62
|
+
|
|
63
|
+
`will-change` on a transform property or `filter` makes the element the containing block for its `position: fixed` descendants, so a fixed modal or tooltip inside it stops tracking the viewport. Any of these values also creates a stacking context, which can reorder `z-index` against siblings.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Surfaces
|
|
2
|
+
|
|
3
|
+
Recipes for concentric radius, optical alignment, shadow rings and image outlines.
|
|
4
|
+
|
|
5
|
+
## Concentric border radius
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
outerRadius = innerRadius + padding + borderWidth
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```css
|
|
12
|
+
/* Good: concentric radii */
|
|
13
|
+
.card {
|
|
14
|
+
border-radius: 20px; /* 12 + 8 */
|
|
15
|
+
padding: 8px;
|
|
16
|
+
}
|
|
17
|
+
.card-inner {
|
|
18
|
+
border-radius: 12px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/* Bad: same radius on both */
|
|
22
|
+
.card {
|
|
23
|
+
border-radius: 12px;
|
|
24
|
+
padding: 8px;
|
|
25
|
+
}
|
|
26
|
+
.card-inner {
|
|
27
|
+
border-radius: 12px;
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
// Good: outer radius accounts for padding
|
|
33
|
+
<div className="rounded-2xl p-2"> {/* 16px radius, 8px padding */}
|
|
34
|
+
<div className="rounded-lg"> {/* 8px radius = 16 - 8 */}
|
|
35
|
+
...
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
// Bad: same radius on both
|
|
40
|
+
<div className="rounded-xl p-2">
|
|
41
|
+
<div className="rounded-xl">
|
|
42
|
+
...
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Optical alignment
|
|
48
|
+
|
|
49
|
+
### Buttons with text and an icon
|
|
50
|
+
|
|
51
|
+
Start the icon side at `2px` less padding than the text side, then judge by eye.
|
|
52
|
+
|
|
53
|
+
```css
|
|
54
|
+
/* Good: less padding on the trailing icon side */
|
|
55
|
+
.button-with-icon {
|
|
56
|
+
padding-inline-start: 16px;
|
|
57
|
+
padding-inline-end: 14px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Bad: equal padding pushes the icon visually outward */
|
|
61
|
+
.button-with-icon {
|
|
62
|
+
padding-inline: 16px;
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
// Tailwind
|
|
68
|
+
<button className="ps-4 pe-3.5 flex items-center gap-2">
|
|
69
|
+
<span>Continue</span>
|
|
70
|
+
<ArrowRightIcon />
|
|
71
|
+
</button>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Play button triangles
|
|
75
|
+
|
|
76
|
+
A triangle's geometric center sits left of its visual center, so shift it toward its point:
|
|
77
|
+
|
|
78
|
+
```css
|
|
79
|
+
.play-button svg {
|
|
80
|
+
transform: translateX(2px); /* physical on purpose: playback icons never mirror */
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Asymmetric icons
|
|
85
|
+
|
|
86
|
+
Stars, arrows and carets carry uneven visual weight. Fix the `viewBox` or path in the SVG, so the component needs no extra offset. Where the asset cannot change, nudge its wrapper:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<span className="translate-x-px">
|
|
90
|
+
<StarIcon />
|
|
91
|
+
</span>
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Shadow recipes
|
|
95
|
+
|
|
96
|
+
### Light mode
|
|
97
|
+
|
|
98
|
+
Three layers. The first acts as a 1px ring, the second adds lift and the third ambient depth:
|
|
99
|
+
|
|
100
|
+
```css
|
|
101
|
+
:root {
|
|
102
|
+
--shadow-border:
|
|
103
|
+
0px 0px 0px 1px oklch(0 0 0 / 0.06),
|
|
104
|
+
0px 1px 2px -1px oklch(0 0 0 / 0.06),
|
|
105
|
+
0px 2px 4px 0px oklch(0 0 0 / 0.04);
|
|
106
|
+
--shadow-border-hover:
|
|
107
|
+
0px 0px 0px 1px oklch(0 0 0 / 0.08),
|
|
108
|
+
0px 1px 2px -1px oklch(0 0 0 / 0.08),
|
|
109
|
+
0px 2px 4px 0px oklch(0 0 0 / 0.06);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Dark mode
|
|
114
|
+
|
|
115
|
+
Depth shadows vanish on dark backgrounds, so dark mode keeps one white ring:
|
|
116
|
+
|
|
117
|
+
```css
|
|
118
|
+
/* Redefine under the project's dark selector */
|
|
119
|
+
--shadow-border: 0 0 0 1px oklch(1 0 0 / 0.08);
|
|
120
|
+
--shadow-border-hover: 0 0 0 1px oklch(1 0 0 / 0.13);
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Usage
|
|
124
|
+
|
|
125
|
+
```css
|
|
126
|
+
.card {
|
|
127
|
+
border: 1px solid transparent; /* forced-colors mode drops box-shadow and paints this border */
|
|
128
|
+
box-shadow: var(--shadow-border);
|
|
129
|
+
transition-property: box-shadow;
|
|
130
|
+
transition-duration: 150ms;
|
|
131
|
+
transition-timing-function: ease-out;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.card:hover {
|
|
135
|
+
box-shadow: var(--shadow-border-hover);
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
The transparent border keeps the box the same size as the border it replaces.
|
|
140
|
+
|
|
141
|
+
## Image outlines
|
|
142
|
+
|
|
143
|
+
```css
|
|
144
|
+
:root {
|
|
145
|
+
--image-outline: oklch(0 0 0 / 0.1);
|
|
146
|
+
}
|
|
147
|
+
/* Redefine under the project's dark selector */
|
|
148
|
+
--image-outline: oklch(1 0 0 / 0.1);
|
|
149
|
+
|
|
150
|
+
.content-image {
|
|
151
|
+
outline: 1px solid var(--image-outline);
|
|
152
|
+
outline-offset: -1px;
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
<img
|
|
158
|
+
className="outline outline-1 -outline-offset-1 outline-black/10 dark:outline-white/10"
|
|
159
|
+
src={src}
|
|
160
|
+
alt={alt}
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Never `outline-slate-*`, `outline-zinc-*`, `outline-neutral-*` or a palette near-black such as `#111827`.
|
|
165
|
+
|
|
166
|
+
Use `outline` rather than `border` because it never changes the image's size. At `outline-offset: -1px` it sits just inside the edge and follows the corner radius.
|