@tenphi/tasty 0.0.0-snapshot.2dc73be → 0.0.0-snapshot.2f5d166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +288 -250
  2. package/dist/_virtual/_rolldown/runtime.js +1 -2
  3. package/dist/chunks/cacheKey.d.ts +1 -0
  4. package/dist/chunks/cacheKey.js +17 -10
  5. package/dist/chunks/cacheKey.js.map +1 -1
  6. package/dist/chunks/definitions.d.ts +1 -1
  7. package/dist/chunks/definitions.js +2 -3
  8. package/dist/chunks/definitions.js.map +1 -1
  9. package/dist/chunks/index.d.ts +1 -0
  10. package/dist/chunks/renderChunk.d.ts +1 -0
  11. package/dist/chunks/renderChunk.js +32 -34
  12. package/dist/chunks/renderChunk.js.map +1 -1
  13. package/dist/compute-styles.d.ts +31 -0
  14. package/dist/compute-styles.js +335 -0
  15. package/dist/compute-styles.js.map +1 -0
  16. package/dist/config.d.ts +109 -30
  17. package/dist/config.js +142 -57
  18. package/dist/config.js.map +1 -1
  19. package/dist/core/index.d.ts +12 -11
  20. package/dist/core/index.js +10 -9
  21. package/dist/counter-style/index.js +51 -0
  22. package/dist/counter-style/index.js.map +1 -0
  23. package/dist/debug.d.ts +26 -141
  24. package/dist/debug.js +357 -637
  25. package/dist/debug.js.map +1 -1
  26. package/dist/font-face/index.js +63 -0
  27. package/dist/font-face/index.js.map +1 -0
  28. package/dist/hooks/index.d.ts +7 -0
  29. package/dist/hooks/useCounterStyle.d.ts +52 -0
  30. package/dist/hooks/useCounterStyle.js +43 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +45 -0
  33. package/dist/hooks/useFontFace.js +68 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +18 -2
  36. package/dist/hooks/useGlobalStyles.js +50 -46
  37. package/dist/hooks/useGlobalStyles.js.map +1 -1
  38. package/dist/hooks/useKeyframes.d.ts +4 -2
  39. package/dist/hooks/useKeyframes.js +32 -57
  40. package/dist/hooks/useKeyframes.js.map +1 -1
  41. package/dist/hooks/useProperty.d.ts +4 -2
  42. package/dist/hooks/useProperty.js +29 -45
  43. package/dist/hooks/useProperty.js.map +1 -1
  44. package/dist/hooks/useRawCSS.d.ts +8 -44
  45. package/dist/hooks/useRawCSS.js +82 -27
  46. package/dist/hooks/useRawCSS.js.map +1 -1
  47. package/dist/hooks/useStyles.d.ts +4 -9
  48. package/dist/hooks/useStyles.js +7 -226
  49. package/dist/hooks/useStyles.js.map +1 -1
  50. package/dist/index.d.ts +15 -12
  51. package/dist/index.js +13 -10
  52. package/dist/injector/index.d.ts +36 -19
  53. package/dist/injector/index.js +42 -19
  54. package/dist/injector/index.js.map +1 -1
  55. package/dist/injector/injector.d.ts +48 -3
  56. package/dist/injector/injector.js +144 -16
  57. package/dist/injector/injector.js.map +1 -1
  58. package/dist/injector/sheet-manager.d.ts +9 -13
  59. package/dist/injector/sheet-manager.js +39 -70
  60. package/dist/injector/sheet-manager.js.map +1 -1
  61. package/dist/injector/types.d.ts +103 -19
  62. package/dist/keyframes/index.js +1 -1
  63. package/dist/parser/classify.js +6 -6
  64. package/dist/parser/classify.js.map +1 -1
  65. package/dist/parser/const.js +30 -3
  66. package/dist/parser/const.js.map +1 -1
  67. package/dist/parser/lru.js +1 -1
  68. package/dist/parser/lru.js.map +1 -1
  69. package/dist/parser/parser.js +2 -3
  70. package/dist/parser/parser.js.map +1 -1
  71. package/dist/parser/tokenizer.js +1 -1
  72. package/dist/parser/tokenizer.js.map +1 -1
  73. package/dist/parser/types.js +1 -1
  74. package/dist/parser/types.js.map +1 -1
  75. package/dist/pipeline/conditions.js +1 -1
  76. package/dist/pipeline/conditions.js.map +1 -1
  77. package/dist/pipeline/exclusive.js +1 -2
  78. package/dist/pipeline/exclusive.js.map +1 -1
  79. package/dist/pipeline/index.d.ts +3 -1
  80. package/dist/pipeline/index.js +80 -32
  81. package/dist/pipeline/index.js.map +1 -1
  82. package/dist/pipeline/materialize.js +329 -82
  83. package/dist/pipeline/materialize.js.map +1 -1
  84. package/dist/pipeline/parseStateKey.d.ts +1 -1
  85. package/dist/pipeline/parseStateKey.js +3 -8
  86. package/dist/pipeline/parseStateKey.js.map +1 -1
  87. package/dist/pipeline/simplify.js +1 -2
  88. package/dist/pipeline/simplify.js.map +1 -1
  89. package/dist/pipeline/warnings.js +1 -1
  90. package/dist/plugins/index.d.ts +2 -0
  91. package/dist/plugins/okhsl-plugin.js +3 -277
  92. package/dist/plugins/okhsl-plugin.js.map +1 -1
  93. package/dist/plugins/types.d.ts +9 -2
  94. package/dist/properties/index.js +3 -17
  95. package/dist/properties/index.js.map +1 -1
  96. package/dist/properties/property-type-resolver.js +5 -2
  97. package/dist/properties/property-type-resolver.js.map +1 -1
  98. package/dist/rsc-cache.js +70 -0
  99. package/dist/rsc-cache.js.map +1 -0
  100. package/dist/ssr/astro-client.d.ts +1 -0
  101. package/dist/ssr/astro-client.js +24 -0
  102. package/dist/ssr/astro-client.js.map +1 -0
  103. package/dist/ssr/astro-middleware.d.ts +15 -0
  104. package/dist/ssr/astro-middleware.js +19 -0
  105. package/dist/ssr/astro-middleware.js.map +1 -0
  106. package/dist/ssr/astro.d.ts +85 -8
  107. package/dist/ssr/astro.js +111 -22
  108. package/dist/ssr/astro.js.map +1 -1
  109. package/dist/ssr/async-storage.js +1 -2
  110. package/dist/ssr/async-storage.js.map +1 -1
  111. package/dist/ssr/collect-auto-properties.js +29 -11
  112. package/dist/ssr/collect-auto-properties.js.map +1 -1
  113. package/dist/ssr/collector.d.ts +17 -0
  114. package/dist/ssr/collector.js +60 -14
  115. package/dist/ssr/collector.js.map +1 -1
  116. package/dist/ssr/format-global-rules.js +1 -1
  117. package/dist/ssr/format-keyframes.js +1 -2
  118. package/dist/ssr/format-keyframes.js.map +1 -1
  119. package/dist/ssr/format-property.js +10 -9
  120. package/dist/ssr/format-property.js.map +1 -1
  121. package/dist/ssr/format-rules.js +8 -5
  122. package/dist/ssr/format-rules.js.map +1 -1
  123. package/dist/ssr/hydrate.js +1 -2
  124. package/dist/ssr/hydrate.js.map +1 -1
  125. package/dist/ssr/index.d.ts +2 -3
  126. package/dist/ssr/index.js +2 -4
  127. package/dist/ssr/index.js.map +1 -1
  128. package/dist/ssr/next.d.ts +1 -3
  129. package/dist/ssr/next.js +10 -7
  130. package/dist/ssr/next.js.map +1 -1
  131. package/dist/ssr/ssr-collector-ref.js +1 -1
  132. package/dist/states/index.js +13 -259
  133. package/dist/states/index.js.map +1 -1
  134. package/dist/static/index.js +1 -2
  135. package/dist/static/inject.d.ts +5 -0
  136. package/dist/static/inject.js +17 -0
  137. package/dist/static/inject.js.map +1 -0
  138. package/dist/static/tastyStatic.js +1 -2
  139. package/dist/static/tastyStatic.js.map +1 -1
  140. package/dist/static/types.js +1 -1
  141. package/dist/styles/border.d.ts +1 -1
  142. package/dist/styles/border.js +30 -24
  143. package/dist/styles/border.js.map +1 -1
  144. package/dist/styles/color.d.ts +1 -1
  145. package/dist/styles/color.js +11 -8
  146. package/dist/styles/color.js.map +1 -1
  147. package/dist/styles/const.js +17 -0
  148. package/dist/styles/const.js.map +1 -0
  149. package/dist/styles/createStyle.js +28 -26
  150. package/dist/styles/createStyle.js.map +1 -1
  151. package/dist/styles/dimension.js +15 -3
  152. package/dist/styles/dimension.js.map +1 -1
  153. package/dist/styles/directional.js +133 -0
  154. package/dist/styles/directional.js.map +1 -0
  155. package/dist/styles/display.d.ts +3 -10
  156. package/dist/styles/display.js +45 -39
  157. package/dist/styles/display.js.map +1 -1
  158. package/dist/styles/fade.d.ts +1 -1
  159. package/dist/styles/fade.js +9 -5
  160. package/dist/styles/fade.js.map +1 -1
  161. package/dist/styles/fill.d.ts +2 -2
  162. package/dist/styles/fill.js +3 -4
  163. package/dist/styles/fill.js.map +1 -1
  164. package/dist/styles/flow.js +1 -1
  165. package/dist/styles/gap.d.ts +1 -1
  166. package/dist/styles/gap.js +4 -3
  167. package/dist/styles/gap.js.map +1 -1
  168. package/dist/styles/height.d.ts +1 -1
  169. package/dist/styles/height.js +1 -2
  170. package/dist/styles/height.js.map +1 -1
  171. package/dist/styles/index.d.ts +0 -1
  172. package/dist/styles/index.js +3 -4
  173. package/dist/styles/index.js.map +1 -1
  174. package/dist/styles/inset.d.ts +1 -29
  175. package/dist/styles/inset.js +19 -135
  176. package/dist/styles/inset.js.map +1 -1
  177. package/dist/styles/list.d.ts +5 -5
  178. package/dist/styles/list.js +4 -2
  179. package/dist/styles/list.js.map +1 -1
  180. package/dist/styles/margin.d.ts +1 -1
  181. package/dist/styles/margin.js +17 -89
  182. package/dist/styles/margin.js.map +1 -1
  183. package/dist/styles/outline.d.ts +1 -1
  184. package/dist/styles/outline.js +6 -16
  185. package/dist/styles/outline.js.map +1 -1
  186. package/dist/styles/padding.d.ts +1 -1
  187. package/dist/styles/padding.js +17 -89
  188. package/dist/styles/padding.js.map +1 -1
  189. package/dist/styles/placement.d.ts +37 -0
  190. package/dist/styles/placement.js +74 -0
  191. package/dist/styles/placement.js.map +1 -0
  192. package/dist/styles/predefined.d.ts +4 -4
  193. package/dist/styles/predefined.js +9 -10
  194. package/dist/styles/predefined.js.map +1 -1
  195. package/dist/styles/preset.d.ts +6 -1
  196. package/dist/styles/preset.js +54 -53
  197. package/dist/styles/preset.js.map +1 -1
  198. package/dist/styles/radius.d.ts +1 -3
  199. package/dist/styles/radius.js +38 -6
  200. package/dist/styles/radius.js.map +1 -1
  201. package/dist/styles/scrollMargin.d.ts +24 -0
  202. package/dist/styles/scrollMargin.js +32 -0
  203. package/dist/styles/scrollMargin.js.map +1 -0
  204. package/dist/styles/scrollbar.d.ts +1 -1
  205. package/dist/styles/scrollbar.js +8 -5
  206. package/dist/styles/scrollbar.js.map +1 -1
  207. package/dist/styles/shadow.d.ts +1 -1
  208. package/dist/styles/shadow.js +4 -3
  209. package/dist/styles/shadow.js.map +1 -1
  210. package/dist/styles/shared.js +17 -0
  211. package/dist/styles/shared.js.map +1 -0
  212. package/dist/styles/transition.d.ts +1 -1
  213. package/dist/styles/transition.js +5 -4
  214. package/dist/styles/transition.js.map +1 -1
  215. package/dist/styles/types.d.ts +84 -15
  216. package/dist/styles/width.d.ts +1 -1
  217. package/dist/styles/width.js +1 -2
  218. package/dist/styles/width.js.map +1 -1
  219. package/dist/tasty.d.ts +46 -893
  220. package/dist/tasty.js +96 -59
  221. package/dist/tasty.js.map +1 -1
  222. package/dist/types.d.ts +1 -1
  223. package/dist/utils/cache-wrapper.js +4 -9
  224. package/dist/utils/cache-wrapper.js.map +1 -1
  225. package/dist/utils/case-converter.js +1 -1
  226. package/dist/utils/color-math.d.ts +46 -0
  227. package/dist/utils/color-math.js +749 -0
  228. package/dist/utils/color-math.js.map +1 -0
  229. package/dist/utils/color-space.d.ts +5 -0
  230. package/dist/utils/color-space.js +228 -0
  231. package/dist/utils/color-space.js.map +1 -0
  232. package/dist/utils/colors.js +3 -2
  233. package/dist/utils/colors.js.map +1 -1
  234. package/dist/utils/dotize.js +1 -1
  235. package/dist/utils/dotize.js.map +1 -1
  236. package/dist/utils/filter-base-props.d.ts +1 -1
  237. package/dist/utils/filter-base-props.js +1 -1
  238. package/dist/utils/filter-base-props.js.map +1 -1
  239. package/dist/utils/get-display-name.js +1 -1
  240. package/dist/utils/has-keys.js +13 -0
  241. package/dist/utils/has-keys.js.map +1 -0
  242. package/dist/utils/hash.js +14 -0
  243. package/dist/utils/hash.js.map +1 -0
  244. package/dist/utils/is-dev-env.js +1 -1
  245. package/dist/utils/is-dev-env.js.map +1 -1
  246. package/dist/utils/is-valid-element-type.js +1 -1
  247. package/dist/utils/merge-styles.js +1 -2
  248. package/dist/utils/merge-styles.js.map +1 -1
  249. package/dist/utils/mod-attrs.d.ts +0 -2
  250. package/dist/utils/mod-attrs.js +3 -4
  251. package/dist/utils/mod-attrs.js.map +1 -1
  252. package/dist/utils/process-tokens.d.ts +3 -17
  253. package/dist/utils/process-tokens.js +19 -107
  254. package/dist/utils/process-tokens.js.map +1 -1
  255. package/dist/utils/resolve-recipes.js +1 -2
  256. package/dist/utils/resolve-recipes.js.map +1 -1
  257. package/dist/utils/selector-transform.js +1 -1
  258. package/dist/utils/string.js +1 -1
  259. package/dist/utils/styles.d.ts +3 -81
  260. package/dist/utils/styles.js +29 -539
  261. package/dist/utils/styles.js.map +1 -1
  262. package/dist/utils/typography.d.ts +24 -13
  263. package/dist/utils/typography.js +15 -17
  264. package/dist/utils/typography.js.map +1 -1
  265. package/dist/utils/warnings.js +1 -1
  266. package/dist/zero/babel.d.ts +63 -8
  267. package/dist/zero/babel.js +163 -44
  268. package/dist/zero/babel.js.map +1 -1
  269. package/dist/zero/css-writer.js +1 -2
  270. package/dist/zero/css-writer.js.map +1 -1
  271. package/dist/zero/extractor.js +54 -3
  272. package/dist/zero/extractor.js.map +1 -1
  273. package/dist/zero/index.js +1 -2
  274. package/dist/zero/next.d.ts +28 -1
  275. package/dist/zero/next.js +70 -15
  276. package/dist/zero/next.js.map +1 -1
  277. package/docs/PIPELINE.md +519 -0
  278. package/docs/README.md +31 -0
  279. package/docs/adoption.md +296 -0
  280. package/docs/comparison.md +420 -0
  281. package/docs/configuration.md +127 -12
  282. package/docs/debug.md +152 -339
  283. package/docs/design-system.md +424 -0
  284. package/docs/{usage.md → dsl.md} +379 -386
  285. package/docs/getting-started.md +217 -0
  286. package/docs/injector.md +43 -27
  287. package/docs/methodology.md +616 -0
  288. package/docs/runtime.md +575 -0
  289. package/docs/ssr.md +144 -81
  290. package/docs/styles.md +48 -26
  291. package/docs/tasty-static.md +166 -22
  292. package/package.json +27 -12
  293. package/dist/ssr/context.d.ts +0 -8
  294. package/dist/ssr/context.js +0 -14
  295. package/dist/ssr/context.js.map +0 -1
  296. package/dist/styles/align.d.ts +0 -15
  297. package/dist/styles/align.js +0 -14
  298. package/dist/styles/align.js.map +0 -1
  299. package/dist/styles/justify.d.ts +0 -15
  300. package/dist/styles/justify.js +0 -14
  301. package/dist/styles/justify.js.map +0 -1
  302. package/dist/tokens/typography.d.ts +0 -19
  303. package/dist/tokens/typography.js +0 -237
  304. package/dist/tokens/typography.js.map +0 -1
  305. package/dist/utils/hsl-to-rgb.js +0 -38
  306. package/dist/utils/hsl-to-rgb.js.map +0 -1
  307. package/dist/utils/okhsl-to-rgb.js +0 -296
  308. package/dist/utils/okhsl-to-rgb.js.map +0 -1
package/docs/ssr.md CHANGED
@@ -1,23 +1,33 @@
1
1
  # Server-Side Rendering (SSR)
2
2
 
3
- Tasty supports server-side rendering with zero-cost client hydration. Your existing `tasty()` components work unchanged -- SSR is opt-in and requires no per-component modifications.
3
+ Tasty supports server-side rendering with zero-cost client hydration. This does **not** introduce a separate styling engine: SSR uses the same runtime `tasty()` pipeline you already use on the client, then adds server-side CSS collection and client-side cache hydration. Your existing `tasty()` components work unchanged, and SSR remains opt-in with no per-component modifications. For the broader docs map, see the [Docs Hub](README.md).
4
4
 
5
- **Requires React 19+.**
5
+ ---
6
+
7
+ ## Requirements
8
+
9
+ | Dependency | Version | Required for |
10
+ |---|---|---|
11
+ | `react` | >= 18 | All SSR entry points (matches the current peer dependency of `@tenphi/tasty`) |
12
+ | `next` | >= 13 | Next.js integration (`@tenphi/tasty/ssr/next`) — App Router with `useServerInsertedHTML` |
13
+ | Node.js | >= 20 | Generic / streaming SSR (`@tenphi/tasty/ssr`) — uses `node:async_hooks` for `AsyncLocalStorage` |
14
+
15
+ The Astro integration (`@tenphi/tasty/ssr/astro`) has no additional dependencies beyond `react`.
6
16
 
7
17
  ---
8
18
 
9
19
  ## How It Works
10
20
 
11
- During server rendering, `useStyles()` detects a `ServerStyleCollector` and collects CSS into it instead of trying to access the DOM. The collector accumulates all styles, serializes them as `<style>` tags and a cache state script in the HTML. On the client, `hydrateTastyCache()` pre-populates the injector cache so that `useStyles()` skips the rendering pipeline entirely during hydration.
21
+ `tasty()` components are hook-free and use `computeStyles()` internally — a synchronous, framework-agnostic function. On the server, `computeStyles()` detects a `ServerStyleCollector` (via `AsyncLocalStorage` or an explicit option) and collects CSS into it instead of trying to access the DOM. On the client, CSS is injected synchronously into the DOM during render; the injector's content-based cache makes this idempotent. The collector accumulates all styles, serializes them as `<style>` tags and a cache state script in the HTML. On the client, `hydrateTastyCache()` pre-populates the injector cache so that `computeStyles()` skips the rendering pipeline entirely during hydration.
12
22
 
13
23
  ```
14
24
  Server Client
15
25
  ────── ──────
16
26
  tasty() renders hydrateTastyCache() pre-populates cache
17
- └─ useStyles() └─ cacheKey → className map ready
27
+ └─ computeStyles() └─ cacheKey → className map ready
18
28
  └─ collector.collect()
19
29
  tasty() renders
20
- After render: └─ useStyles()
30
+ After render: └─ computeStyles()
21
31
  <style data-tasty-ssr> └─ cache hit → skip pipeline
22
32
  <script data-tasty-cache> └─ no CSS re-injection
23
33
  ```
@@ -72,15 +82,21 @@ That's it. All `tasty()` components inside the tree automatically get SSR suppor
72
82
 
73
83
  ### How it works
74
84
 
75
- - `TastyRegistry` is a `'use client'` component, but Next.js still server-renders it on initial page load.
76
- - During SSR, `useStyles()` finds the collector via React context and pushes CSS rules to it.
77
- - `TastyRegistry` uses `useServerInsertedHTML` to flush collected CSS into the HTML stream as `<style data-tasty-ssr>` tags. This is fully streaming-compatible -- styles are injected alongside each Suspense boundary as it resolves.
85
+ - `TastyRegistry` is a `'use client'` component, but Next.js still server-renders it on initial page load. The `'use client'` boundary is required solely to access `useServerInsertedHTML` — **not** because `tasty()` components need the client.
86
+ - During SSR, `TastyRegistry` creates a `ServerStyleCollector` and registers it via a module-level global getter. All style functions — `tasty()` components, `computeStyles()`, `useStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, and `useCounterStyle()` — discover the collector through this single global getter. No React context is involved.
87
+ - `TastyRegistry` uses `useServerInsertedHTML` to flush collected CSS into the HTML stream as `<style data-tasty-ssr>` tags. This is fully streaming-compatible — styles are injected alongside each Suspense boundary as it resolves.
78
88
  - A companion `<script>` tag transfers the `cacheKey → className` mapping to the client.
79
- - When the module loads on the client, `hydrateTastyCache()` runs automatically and pre-populates the injector cache. During hydration, `useStyles()` hits the cache and skips the entire pipeline.
89
+ - When the module loads on the client, `hydrateTastyCache()` runs automatically and pre-populates the injector cache. During hydration, `computeStyles()` hits the cache and skips the entire pipeline.
90
+
91
+ ### Using Tasty in Server Components
92
+
93
+ All Tasty style functions are hook-free and do not require `'use client'`. They can be used directly in React Server Components:
80
94
 
81
- ### Using tasty() in Server Components
95
+ - `tasty()` components — dynamic `styleProps` like `<Grid flow="column">` work normally
96
+ - `useStyles()`, `useGlobalStyles()`, `useRawCSS()` — inject styles by class or selector
97
+ - `useKeyframes()`, `useProperty()`, `useFontFace()`, `useCounterStyle()` — inject ancillary CSS rules
82
98
 
83
- `tasty()` components use React hooks internally, so they require `'use client'`. However, this does **not** prevent them from being used in Server Component pages. In Next.js, `'use client'` components are still server-rendered on initial load. Dynamic `styleProps` like `<Grid flow="column">` work normally when a `tasty()` component is imported into a Server Component page.
99
+ During SSR, all functions discover the collector via the same global getter registered by `TastyRegistry` — no React context or client boundary needed. In RSC mode without a collector (e.g., Astro zero-setup), CSS is accumulated in a per-request cache and flushed into an inline `<style>` tag by the next `tasty()` component in the tree.
84
100
 
85
101
  ### Options
86
102
 
@@ -106,18 +122,17 @@ The nonce is automatically applied to all `<style>` and `<script>` tags injected
106
122
 
107
123
  ## Astro
108
124
 
109
- ### 1. Add the middleware
125
+ Tasty offers three levels of Astro integration. Choose the one that matches your needs:
110
126
 
111
- Create or update your Astro middleware:
127
+ | Setup | Config needed | Deduplication | Hooks work | Client JS |
128
+ |---|---|---|---|---|
129
+ | Zero setup | None | Per render tree | No | None |
130
+ | `tastyIntegration({ islands: false })` | One line | Cross-tree | Yes | None |
131
+ | `tastyIntegration()` | One line | Cross-tree | Yes | Auto-hydration |
112
132
 
113
- ```ts
114
- // src/middleware.ts
115
- import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
116
-
117
- export const onRequest = tastyMiddleware();
118
- ```
133
+ ### Zero setup (static pages)
119
134
 
120
- ### 2. Use tasty() components as normal
135
+ `tasty()` components work in Astro with **no configuration**. Each component emits its own inline `<style>` tag during server rendering via the RSC inline path. Just import and use:
121
136
 
122
137
  ```tsx
123
138
  // src/components/Card.tsx
@@ -143,56 +158,123 @@ import Card from '../components/Card.tsx';
143
158
 
144
159
  <html>
145
160
  <body>
146
- <Card>Static card — styles collected by middleware</Card>
147
- <Card client:load>Island card — styles hydrated on client</Card>
161
+ <Card>Styled with zero setup</Card>
148
162
  </body>
149
163
  </html>
150
164
  ```
151
165
 
152
- ### How it works
166
+ **Trade-offs**: Styles are deduplicated within each React render tree, but Astro renders separate component trees independently, so shared CSS (tokens, `@property` rules) may appear more than once. All style functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useProperty`, `useFontFace`, `useCounterStyle`) work in zero-setup mode — their CSS is accumulated in the RSC cache and flushed by the next `tasty()` component in the tree.
153
167
 
154
- Astro's `@astrojs/react` renderer calls `renderToString()` for each React component without wrapping the tree in a provider. The middleware uses `AsyncLocalStorage` to make the collector available to all `useStyles()` calls within the request.
168
+ Best for quick prototyping, small static sites, or trying Tasty out in Astro.
155
169
 
156
- - **Static components** (no `client:*`): Styles are collected during `renderToString` and injected into `</head>`. No JavaScript is shipped for these components.
157
- - **Islands** (`client:load`, `client:visible`, etc.): Styles are collected during SSR the same way. On the client, importing `@tenphi/tasty/ssr/astro` auto-hydrates the cache from `<script data-tasty-cache>`. The island's `useStyles()` calls hit the cache during hydration.
170
+ ### Astro Integration (recommended)
158
171
 
159
- ### Client-side hydration for islands
172
+ For production use, add `tastyIntegration()` to your Astro config. This registers middleware automatically and, by default, injects client-side hydration for islands.
160
173
 
161
- The `@tenphi/tasty/ssr/astro` module auto-hydrates when imported on the client. To ensure the cache is warm before any island renders, import it in a shared entry point or in each island component:
174
+ #### With islands (default)
162
175
 
163
- ```tsx
164
- // src/components/MyIsland.tsx
165
- import '@tenphi/tasty/ssr/astro'; // auto-hydrates cache on import
166
- import { tasty } from '@tenphi/tasty';
176
+ ```ts
177
+ // astro.config.mjs
178
+ import { defineConfig } from 'astro/config';
179
+ import react from '@astrojs/react';
180
+ import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
167
181
 
168
- const MyIsland = tasty({
169
- styles: { padding: '2x', fill: '#blue' },
182
+ export default defineConfig({
183
+ integrations: [react(), tastyIntegration()],
170
184
  });
185
+ ```
186
+
187
+ This gives you:
188
+
189
+ - A `ServerStyleCollector` per request via `AsyncLocalStorage`, deduplicating CSS across all React trees on the page
190
+ - A single consolidated `<style data-tasty-ssr>` injected into `</head>`
191
+ - A `<script data-tasty-cache>` tag with the `cacheKey -> className` map for client hydration
192
+ - Auto-injected client hydration script (via `injectScript('before-hydration')`) so islands skip the style pipeline during hydration -- no need to import anything manually in each island component
193
+
194
+ All style functions (`useGlobalStyles`, `useRawCSS`, `useKeyframes`, `useProperty`, `useFontFace`, `useCounterStyle`) work on the server.
195
+
196
+ ```astro
197
+ ---
198
+ // src/pages/index.astro
199
+ import Card from '../components/Card.tsx';
200
+ import Interactive from '../components/Interactive.tsx';
201
+ ---
171
202
 
172
- export default MyIsland;
203
+ <html>
204
+ <body>
205
+ <Card>Static -- styles in <style data-tasty-ssr></Card>
206
+ <Interactive client:load>Island -- cache hydrated automatically</Interactive>
207
+ </body>
208
+ </html>
173
209
  ```
174
210
 
175
- ### Options
211
+ #### Static only (no client JS)
212
+
213
+ If your site has no `client:*` islands, skip the hydration script and cache transfer:
176
214
 
177
215
  ```ts
178
- // Skip cache state transfer
216
+ // astro.config.mjs
217
+ import { defineConfig } from 'astro/config';
218
+ import react from '@astrojs/react';
219
+ import { tastyIntegration } from '@tenphi/tasty/ssr/astro';
220
+
221
+ export default defineConfig({
222
+ integrations: [react(), tastyIntegration({ islands: false })],
223
+ });
224
+ ```
225
+
226
+ This gives the same middleware deduplication and hook support, but ships zero client-side JavaScript. No `<script data-tasty-cache>` is emitted.
227
+
228
+ ### Manual middleware (advanced)
229
+
230
+ If you need to compose Tasty's middleware with other middleware (e.g., via `sequence()`), use `tastyMiddleware()` directly:
231
+
232
+ ```ts
233
+ // src/middleware.ts
234
+ import { sequence } from 'astro:middleware';
235
+ import { tastyMiddleware } from '@tenphi/tasty/ssr/astro';
236
+
237
+ export const onRequest = sequence(
238
+ tastyMiddleware(),
239
+ myOtherMiddleware,
240
+ );
241
+ ```
242
+
243
+ For island hydration with manual middleware, import the client module in a shared entry point or in each island:
244
+
245
+ ```tsx
246
+ import '@tenphi/tasty/ssr/astro-client';
247
+ ```
248
+
249
+ #### Options
250
+
251
+ ```ts
252
+ // Skip cache state transfer (static-only, no islands)
179
253
  export const onRequest = tastyMiddleware({ transferCache: false });
180
254
  ```
181
255
 
256
+ ### How it works
257
+
258
+ Astro's `@astrojs/react` renderer calls `renderToString()` for each React component without wrapping the tree in a provider. The middleware creates a `ServerStyleCollector` and binds it via `AsyncLocalStorage`. All `computeStyles()` calls within the request discover this collector automatically.
259
+
260
+ - **Static components** (no `client:*`): Styles are collected during `renderToString` and injected into `</head>` as a single `<style>` tag. No JavaScript is shipped.
261
+ - **Islands** (`client:load`, `client:visible`, etc.): Styles are collected during SSR the same way. On the client, the hydration script (auto-injected by `tastyIntegration()` or manually via `@tenphi/tasty/ssr/astro-client`) reads the cache state from `<script data-tasty-cache>` and pre-populates the injector. The island's `computeStyles()` calls hit the cache during hydration.
262
+ - The middleware uses streaming-compatible `TransformStream` processing to inject CSS into the response without buffering the entire HTML.
263
+
182
264
  ### CSP nonce
183
265
 
184
- Same as Next.js -- call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected tags.
266
+ Call `configure({ nonce: '...' })` before any rendering happens. The middleware reads the nonce and applies it to injected `<style>` and `<script>` tags.
185
267
 
186
268
  ---
187
269
 
188
270
  ## Generic Framework Integration
189
271
 
190
- Any React-based framework can integrate using the core SSR API:
272
+ Any React-based framework can integrate using `runWithCollector`, which binds a `ServerStyleCollector` to the current async context via `AsyncLocalStorage`. All style function calls within the render automatically discover the collector.
191
273
 
192
274
  ```tsx
193
275
  import {
194
276
  ServerStyleCollector,
195
- TastySSRContext,
277
+ runWithCollector,
196
278
  hydrateTastyCache,
197
279
  } from '@tenphi/tasty/ssr';
198
280
  import { renderToString } from 'react-dom/server';
@@ -202,10 +284,8 @@ import { hydrateRoot } from 'react-dom/client';
202
284
 
203
285
  const collector = new ServerStyleCollector();
204
286
 
205
- const html = renderToString(
206
- <TastySSRContext.Provider value={collector}>
207
- <App />
208
- </TastySSRContext.Provider>
287
+ const html = await runWithCollector(collector, () =>
288
+ renderToString(<App />)
209
289
  );
210
290
 
211
291
  const css = collector.getCSS();
@@ -241,11 +321,8 @@ For streaming with `renderToPipeableStream`, use `flushCSS()` instead of `getCSS
241
321
  ```tsx
242
322
  const collector = new ServerStyleCollector();
243
323
 
244
- const stream = renderToPipeableStream(
245
- <TastySSRContext.Provider value={collector}>
246
- <App />
247
- </TastySSRContext.Provider>,
248
- {
324
+ const stream = await runWithCollector(collector, () =>
325
+ renderToPipeableStream(<App />, {
249
326
  onShellReady() {
250
327
  // Flush styles collected so far
251
328
  const css = collector.flushCSS();
@@ -260,31 +337,10 @@ const stream = renderToPipeableStream(
260
337
  const state = collector.getCacheState();
261
338
  res.write(`<script data-tasty-cache type="application/json">${JSON.stringify(state)}</script>`);
262
339
  },
263
- }
340
+ })
264
341
  );
265
342
  ```
266
343
 
267
- ### AsyncLocalStorage (no React context)
268
-
269
- If your framework doesn't support wrapping the React tree with a provider, use `runWithCollector`:
270
-
271
- ```tsx
272
- import {
273
- ServerStyleCollector,
274
- runWithCollector,
275
- hydrateTastyCache,
276
- } from '@tenphi/tasty/ssr';
277
-
278
- const collector = new ServerStyleCollector();
279
-
280
- const html = await runWithCollector(collector, () =>
281
- renderToString(<App />)
282
- );
283
-
284
- const css = collector.getCSS();
285
- // ... inject into HTML as above
286
- ```
287
-
288
344
  ---
289
345
 
290
346
  ## API Reference
@@ -293,9 +349,10 @@ const css = collector.getCSS();
293
349
 
294
350
  | Import path | Description |
295
351
  |---|---|
296
- | `@tenphi/tasty/ssr` | Core SSR API: `ServerStyleCollector`, `TastySSRContext`, `runWithCollector`, `hydrateTastyCache` |
352
+ | `@tenphi/tasty/ssr` | Core SSR API: `ServerStyleCollector`, `runWithCollector`, `hydrateTastyCache` |
297
353
  | `@tenphi/tasty/ssr/next` | Next.js App Router: `TastyRegistry` component |
298
- | `@tenphi/tasty/ssr/astro` | Astro: `tastyMiddleware`, auto-hydration on import |
354
+ | `@tenphi/tasty/ssr/astro` | Astro: `tastyIntegration`, `tastyMiddleware` |
355
+ | `@tenphi/tasty/ssr/astro-client` | Astro: client-side cache hydration (auto-injected by integration, or import manually) |
299
356
 
300
357
  ### `ServerStyleCollector`
301
358
 
@@ -307,14 +364,12 @@ Server-safe style collector. One instance per request.
307
364
  | `collectChunk(cacheKey, className, rules)` | Record CSS rules for a chunk. Deduplicated by `cacheKey`. |
308
365
  | `collectKeyframes(name, css)` | Record a `@keyframes` rule. Deduplicated by name. |
309
366
  | `collectProperty(name, css)` | Record a `@property` rule. Deduplicated by name. |
367
+ | `collectFontFace(key, css)` | Record a `@font-face` rule. Deduplicated by content hash. |
368
+ | `collectCounterStyle(name, css)` | Record a `@counter-style` rule. Deduplicated by name. |
310
369
  | `getCSS()` | Get all collected CSS as a single string. For non-streaming SSR. |
311
370
  | `flushCSS()` | Get only CSS collected since the last flush. For streaming SSR. |
312
371
  | `getCacheState()` | Serialize `{ entries: Record<cacheKey, className>, classCounter }` for client hydration. |
313
372
 
314
- ### `TastySSRContext`
315
-
316
- React context (`createContext<ServerStyleCollector | null>(null)`). Used by `useStyles()` to find the collector during SSR.
317
-
318
373
  ### `TastyRegistry`
319
374
 
320
375
  Next.js App Router component. Props:
@@ -324,9 +379,17 @@ Next.js App Router component. Props:
324
379
  | `children` | `ReactNode` | required | Application tree |
325
380
  | `transferCache` | `boolean` | `true` | Embed cache state script for zero-cost hydration |
326
381
 
382
+ ### `tastyIntegration(options?)`
383
+
384
+ Astro integration factory. Registers middleware and optionally injects client hydration.
385
+
386
+ | Option | Type | Default | Description |
387
+ |---|---|---|---|
388
+ | `islands` | `boolean` | `true` | When `true`, injects client hydration script and enables `transferCache`. When `false`, no client JS is shipped. |
389
+
327
390
  ### `tastyMiddleware(options?)`
328
391
 
329
- Astro middleware factory. Options:
392
+ Astro middleware factory. Use for manual middleware composition.
330
393
 
331
394
  | Option | Type | Default | Description |
332
395
  |---|---|---|---|
@@ -338,7 +401,7 @@ Pre-populate the client injector cache. When called without arguments, reads fro
338
401
 
339
402
  ### `runWithCollector(collector, fn)`
340
403
 
341
- Run a function with a `ServerStyleCollector` bound to the current async context via `AsyncLocalStorage`. All `useStyles()` calls within `fn` (and async continuations) will find this collector.
404
+ Run a function with a `ServerStyleCollector` bound to the current async context via `AsyncLocalStorage`. All style function calls within `fn` (and async continuations) — including `computeStyles()`, `useStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, and `useCounterStyle()` — will find this collector.
342
405
 
343
406
  ---
344
407
 
@@ -346,11 +409,11 @@ Run a function with a `ServerStyleCollector` bound to the current async context
346
409
 
347
410
  ### Styles flash on page load (FOUC)
348
411
 
349
- The `TastyRegistry` or `tastyMiddleware` is missing. Ensure your layout wraps the app with `TastyRegistry` (Next.js) or the middleware is registered (Astro).
412
+ The `TastyRegistry` or `tastyIntegration` is missing. Ensure your layout wraps the app with `TastyRegistry` (Next.js) or that `tastyIntegration()` is in your Astro config (or `tastyMiddleware()` is registered manually).
350
413
 
351
414
  ### Hydration mismatch warnings
352
415
 
353
- Class names are deterministic for the same render order. If you see mismatches, ensure `hydrateTastyCache()` runs before React hydration. For Next.js, this is automatic. For Astro, import `@tenphi/tasty/ssr/astro` in your island components. For custom setups, call `hydrateTastyCache()` before `hydrateRoot()`.
416
+ Class names are deterministic for the same render order. If you see mismatches, ensure `hydrateTastyCache()` runs before React hydration. For Next.js, this is automatic. For Astro with `tastyIntegration()`, this is also automatic. For manual Astro middleware setups, import `@tenphi/tasty/ssr/astro-client` in your island components. For custom setups, call `hydrateTastyCache()` before `hydrateRoot()`.
354
417
 
355
418
  ### Styles duplicated after hydration
356
419
 
package/docs/styles.md CHANGED
@@ -104,6 +104,8 @@ Element padding with directional modifiers and multi-group support. Use **comma-
104
104
 
105
105
  **Direction modifiers:** `top`, `right`, `bottom`, `left`
106
106
 
107
+ **Output modifier:** `longhand` — forces output as individual CSS longhand properties (`padding-top`, `padding-right`, `padding-bottom`, `padding-left`) instead of the `padding` shorthand. Useful when children need to selectively inherit individual directions.
108
+
107
109
  | Value | Effect |
108
110
  |-------|--------|
109
111
  | `"2x"` | All sides `2x` |
@@ -112,6 +114,7 @@ Element padding with directional modifiers and multi-group support. Use **comma-
112
114
  | `"1x left right"` | Left and right `1x`, top/bottom `0` |
113
115
  | `"1x, 2x top"` | All sides `1x`, then top overridden to `2x` |
114
116
  | `"1x, 2x top bottom"` | Left/right `1x`, top/bottom `2x` |
117
+ | `"2x longhand"` | All sides `2x`, output as 4 individual `padding-*` properties |
115
118
  | `true` | All sides `1x` |
116
119
  | Number | Converted to `px` |
117
120
 
@@ -129,6 +132,8 @@ Element margin. Same syntax, modifiers, and multi-group support as `padding`.
129
132
 
130
133
  **Direction modifiers:** `top`, `right`, `bottom`, `left`
131
134
 
135
+ **Output modifier:** `longhand` — forces output as individual CSS longhand properties (`margin-top`, etc.) instead of the `margin` shorthand.
136
+
132
137
  | Value | Effect |
133
138
  |-------|--------|
134
139
  | `"2x"` | All sides `2x` |
@@ -146,37 +151,39 @@ Individual props `marginTop`, `marginRight`, `marginBottom`, `marginLeft`, `marg
146
151
 
147
152
  ### `width`
148
153
 
149
- Element width with min/max control.
154
+ Element width with min/max control. One, two, or three values set `min-width`, `width`, and `max-width` together.
155
+
156
+ **Positional syntax:**
150
157
 
151
- **Syntax:** `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
158
+ | Value | min-width | width | max-width |
159
+ |-------|-----------|-------|-----------|
160
+ | `"10x"` | initial | `10x` | initial |
161
+ | `"1x 10x"` | `1x` | auto | `10x` |
162
+ | `"1x 5x 10x"` | `1x` | `5x` | `10x` |
163
+ | `"0 100% 800px"` | `0` | `100%` | `800px` |
164
+ | `"initial 100% 1400px"` | initial | `100%` | `1400px` |
152
165
 
153
- **Modifiers:** `min`, `max`, `fixed`
166
+ **Modifier syntax:**
167
+
168
+ | Value | min-width | width | max-width |
169
+ |-------|-----------|-------|-----------|
170
+ | `"min 2x"` | `2x` | auto | initial |
171
+ | `"max 100%"` | initial | auto | `100%` |
172
+ | `"fixed 200px"` | `200px` | `200px` | `200px` |
154
173
 
155
174
  **Keywords:** `stretch`, `max-content`, `min-content`, `fit-content`
156
175
 
157
176
  | Value | Effect |
158
177
  |-------|--------|
159
- | `"10x"` | Width `10x`, min `initial`, max `initial` |
160
- | `"1x 10x"` | Width `auto`, min `1x`, max `10x` |
161
- | `"1x 5x 10x"` | Min `1x`, width `5x`, max `10x` |
162
- | `"min 2x"` | Min-width `2x`, width `auto`, max `initial` |
163
- | `"max 100%"` | Max-width `100%`, width `auto`, min `initial` |
164
- | `"fixed 200px"` | Min, width, and max all set to `200px` |
165
178
  | `"stretch"` | Fill available space (cross-browser) |
166
- | `true` | Width `auto`, min `initial`, max `initial` |
179
+ | `true` | Reset to `auto` / `initial` / `initial` |
167
180
  | Number | Converted to `px` |
168
181
 
169
182
  Separate `minWidth` and `maxWidth` props are supported and override values from the `width` syntax.
170
183
 
171
184
  ### `height`
172
185
 
173
- Element height. Same syntax and modifiers as `width`.
174
-
175
- **Syntax:** `[value]` | `[min max]` | `[min value max]` | `[modifier value]`
176
-
177
- **Modifiers:** `min`, `max`, `fixed`
178
-
179
- **Keywords:** `max-content`, `min-content`, `fit-content`
186
+ Element height. Same syntax, modifiers, and positional patterns as `width`.
180
187
 
181
188
  Separate `minHeight` and `maxHeight` props are supported and override values from the `height` syntax.
182
189
 
@@ -188,12 +195,15 @@ Positioning offsets with directional modifiers and multi-group support. Same dir
188
195
 
189
196
  **Direction modifiers:** `top`, `right`, `bottom`, `left`
190
197
 
198
+ **Output modifier:** `longhand` — forces output as individual CSS properties (`top`, `right`, `bottom`, `left`) instead of the `inset` shorthand.
199
+
191
200
  | Value | Effect |
192
201
  |-------|--------|
193
202
  | `"0"` | All sides `0` |
194
203
  | `"2x top"` | Top `2x`, right/bottom/left `auto` |
195
204
  | `"1x left right"` | Left and right `1x`, top/bottom `auto` |
196
205
  | `"0, 2x top"` | All sides `0`, then top overridden to `2x` |
206
+ | `"0 longhand"` | All sides `0`, output as individual `top`/`right`/`bottom`/`left` |
197
207
  | `true` | All sides `0` |
198
208
 
199
209
  Later comma-separated groups override earlier groups for conflicting directions.
@@ -252,7 +262,7 @@ Text color with design token support.
252
262
  | `"(#primary, #secondary)"` | Fallback: use `#primary`, fall back to `#secondary` |
253
263
  | `true` | `currentColor` |
254
264
 
255
- When set to a named color token, also sets `$current-color` and `$current-color-rgb` custom properties for downstream use.
265
+ When set to a named color token, also sets `$current-color` and `$current-color-{colorSpace}` custom properties for downstream use (suffix depends on the configured `colorSpace`, default `oklch`).
256
266
 
257
267
  ### `svgFill`
258
268
 
@@ -279,12 +289,15 @@ Border shorthand with directional and multi-group support. Use **comma-separated
279
289
 
280
290
  **Direction modifiers:** `top`, `right`, `bottom`, `left`
281
291
 
292
+ **Output modifier:** `longhand` — forces output as individual CSS properties (`border-top`, `border-right`, `border-bottom`, `border-left`) instead of the `border` shorthand. Useful when children need to selectively inherit individual sides.
293
+
282
294
  | Value | Effect |
283
295
  |-------|--------|
284
296
  | `true` | Default border (`1bw solid #border`) on all sides |
285
297
  | `"2bw dashed #purple"` | All sides: 2bw dashed purple |
286
298
  | `"2bw top"` | Top only: 2bw solid `#border`, others: 0 |
287
299
  | `"dotted #danger left right"` | Left/right: 1bw dotted `#danger`, others: 0 |
300
+ | `"1bw longhand"` | All sides: 1bw solid `#border`, output as 4 individual `border-*` properties |
288
301
  | `"1bw #red, 2bw #blue top"` | All sides: 1bw solid `#red`, top overridden to 2bw solid `#blue` |
289
302
  | `"1bw, dashed top bottom, #purple left right"` | Base: 1bw solid `#border`, top/bottom: 1bw dashed `#border`, left/right: 1bw solid `#purple` |
290
303
 
@@ -304,9 +317,12 @@ Border radius with shape presets and directional modifiers.
304
317
  | `"ellipse"` | Circular (`50%`) |
305
318
  | `"leaf"` | Asymmetric: sharp, round, sharp, round |
306
319
  | `"backleaf"` | Asymmetric: round, sharp, round, sharp |
320
+ | `"inherit"` | Inherit border-radius from parent |
307
321
 
308
322
  **Direction modifiers:** `top`, `right`, `bottom`, `left` — rounds only the specified corners.
309
323
 
324
+ **Output modifier:** `longhand` — forces output as individual CSS longhand properties (`border-top-left-radius`, `border-top-right-radius`, `border-bottom-right-radius`, `border-bottom-left-radius`) instead of the `border-radius` shorthand. Useful when children need to selectively inherit individual corners via `radius: 'inherit left'`.
325
+
310
326
  | Value | Effect |
311
327
  |-------|--------|
312
328
  | `"2r"` | All corners `2r` |
@@ -315,6 +331,9 @@ Border radius with shape presets and directional modifiers.
315
331
  | `"1r top"` | Top-left and top-right `1r`, bottom-left and bottom-right `0` |
316
332
  | `"leaf"` | Alternating sharp/round corners (top-left `0`, top-right `1r`, bottom-right `0`, bottom-left `1r`) |
317
333
  | `"backleaf"` | Inverse leaf (top-left `1r`, top-right `0`, bottom-right `1r`, bottom-left `0`) |
334
+ | `"1r longhand"` | All corners `1r`, output as 4 individual `border-*-radius` properties |
335
+ | `"inherit"` | All corners inherit from parent (`border-radius: inherit`) |
336
+ | `"inherit right"` | Right corners inherit from parent (uses longhand properties) |
318
337
 
319
338
  ### `outline`
320
339
 
@@ -344,7 +363,7 @@ Box shadow. Supports multiple shadows comma-separated.
344
363
 
345
364
  | Value | Effect |
346
365
  |-------|--------|
347
- | `true` | Default shadow (from `$shadow` token) |
366
+ | `true` | Default shadow (uses `var(--shadow)` — define a `$shadow` token in your design system) |
348
367
  | `"1x .5x .5x #dark.50"` | Custom shadow with Tasty units/colors |
349
368
  | `"0 1x 2x #dark.20"` | Standard shadow |
350
369
  | `"inset 0 1x 2x #dark.10"` | Inset shadow |
@@ -359,24 +378,27 @@ Multiple shadows: `shadow="1x 1x 2x #dark.20, inset 0 0 4x #dark.10"`
359
378
 
360
379
  Typography preset that sets font-size, line-height, letter-spacing, font-weight, font-style, and text-transform from named design tokens.
361
380
 
362
- **Syntax:** `[name] [modifiers...]`
381
+ **Syntax:** `name`, `name / modifier`, or `modifier` (shorthand)
363
382
 
364
383
  Preset names are project-specific (e.g. `h1`–`h6`, `t1`–`t4`, `p1`–`p4`). Register them for autocomplete by augmenting `TastyPresetNames`.
365
384
 
385
+ Use `/` to separate the preset name from a modifier. When a modifier is used alone (without a name), the preset name defaults to `inherit`.
386
+
366
387
  **Modifiers:**
367
388
 
368
389
  | Modifier | Effect |
369
390
  |----------|--------|
370
- | `strong` | Sets `font-weight` to bold (from `$bold-font-weight` token) |
391
+ | `strong` (or `bold`) | Sets `font-weight` to bold (from `$bold-font-weight` token) |
371
392
  | `italic` | Sets `font-style: italic` |
372
393
  | `icon` | Sets font-size and line-height to icon size |
373
394
  | `tight` | Sets line-height equal to font-size |
374
395
 
375
396
  ```jsx
376
- preset="h1" // heading 1
377
- preset="h2 strong" // bold heading 2
378
- preset="t3 italic" // italic text 3
379
- preset="t2 tight" // text 2 with tight line-height
397
+ preset="h1" // heading 1
398
+ preset="h2 / strong" // bold heading 2
399
+ preset="t3 / italic" // italic text 3
400
+ preset="t2 / tight" // text 2 with tight line-height
401
+ preset="bold" // inherit preset with bold (shorthand for "inherit / bold")
380
402
  ```
381
403
 
382
404
  Individual typography props (`fontSize`, `lineHeight`, `letterSpacing`, `fontWeight`, `fontStyle`, `textTransform`) can be used alongside `preset` to override specific values, but using `preset` alone is recommended.
@@ -511,7 +533,7 @@ Scrollbar styling using CSS standard properties (`scrollbar-width`, `scrollbar-c
511
533
 
512
534
  **Colors:** Up to 2 color values for thumb and track (optional), applied via `scrollbar-color`.
513
535
 
514
- **Defaults:** When no colors are specified, the thumb color comes from the `#scrollbar-thumb` token (`#text.5`) and the track color from the `#scrollbar-track` token (`#dark-bg`). These tokens are provided by the base token set. If the base tokens are not loaded, the track falls back to `transparent` via a CSS fallback, while the thumb has no CSS-level fallback — the browser treats the entire `scrollbar-color` declaration as invalid and reverts to the platform-default scrollbar appearance.
536
+ **Defaults:** When no colors are specified, the thumb color comes from `var(--scrollbar-thumb-color)` and the track color from `var(--scrollbar-track-color, transparent)`. These are not built-in — your design system should define `#scrollbar-thumb` and `#scrollbar-track` tokens (e.g. `'#text.5'` and `'#dark-bg'`). If neither token is defined, the track falls back to `transparent` via a CSS fallback, while the thumb has no CSS-level fallback — the browser treats the entire `scrollbar-color` declaration as invalid and reverts to the platform-default scrollbar appearance.
515
537
 
516
538
  **Note:** `none` takes precedence over all other modifiers and colors. Combining `none` with other tokens (e.g., `"none always #red"`) produces a warning, and only `scrollbar-width: none` is applied.
517
539