@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
@@ -1,54 +1,208 @@
1
- # Usage Guide
1
+ # Style DSL Reference
2
2
 
3
- `tasty` is a powerful utility for creating styled React components with a declarative, design-system-integrated API. It combines the flexibility of CSS-in-JS with the consistency of a design system, enabling you to build maintainable, themeable components quickly.
3
+ This is the Tasty style language reference — the value syntax, state mappings, tokens, units, extending semantics, and special declarations that apply to both runtime `tasty()` and build-time `tastyStatic()`.
4
4
 
5
- For global configuration (tokens, recipes, custom units, handlers), see **[Configuration](configuration.md)**.
5
+ For the runtime React API (`tasty()`, hooks, component props), see [Runtime API](runtime.md). For all enhanced style properties, see [Style Properties](styles.md). For global configuration, see [Configuration](configuration.md).
6
6
 
7
7
  ---
8
8
 
9
- ## Quick Start
9
+ ## Dictionary
10
+
11
+ ### Style Mapping
12
+
13
+ Object where keys represent states and values are the styles to apply:
14
+
15
+ ```jsx
16
+ fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
17
+ ```
18
+
19
+ #### State Key Types
20
+
21
+ | Syntax | Example | Generated CSS |
22
+ |--------|---------|---------------|
23
+ | Boolean modifier | `hovered` | `[data-hovered]` |
24
+ | Value modifier | `theme=danger` | `[data-theme="danger"]` |
25
+ | Pseudo-class | `:hover` | `:hover` |
26
+ | Class selector | `.active` | `.active` |
27
+ | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
28
+ | Combined (AND) | `hovered & .active` | `[data-hovered].active` |
29
+ | Combined (OR) | `hovered \| focused` | `[data-hovered], [data-focused]` |
30
+ | Negated (NOT) | `!disabled` | `:not([data-disabled])` |
31
+ | Exclusive (XOR) | `hovered ^ focused` | `[data-hovered]:not([data-focused]), :not([data-hovered])[data-focused]` |
32
+
33
+ Operator precedence (highest to lowest): `!` (NOT) > `^` (XOR) > `|` (OR) > `&` (AND). Use parentheses to override: `hovered & (pressed ^ focused)`.
34
+
35
+ `^` (XOR) means "exactly one of" — `A ^ B` expands to `(A & !B) | (!A & B)`. This is useful for mutually exclusive states where exactly one should be active:
36
+
37
+ ```jsx
38
+ fill: {
39
+ '': '#surface',
40
+ 'hovered ^ focused': '#accent', // active when hovered OR focused, but not both
41
+ }
42
+ ```
43
+
44
+ ### Sub-element
45
+
46
+ Element styled using a capitalized key. Identified by `data-element` attribute:
47
+
48
+ ```jsx
49
+ styles: { Title: { preset: 'h3' } }
50
+ // Targets: <div data-element="Title">
51
+ ```
52
+
53
+ #### Selector Affix (`$`)
54
+
55
+ Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles:
56
+
57
+ | Pattern | Result | Description |
58
+ |---------|--------|-------------|
59
+ | *(none)* | ` [el]` | Descendant (default) |
60
+ | `>` | `> [el]` | Direct child |
61
+ | `>Body>Row>` | `> [Body] > [Row] > [el]` | Chained elements |
62
+ | `h1` | ` h1` | Tag selector (no key injection) |
63
+ | `h1 >` | ` h1 > [el]` | Key is direct child of tag |
64
+ | `h1 *` | ` h1 *` | Any descendant of tag |
65
+ | `*` | ` *` | All descendants |
66
+ | `::before` | `::before` | Root pseudo (no key) |
67
+ | `@::before` | `[el]::before` | Pseudo on the sub-element |
68
+ | `>@:hover` | `> [el]:hover` | Pseudo-class on the sub-element |
69
+ | `>@.active` | `> [el].active` | Class on the sub-element |
70
+
71
+ Rules for key injection (`[data-element="..."]`):
72
+
73
+ - **Trailing combinator** (`>`, `+`, `~`) — key is injected after it
74
+ - **Uppercase element name** (`Body`, `Row`) — key is injected as descendant
75
+ - **HTML tag** (`h1`, `a`, `span`) — no key injection; the tag IS the selector
76
+ - **Universal selector** (`*`) — no key injection
77
+ - **Pseudo / class / attribute** — no key injection
78
+
79
+ The `@` placeholder marks exactly where `[data-element="..."]` is injected, allowing you to attach pseudo-classes, pseudo-elements, or class selectors directly to the sub-element instead of the root:
80
+
81
+ ```jsx
82
+ const List = tasty({
83
+ styles: {
84
+ Item: {
85
+ $: '>@:last-child',
86
+ border: 'none',
87
+ },
88
+ },
89
+ });
90
+ // → .t0 > [data-element="Item"]:last-child { border: none }
91
+ ```
92
+
93
+ ### Color Token
94
+
95
+ Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
96
+
97
+ ```jsx
98
+ fill: '#purple.5' // → var(--purple-color) with 50% opacity
99
+ ```
100
+
101
+ ### Modifier
102
+
103
+ State value via `mods` prop that generates `data-*` attributes:
104
+
105
+ ```jsx
106
+ mods={{ hovered: true, theme: 'danger' }}
107
+ // → data-hovered="" data-theme="danger"
108
+ ```
109
+
110
+ Modifiers can also be exposed as top-level component props via `modProps` — see [Runtime — Mod Props](runtime.md#mod-props).
111
+
112
+ ---
113
+
114
+ ## Color Tokens & Opacity
115
+
116
+ ```jsx
117
+ color: '#purple', // Full opacity
118
+ color: '#purple.5', // 50% opacity
119
+ color: '#purple.05', // 5% opacity
120
+ fill: '#current', // → currentcolor
121
+ fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
122
+ color: '(#primary, #secondary)', // Fallback syntax
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Built-in Units
128
+
129
+ | Unit | Description | Example | CSS Output |
130
+ |------|-------------|---------|------------|
131
+ | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
132
+ | `r` | Border radius | `1r` | `var(--radius)` |
133
+ | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
134
+ | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
135
+ | `ow` | Outline width | `1ow` | `var(--outline-width)` |
136
+ | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
137
+
138
+ You can register additional custom units via [`configure()`](configuration.md#options).
139
+
140
+ ---
141
+
142
+ ## Replace Tokens
10
143
 
11
- ### Creating Your First Component
144
+ Tokens defined via [`configure({ replaceTokens })`](configuration.md#replace-tokens-parse-time-substitution) are replaced at parse time and baked into the generated CSS:
12
145
 
13
146
  ```jsx
14
- import { tasty } from '@tenphi/tasty';
147
+ const Card = tasty({
148
+ styles: {
149
+ padding: '$card-padding',
150
+ fill: '#surface',
151
+ border: '1bw solid #accent',
152
+ },
153
+ });
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Recipes
15
159
 
16
- // Basic styled component
160
+ Apply predefined style bundles (defined via [`configure({ recipes })`](configuration.md#recipes)) using the `recipe` style property:
161
+
162
+ ```jsx
17
163
  const Card = tasty({
18
- as: 'div',
19
164
  styles: {
20
- padding: '4x',
21
- fill: '#white',
22
- border: true,
23
- radius: true,
165
+ recipe: 'card',
166
+ color: '#text',
24
167
  },
25
- styleProps: ['padding', 'fill'], // Expose styles as props
26
168
  });
27
169
 
28
- // Usage
29
- <Card>Hello World</Card>
30
- <Card padding="6x" fill="#gray.05">Custom Card</Card>
170
+ // Compose multiple recipes
171
+ const ElevatedCard = tasty({
172
+ styles: {
173
+ recipe: 'card elevated',
174
+ color: '#text',
175
+ },
176
+ });
31
177
  ```
32
178
 
33
- ### Extending Existing Components
179
+ **Post-merge recipes (`/` separator):**
34
180
 
35
- > **Best Practice:** Always prefer creating styled wrappers over using the `styles` prop directly.
181
+ Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
36
182
 
37
183
  ```jsx
38
- // Recommended
39
- const PrimaryButton = tasty(Button, {
184
+ const Input = tasty({
40
185
  styles: {
41
- fill: '#purple',
42
- color: '#white',
43
- padding: '2x 4x',
186
+ recipe: 'reset input / input-autofill',
187
+ preset: 't3',
44
188
  },
45
189
  });
190
+ ```
191
+
192
+ Use `none` to skip base recipes and apply only post recipes:
46
193
 
47
- // Avoid
48
- <Button styles={{ fill: '#purple' }}>Click me</Button>
194
+ ```jsx
195
+ const Custom = tasty({
196
+ styles: {
197
+ recipe: 'none / disabled',
198
+ padding: '2x',
199
+ },
200
+ });
49
201
  ```
50
202
 
51
- #### Extending vs. Replacing State Maps
203
+ ---
204
+
205
+ ## Extending vs. Replacing State Maps
52
206
 
53
207
  When a style property uses a state map, the merge behavior depends on whether the child provides a `''` (default) key:
54
208
 
@@ -102,7 +256,7 @@ fill: { pressed: null } // removes pressed from the result
102
256
  fill: { disabled: false } // tombstone — no CSS for disabled, blocks recipe too
103
257
  ```
104
258
 
105
- #### Resetting Properties with `null` and `false`
259
+ ### Resetting Properties with `null` and `false`
106
260
 
107
261
  ```jsx
108
262
  const SimpleButton = tasty(Button, {
@@ -119,229 +273,178 @@ const SimpleButton = tasty(Button, {
119
273
  | `null` | Intentional unset — parent discarded | Yes |
120
274
  | `false` | Tombstone — blocks everything | No |
121
275
 
122
- ### Essential Patterns
123
-
124
- ```jsx
125
- // State-based styling
126
- const InteractiveCard = tasty({
127
- styles: {
128
- fill: {
129
- '': '#white',
130
- 'hovered': '#gray.05',
131
- 'pressed': '#gray.10',
132
- },
133
- },
134
- });
135
-
136
- // Using design tokens
137
- const TokenCard = tasty({
138
- styles: {
139
- fill: '#surface', // Color token
140
- color: '#text', // Color token
141
- padding: '2x', // Custom unit (gap × 2)
142
- radius: '1r', // Custom unit (border-radius)
143
- border: '1bw solid #border', // Border width token
144
- },
145
- });
146
- ```
147
-
148
276
  ---
149
277
 
150
- ## Configuration
151
-
152
- For tokens, recipes, custom units, style handlers, and other global settings, see **[Configuration](configuration.md)**.
278
+ ## Advanced States (`@` prefix)
153
279
 
154
- ---
280
+ | Prefix | Purpose | Example |
281
+ |--------|---------|---------|
282
+ | `@media` | Media queries | `@media(w < 768px)` |
283
+ | `@(...)` | Container queries | `@(panel, w >= 300px)` |
284
+ | `@supports` | Feature/selector support | `@supports(display: grid)` |
285
+ | `@root` | Root element states | `@root(schema=dark)` |
286
+ | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
287
+ | `@own` | Sub-element's own state | `@own(hovered)` |
288
+ | `@starting` | Entry animation | `@starting` |
289
+ | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
290
+ | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
291
+ | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
292
+ | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
155
293
 
156
- ## Dictionary
294
+ ### `@media(...)` — Media Queries
157
295
 
158
- ### Style Mapping
296
+ Media queries support dimension shorthands and custom unit expansion:
159
297
 
160
- Object where keys represent states and values are the styles to apply:
298
+ | Shorthand | Expands to |
299
+ |-----------|------------|
300
+ | `w` | `width` |
301
+ | `h` | `height` |
161
302
 
162
303
  ```jsx
163
- fill: { '': '#white', hovered: '#gray.05', 'theme=danger': '#red' }
304
+ fill: {
305
+ '': '#surface',
306
+ '@media(w < 768px)': '#surface-mobile',
307
+ '@media(600px <= w < 1200px)': '#surface-tablet',
308
+ '@media(prefers-color-scheme: dark)': '#surface-dark',
309
+ }
164
310
  ```
165
311
 
166
- #### State Key Types
167
-
168
- | Syntax | Example | Generated CSS |
169
- |--------|---------|---------------|
170
- | Boolean modifier | `hovered` | `[data-hovered]` |
171
- | Value modifier | `theme=danger` | `[data-theme="danger"]` |
172
- | Pseudo-class | `:hover` | `:hover` |
173
- | Class selector | `.active` | `.active` |
174
- | Attribute selector | `[aria-expanded="true"]` | `[aria-expanded="true"]` |
175
- | Combined | `hovered & .active` | `[data-hovered].active` |
312
+ | Tasty syntax | CSS output |
313
+ |--------------|------------|
314
+ | `@media(w < 768px)` | `@media (width < 768px)` |
315
+ | `@media(600px <= w < 1200px)` | `@media (600px <= width < 1200px)` |
316
+ | `@media:print` | `@media print` |
317
+ | `@media:screen` | `@media screen` |
318
+ | `@media(prefers-color-scheme: dark)` | `@media (prefers-color-scheme: dark)` |
319
+ | `@media(prefers-reduced-motion)` | `@media (prefers-reduced-motion)` |
176
320
 
177
- ### Sub-element
321
+ Custom units work inside media queries: `@media(w < 40x)` → `@media (width < calc(var(--gap) * 40))`.
178
322
 
179
- Element styled using a capitalized key. Identified by `data-element` attribute:
323
+ In practice, define state aliases via `configure({ states })` and use `@mobile` instead of writing the full query in every component.
180
324
 
181
- ```jsx
182
- styles: { Title: { preset: 'h3' } }
183
- // Targets: <div data-element="Title">
184
- ```
325
+ ### `@(...)` — Container Queries
185
326
 
186
- ### Color Token
327
+ Container queries use the syntax `@(name, condition)` for named containers or `@(condition)` for the nearest ancestor container. Dimension shorthands (`w`, `h`, `is`, `bs`) are expanded the same way as `@media`.
187
328
 
188
- Named color prefixed with `#` that maps to CSS custom properties. Supports opacity with `.N` suffix:
329
+ | Shorthand | Expands to |
330
+ |-----------|------------|
331
+ | `w` | `width` |
332
+ | `h` | `height` |
333
+ | `is` | `inline-size` |
334
+ | `bs` | `block-size` |
189
335
 
190
336
  ```jsx
191
- fill: '#purple.5' // → var(--purple-color) with 50% opacity
337
+ const Panel = tasty({
338
+ styles: {
339
+ flow: {
340
+ '': 'column',
341
+ '@(layout, w >= 600px)': 'row',
342
+ },
343
+ },
344
+ });
192
345
  ```
193
346
 
194
- ### Modifier
347
+ | Tasty syntax | CSS output |
348
+ |--------------|------------|
349
+ | `@(layout, w < 600px)` | `@container layout (width < 600px)` |
350
+ | `@(w < 600px)` | `@container (width < 600px)` |
351
+ | `@(layout, $variant=danger)` | `@container layout style(--variant: "danger")` |
352
+ | `@(layout, $compact)` | `@container layout style(--compact)` |
353
+ | `@(scroll-state(stuck: top))` | `@container scroll-state(stuck: top)` |
354
+ | `@(nav, scroll-state(stuck: top))` | `@container nav scroll-state(stuck: top)` |
195
355
 
196
- State value via `mods` prop that generates `data-*` attributes:
356
+ Container style queries use `$prop` (boolean) or `$prop=value` syntax, which maps to CSS `style(--prop)` or `style(--prop: "value")`.
197
357
 
198
- ```jsx
199
- mods={{ hovered: true, theme: 'danger' }}
200
- // → data-hovered="" data-theme="danger"
201
- ```
202
-
203
- ---
358
+ ### `@supports(...)` — Feature Queries
204
359
 
205
- ## Core Concepts
360
+ Feature queries test CSS property support. Use `$` as the first argument to test selector support:
206
361
 
207
- ### Component Creation
362
+ | Tasty syntax | CSS output |
363
+ |--------------|------------|
364
+ | `@supports(display: grid)` | `@supports (display: grid)` |
365
+ | `@supports($, :has(*))` | `@supports selector(:has(*))` |
366
+ | `!@supports(display: grid)` | `@supports (not (display: grid))` |
208
367
 
209
368
  ```jsx
210
- // Create new element
211
- const Box = tasty({
212
- as: 'div',
213
- styles: { /* styles */ },
214
- });
215
-
216
- // Extend existing component
217
- const StyledButton = tasty(Button, {
218
- styles: { /* additional styles */ },
219
- });
369
+ display: {
370
+ '': 'flex',
371
+ '@supports(display: grid)': 'grid',
372
+ }
220
373
  ```
221
374
 
222
- ### Style Props
375
+ ### `@root(...)` — Root Element States
223
376
 
224
- Use `styleProps` to expose style properties as direct component props:
377
+ Root states generate selectors on the `:root` element. They are useful for theme modes, feature flags, and other page-level conditions:
225
378
 
226
- ```jsx
227
- const FlexibleBox = tasty({
228
- as: 'div',
229
- styles: {
230
- display: 'flex',
231
- padding: '2x',
232
- },
233
- styleProps: ['gap', 'align', 'placeContent', 'fill'],
234
- });
235
-
236
- <FlexibleBox gap="2x" align="center" fill="#surface">
237
- Content
238
- </FlexibleBox>
239
- ```
240
-
241
- ### Color Tokens & Opacity
379
+ These docs use `data-schema` in examples. If your app standardizes on a different root attribute, keep the same pattern and swap the attribute name consistently in your aliases and selectors.
242
380
 
243
381
  ```jsx
244
- color: '#purple', // Full opacity
245
- color: '#purple.5', // 50% opacity
246
- color: '#purple.05', // 5% opacity
247
- fill: '#current', // → currentcolor
248
- fill: '#current.5', // → color-mix(in oklab, currentcolor 50%, transparent)
249
- color: '(#primary, #secondary)', // Fallback syntax
382
+ color: {
383
+ '': '#text',
384
+ '@root(schema=dark)': '#text-on-dark',
385
+ '@root(.premium-user)': '#gold',
386
+ }
250
387
  ```
251
388
 
252
- ### Built-in Units
253
-
254
- | Unit | Description | Example | CSS Output |
255
- |------|-------------|---------|------------|
256
- | `x` | Gap multiplier | `2x` | `calc(var(--gap) * 2)` |
257
- | `r` | Border radius | `1r` | `var(--radius)` |
258
- | `cr` | Card border radius | `1cr` | `var(--card-radius)` |
259
- | `bw` | Border width | `2bw` | `calc(var(--border-width) * 2)` |
260
- | `ow` | Outline width | `1ow` | `var(--outline-width)` |
261
- | `fs` | Font size | `1fs` | `var(--font-size)` |
262
- | `lh` | Line height | `1lh` | `var(--line-height)` |
263
- | `sf` | Stable fraction | `1sf` | `minmax(0, 1fr)` |
264
-
265
- You can register additional custom units via [`configure()`](configuration.md#options).
266
-
267
- ### Predefined Tokens
389
+ | Tasty syntax | CSS selector |
390
+ |--------------|-------------|
391
+ | `@root(schema=dark)` | `:root[data-schema="dark"]` |
392
+ | `@root(hovered)` | `:root[data-hovered]` |
393
+ | `@root(.premium-user)` | `:root.premium-user` |
394
+ | `@root([lang="en"])` | `:root[lang="en"]` |
395
+ | `!@root(schema=dark)` | `:root:not([data-schema="dark"])` |
268
396
 
269
- Tokens defined via [`configure({ tokens })`](configuration.md#predefined-tokens) are replaced at parse time and baked into the generated CSS:
397
+ Root conditions are prepended to the component selector: `:root[data-schema="dark"] .t0.t0 { ... }`.
270
398
 
271
- ```jsx
272
- const Card = tasty({
273
- styles: {
274
- padding: '$card-padding',
275
- fill: '#surface',
276
- border: '1bw solid #accent',
277
- },
278
- });
279
- ```
399
+ ### `@own(...)` — Sub-element's Own State
280
400
 
281
- ### Recipes
282
-
283
- Apply predefined style bundles (defined via [`configure({ recipes })`](configuration.md#recipes)) using the `recipe` style property:
401
+ By default, state keys in sub-element styles refer to the root component's state context. Use `@own(...)` when the sub-element should react to its own state:
284
402
 
285
403
  ```jsx
286
- const Card = tasty({
404
+ const Nav = tasty({
287
405
  styles: {
288
- recipe: 'card',
289
- color: '#text',
290
- },
291
- });
292
-
293
- // Compose multiple recipes
294
- const ElevatedCard = tasty({
295
- styles: {
296
- recipe: 'card elevated',
297
- color: '#text',
406
+ NavItem: {
407
+ color: {
408
+ '': '#text',
409
+ '@own(:hover)': '#primary',
410
+ '@own(:focus-visible)': '#primary',
411
+ 'selected': '#primary', // root-level modifier
412
+ },
413
+ },
298
414
  },
415
+ elements: { NavItem: 'a' },
299
416
  });
300
417
  ```
301
418
 
302
- **Post-merge recipes (`/` separator):**
419
+ | Tasty syntax (inside sub-element) | CSS output |
420
+ |-----------------------------------|------------|
421
+ | `@own(:hover)` | `:hover` on the sub-element selector |
422
+ | `@own(hovered)` | `[data-hovered]` on the sub-element selector |
423
+ | `@own(theme=dark)` | `[data-theme="dark"]` on the sub-element selector |
303
424
 
304
- Recipes listed after `/` are applied *after* component styles using `mergeStyles`:
425
+ `@own()` is only valid inside sub-element styles. Using it on root styles emits a warning and is treated as a regular modifier.
305
426
 
306
- ```jsx
307
- const Input = tasty({
308
- styles: {
309
- recipe: 'reset input / input-autofill',
310
- preset: 't3',
311
- },
312
- });
313
- ```
427
+ ### `@starting` — Entry Animation
314
428
 
315
- Use `none` to skip base recipes and apply only post recipes:
429
+ Wraps the rule in `@starting-style`, enabling CSS entry animations for elements as they appear in the DOM:
316
430
 
317
431
  ```jsx
318
- const Custom = tasty({
432
+ const FadeIn = tasty({
319
433
  styles: {
320
- recipe: 'none / disabled',
321
- padding: '2x',
434
+ opacity: { '': '1', '@starting': '0' },
435
+ transform: { '': 'scale(1)', '@starting': 'scale(0.95)' },
436
+ transition: 'opacity 0.3s, translate 0.3s',
322
437
  },
323
438
  });
324
439
  ```
325
440
 
326
- ### Advanced States (`@` prefix)
327
-
328
- | Prefix | Purpose | Example |
329
- |--------|---------|---------|
330
- | `@media` | Media queries | `@media(w < 768px)` |
331
- | `@(...)` | Container queries | `@(panel, w >= 300px)` |
332
- | `@supports` | Feature/selector support | `@supports(display: grid)` |
333
- | `@root` | Root element states | `@root(theme=dark)` |
334
- | `@parent` | Parent/ancestor element states | `@parent(hovered)` |
335
- | `@own` | Sub-element's own state | `@own(hovered)` |
336
- | `@starting` | Entry animation | `@starting` |
337
- | `:is()` | CSS `:is()` structural pseudo-class | `:is(fieldset > label)` |
338
- | `:has()` | CSS `:has()` relational pseudo-class | `:has(> Icon)` |
339
- | `:not()` | CSS `:not()` negation (prefer `!:is()`) | `:not(:first-child)` |
340
- | `:where()` | CSS `:where()` (zero specificity) | `:where(Section)` |
441
+ | Tasty syntax | CSS output |
442
+ |--------------|------------|
443
+ | `@starting` | `@starting-style { .t0.t0 { ... } }` |
341
444
 
342
- #### `@parent(...)` — Parent Element States
445
+ ### `@parent(...)` — Parent Element States
343
446
 
344
- Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`) is supported inside `@parent()`.
447
+ Style based on ancestor element attributes. Uses `:is([selector] *)` / `:not([selector] *)` for symmetric, composable parent checks. Boolean logic (`&`, `|`, `!`, `^`) is supported inside `@parent()`.
345
448
 
346
449
  ```jsx
347
450
  const Highlight = tasty({
@@ -381,7 +484,7 @@ const Card = tasty({
381
484
  // → .t0.t0:is([data-hovered] *) [data-element="Label"]
382
485
  ```
383
486
 
384
- #### `:is()`, `:has()` — CSS Structural Pseudo-classes
487
+ ### `:is()`, `:has()` — CSS Structural Pseudo-classes
385
488
 
386
489
  Use CSS structural pseudo-classes directly in state keys. Capitalized words become `[data-element="..."]` selectors; lowercase words are HTML tags. A trailing combinator (`>`, `+`, `~`) is auto-completed with `*`.
387
490
 
@@ -419,27 +522,22 @@ const Card = tasty({
419
522
  | `!:has(> Icon)` | `:not(:has(> [data-element="Icon"]))` | Negation (use `!`) |
420
523
  | `!:is(Panel)` | `:not([data-element="Panel"])` | Negation (use `!:is`) |
421
524
 
422
- Combine with other states using boolean logic:
525
+ Combine with other states using boolean logic (`&`, `|`, `!`, `^`):
423
526
 
424
527
  ```jsx
425
- ':has(> Icon) & hovered' // structural + data attribute
426
- '@parent(hovered) & :has(> Icon)' // parent check + structural
528
+ ':has(> Icon) & hovered' // AND: structural + data attribute
529
+ '@parent(hovered) & :has(> Icon)' // AND: parent check + structural
427
530
  ':has(> Icon) | :has(> Button)' // OR: either sub-element present
531
+ ':has(> Icon) ^ :has(> Button)' // XOR: exactly one present
428
532
  ```
429
533
 
430
534
  > **Nesting limit:** The state key parser supports up to 2 levels of nested parentheses inside `:is()`, `:has()`, `:not()`, and `:where()` — e.g. `:has(Input:not(:disabled))` works, but 3+ levels like `:has(:is(:not(:hover)))` will not be tokenized correctly. This covers virtually all practical use cases.
431
535
 
432
536
  ---
433
537
 
434
- ## Style Properties
538
+ ## Keyframes
435
539
 
436
- For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
437
-
438
- ---
439
-
440
- ## Advanced Features
441
-
442
- ### Keyframes
540
+ Define animations inline using the `@keyframes` key in styles:
443
541
 
444
542
  ```jsx
445
543
  const Pulse = tasty({
@@ -455,7 +553,9 @@ const Pulse = tasty({
455
553
  });
456
554
  ```
457
555
 
458
- ### Properties (`@property`)
556
+ ---
557
+
558
+ ## Properties (`@property`)
459
559
 
460
560
  CSS cannot transition or animate custom properties unless the browser knows their type. Tasty solves this automatically — when you assign a concrete value to a custom property, the type is inferred and a CSS `@property` rule is registered behind the scenes:
461
561
 
@@ -480,216 +580,109 @@ Use explicit `@properties` when you need non-default settings like `inherits: fa
480
580
  },
481
581
  ```
482
582
 
483
- ### Variants & Theming
484
-
485
- ```jsx
486
- const Button = tasty({
487
- styles: {
488
- padding: '2x 4x',
489
- border: true,
490
- },
491
- variants: {
492
- default: { fill: '#blue', color: '#white' },
493
- danger: { fill: '#red', color: '#white' },
494
- outline: { fill: 'transparent', color: '#blue', border: '1bw solid #blue' },
495
- },
496
- });
497
-
498
- <Button variant="danger">Delete</Button>
499
- ```
583
+ ---
500
584
 
501
- #### Extending Variants with Base State Maps
585
+ ## Font Face (`@fontFace`)
502
586
 
503
- When base `styles` contain an extend-mode state map (an object **without** a `''` key), it is applied **after** the variant merge. This lets you add or override states across all variants without repeating yourself:
587
+ Register custom fonts directly inside a `styles` object. Keys are font-family names, values are descriptor objects (or arrays of them for multiple weights/styles).
504
588
 
505
- ```jsx
506
- const Badge = tasty({
589
+ ```ts
590
+ const Heading = tasty({
507
591
  styles: {
508
- padding: '1x 2x',
509
- // No '' key → extend mode: appended to every variant's border
510
- border: {
511
- 'type=primary': '#clear',
512
- },
513
- },
514
- variants: {
515
- primary: {
516
- border: { '': '#white.2', pressed: '#primary-text', disabled: '#clear' },
517
- fill: { '': '#white #primary', hovered: '#white #primary-text' },
518
- },
519
- secondary: {
520
- border: { '': '#primary.15', pressed: '#primary.3' },
521
- fill: '#primary.10',
592
+ '@fontFace': {
593
+ 'Brand Sans': {
594
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
595
+ fontDisplay: 'swap',
596
+ },
522
597
  },
598
+ fontFamily: '"Brand Sans", sans-serif',
523
599
  },
524
600
  });
525
-
526
- // Both variants get 'type=primary': '#clear' appended to their border map
527
601
  ```
528
602
 
529
- Properties that are **not** extend-mode (simple values, state maps with `''`, `null`, `false`, selectors, sub-elements) merge with variants as before — the variant can fully replace them.
530
-
531
- ### Sub-element Styling
532
-
533
- Sub-elements are inner parts of a compound component, styled via capitalized keys in `styles` and identified by `data-element` attributes in the DOM.
534
-
535
- > **Best Practice:** Use the `elements` prop to declare sub-element components. This gives you typed, reusable sub-components (`Card.Title`, `Card.Content`) instead of manually writing `data-element` attributes.
536
-
537
- ```jsx
538
- const Card = tasty({
539
- styles: {
540
- padding: '4x',
541
- Title: { preset: 'h3', color: '#primary' },
542
- Content: { color: '#text' },
543
- },
544
- elements: {
545
- Title: 'h3',
546
- Content: 'div',
547
- },
548
- });
549
-
550
- // Sub-components automatically get data-element attributes
551
- <Card>
552
- <Card.Title>Card Title</Card.Title>
553
- <Card.Content>Card content</Card.Content>
554
- </Card>
555
- ```
603
+ ### Multiple weights
556
604
 
557
- Each entry in `elements` can be a tag name string or a config object:
605
+ Supply an array to register several variants of the same family:
558
606
 
559
- ```jsx
560
- elements: {
561
- Title: 'h3', // shorthand: tag name only
562
- Icon: { as: 'span', qa: 'card-icon' }, // full form: tag + QA attribute
607
+ ```ts
608
+ '@fontFace': {
609
+ 'Brand Sans': [
610
+ { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
611
+ { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
612
+ ],
563
613
  }
564
614
  ```
565
615
 
566
- The sub-components produced by `elements` support `mods`, `tokens`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component.
567
-
568
- If you don't need sub-components (e.g., the inner elements are already rendered by a third-party library), you can still style them by key alone — just omit `elements` and apply `data-element` manually:
569
-
570
- ```jsx
571
- const Card = tasty({
572
- styles: {
573
- padding: '4x',
574
- Title: { preset: 'h3', color: '#primary' },
575
- },
576
- });
616
+ ### Supported descriptors
577
617
 
578
- <Card>
579
- <div data-element="Title">Card Title</div>
580
- </Card>
581
- ```
618
+ | Descriptor | CSS property | Type |
619
+ |---|---|---|
620
+ | `src` (required) | `src` | `string` |
621
+ | `fontWeight` | `font-weight` | `string \| number` |
622
+ | `fontStyle` | `font-style` | `string` |
623
+ | `fontStretch` | `font-stretch` | `string` |
624
+ | `fontDisplay` | `font-display` | `'auto' \| 'block' \| 'swap' \| 'fallback' \| 'optional'` |
625
+ | `unicodeRange` | `unicode-range` | `string` |
626
+ | `ascentOverride` | `ascent-override` | `string` |
627
+ | `descentOverride` | `descent-override` | `string` |
628
+ | `lineGapOverride` | `line-gap-override` | `string` |
629
+ | `sizeAdjust` | `size-adjust` | `string` |
630
+ | `fontFeatureSettings` | `font-feature-settings` | `string` |
631
+ | `fontVariationSettings` | `font-variation-settings` | `string` |
582
632
 
583
- #### Selector Affix (`$`)
633
+ > Font-face rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@font-face`.
584
634
 
585
- Control how a sub-element selector attaches to the root selector using the `$` property inside the sub-element's styles:
635
+ ---
586
636
 
587
- | Pattern | Result | Description |
588
- |---------|--------|-------------|
589
- | *(none)* | ` [el]` | Descendant (default) |
590
- | `>` | `> [el]` | Direct child |
591
- | `>Body>Row>` | `> [Body] > [Row] > [el]` | Chained elements |
592
- | `::before` | `::before` | Root pseudo (no key) |
593
- | `@::before` | `[el]::before` | Pseudo on the sub-element |
594
- | `>@:hover` | `> [el]:hover` | Pseudo-class on the sub-element |
595
- | `>@.active` | `> [el].active` | Class on the sub-element |
637
+ ## Counter Style (`@counterStyle`)
596
638
 
597
- The `@` placeholder marks exactly where the `[data-element="..."]` selector is injected, allowing you to attach pseudo-classes, pseudo-elements, or class selectors directly to the sub-element instead of the root:
639
+ Define custom list markers via the CSS `@counter-style` at-rule. Keys are counter-style names, values are descriptor objects.
598
640
 
599
- ```jsx
600
- const List = tasty({
641
+ ```ts
642
+ const EmojiList = tasty({
643
+ tag: 'ol',
601
644
  styles: {
602
- Item: {
603
- $: '>@:last-child',
604
- border: 'none',
645
+ '@counterStyle': {
646
+ thumbs: {
647
+ system: 'cyclic',
648
+ symbols: '"👍"',
649
+ suffix: '" "',
650
+ },
605
651
  },
652
+ listStyleType: 'thumbs',
606
653
  },
607
654
  });
608
- // → .t0 > [data-element="Item"]:last-child { border: none }
609
655
  ```
610
656
 
611
- ---
612
-
613
- ## Hooks
614
-
615
- ### useStyles
657
+ ### Supported descriptors
616
658
 
617
- ```tsx
618
- import { useStyles } from '@tenphi/tasty';
659
+ | Descriptor | CSS property | Type |
660
+ |---|---|---|
661
+ | `system` (required) | `system` | `'cyclic' \| 'numeric' \| 'alphabetic' \| 'symbolic' \| 'additive' \| 'fixed' \| string` |
662
+ | `symbols` | `symbols` | `string` |
663
+ | `additiveSymbols` | `additive-symbols` | `string` |
664
+ | `prefix` | `prefix` | `string` |
665
+ | `suffix` | `suffix` | `string` |
666
+ | `negative` | `negative` | `string` |
667
+ | `range` | `range` | `string` |
668
+ | `pad` | `pad` | `string` |
669
+ | `fallback` | `fallback` | `string` |
670
+ | `speakAs` | `speak-as` | `string` |
619
671
 
620
- function MyComponent() {
621
- const { className } = useStyles({
622
- padding: '2x',
623
- fill: '#surface',
624
- radius: '1r',
625
- });
626
-
627
- return <div className={className}>Styled content</div>;
628
- }
629
- ```
630
-
631
- ### useGlobalStyles
632
-
633
- ```tsx
634
- import { useGlobalStyles } from '@tenphi/tasty';
635
-
636
- function ThemeStyles() {
637
- useGlobalStyles('.card', {
638
- padding: '4x',
639
- fill: '#surface',
640
- radius: '1r',
641
- });
642
-
643
- return null;
644
- }
645
- ```
646
-
647
- ### useRawCSS
648
-
649
- ```tsx
650
- import { useRawCSS } from '@tenphi/tasty';
651
-
652
- function GlobalReset() {
653
- useRawCSS(`
654
- body { margin: 0; padding: 0; }
655
- `);
656
-
657
- return null;
658
- }
659
- ```
660
-
661
- ### useMergeStyles
662
-
663
- ```tsx
664
- import { useMergeStyles } from '@tenphi/tasty';
665
-
666
- function MyTabs({ styles, tabListStyles, prefixStyles }) {
667
- const mergedStyles = useMergeStyles(styles, {
668
- TabList: tabListStyles,
669
- Prefix: prefixStyles,
670
- });
671
-
672
- return <TabsElement styles={mergedStyles} />;
673
- }
674
- ```
672
+ > Counter-style rules are permanent — they are injected once and never cleaned up, matching how browsers handle `@counter-style`.
675
673
 
676
674
  ---
677
675
 
678
- ## Best Practices
676
+ ## Style Properties
679
677
 
680
- ### Do's
678
+ For a complete reference of all enhanced style properties — syntax, values, modifiers, and recommendations — see **[Style Properties Reference](styles.md)**.
681
679
 
682
- - Use styled wrappers instead of `styles` prop directly
683
- - Use design tokens and custom units (`#text`, `2x`, `1r`)
684
- - Use semantic transition names (`theme 0.3s`)
685
- - Use `elements` prop to declare typed sub-components for compound components
686
- - Use `styleProps` for component APIs
687
- - Use `tokens` prop for dynamic values
680
+ ---
688
681
 
689
- ### Don'ts
682
+ ## Learn more
690
683
 
691
- - Don't use `styles` prop directly on components
692
- - Don't use raw CSS values when tokens exist
693
- - Don't use CSS property names when Tasty alternatives exist — see [recommended props](styles.md#recommended-props)
694
- - Don't change `styles` prop at runtime (use modifiers or tokens instead)
695
- - Don't use `style` prop for custom styling (only for third-party library integration)
684
+ - **[Runtime API](runtime.md)** — `tasty()` factory, component props, variants, sub-elements, style functions
685
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
686
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
687
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
688
+ - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin