@tenphi/tasty 0.0.0-snapshot.002b1b3

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 (82) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +637 -0
  3. package/dist/async-storage-B7_o6FKt.js +44 -0
  4. package/dist/async-storage-B7_o6FKt.js.map +1 -0
  5. package/dist/collector-LuU1vZ68.d.ts +98 -0
  6. package/dist/collector-MOYY2SOr.js +230 -0
  7. package/dist/collector-MOYY2SOr.js.map +1 -0
  8. package/dist/config-A237aY9H.js +10235 -0
  9. package/dist/config-A237aY9H.js.map +1 -0
  10. package/dist/config-vuCRkBWX.d.ts +884 -0
  11. package/dist/context-CkSg-kDT.js +24 -0
  12. package/dist/context-CkSg-kDT.js.map +1 -0
  13. package/dist/core/index.d.ts +5 -0
  14. package/dist/core/index.js +6 -0
  15. package/dist/core-BkKav78f.js +1592 -0
  16. package/dist/core-BkKav78f.js.map +1 -0
  17. package/dist/css-writer-Cos9tQRM.js +329 -0
  18. package/dist/css-writer-Cos9tQRM.js.map +1 -0
  19. package/dist/format-global-rules-Dbc_1tc3.js +22 -0
  20. package/dist/format-global-rules-Dbc_1tc3.js.map +1 -0
  21. package/dist/format-rules-C2oiTsEO.js +143 -0
  22. package/dist/format-rules-C2oiTsEO.js.map +1 -0
  23. package/dist/hydrate-miFzWIKR.js +45 -0
  24. package/dist/hydrate-miFzWIKR.js.map +1 -0
  25. package/dist/index-CJMXAAO5.d.ts +1602 -0
  26. package/dist/index-dUtwpOux.d.ts +1266 -0
  27. package/dist/index.d.ts +5 -0
  28. package/dist/index.js +732 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/keyframes-DDtNo_hl.js +587 -0
  31. package/dist/keyframes-DDtNo_hl.js.map +1 -0
  32. package/dist/merge-styles-CtDJMhpJ.d.ts +7 -0
  33. package/dist/merge-styles-D_HbBOlq.js +144 -0
  34. package/dist/merge-styles-D_HbBOlq.js.map +1 -0
  35. package/dist/resolve-recipes-B7-823LL.js +144 -0
  36. package/dist/resolve-recipes-B7-823LL.js.map +1 -0
  37. package/dist/ssr/astro-client.d.ts +1 -0
  38. package/dist/ssr/astro-client.js +19 -0
  39. package/dist/ssr/astro-client.js.map +1 -0
  40. package/dist/ssr/astro-middleware.d.ts +15 -0
  41. package/dist/ssr/astro-middleware.js +19 -0
  42. package/dist/ssr/astro-middleware.js.map +1 -0
  43. package/dist/ssr/astro.d.ts +97 -0
  44. package/dist/ssr/astro.js +149 -0
  45. package/dist/ssr/astro.js.map +1 -0
  46. package/dist/ssr/index.d.ts +44 -0
  47. package/dist/ssr/index.js +10 -0
  48. package/dist/ssr/index.js.map +1 -0
  49. package/dist/ssr/next.d.ts +46 -0
  50. package/dist/ssr/next.js +75 -0
  51. package/dist/ssr/next.js.map +1 -0
  52. package/dist/static/index.d.ts +91 -0
  53. package/dist/static/index.js +50 -0
  54. package/dist/static/index.js.map +1 -0
  55. package/dist/static/inject.d.ts +5 -0
  56. package/dist/static/inject.js +17 -0
  57. package/dist/static/inject.js.map +1 -0
  58. package/dist/zero/babel.d.ts +81 -0
  59. package/dist/zero/babel.js +466 -0
  60. package/dist/zero/babel.js.map +1 -0
  61. package/dist/zero/index.d.ts +67 -0
  62. package/dist/zero/index.js +2 -0
  63. package/dist/zero/next.d.ts +86 -0
  64. package/dist/zero/next.js +143 -0
  65. package/dist/zero/next.js.map +1 -0
  66. package/docs/README.md +31 -0
  67. package/docs/adoption.md +298 -0
  68. package/docs/comparison.md +419 -0
  69. package/docs/configuration.md +394 -0
  70. package/docs/debug.md +320 -0
  71. package/docs/design-system.md +436 -0
  72. package/docs/dsl.md +688 -0
  73. package/docs/getting-started.md +217 -0
  74. package/docs/injector.md +544 -0
  75. package/docs/methodology.md +616 -0
  76. package/docs/pipeline.md +673 -0
  77. package/docs/react-api.md +557 -0
  78. package/docs/ssr.md +442 -0
  79. package/docs/styles.md +596 -0
  80. package/docs/tasty-static.md +532 -0
  81. package/package.json +222 -0
  82. package/tasty.config.ts +15 -0
@@ -0,0 +1,557 @@
1
+ # React API
2
+
3
+ The React-specific `tasty()` component factory, component props, and style functions. All Tasty style functions — `tasty()` components, `useStyles()`, `useGlobalStyles()`, `useRawCSS()`, `useKeyframes()`, `useProperty()`, `useFontFace()`, and `useCounterStyle()` — are hook-free and compatible with React Server Components. No `'use client'` directive needed. For the shared style language (state maps, tokens, units, extending semantics), see [Style DSL](dsl.md). For global configuration, see [Configuration](configuration.md). For the broader docs map, see the [Docs Hub](README.md).
4
+
5
+ > **Note:** This file was previously named `runtime.md`. All functionality documented here works in both server and client contexts — "runtime" referred to style computation during React rendering, not to client-side JavaScript.
6
+
7
+ ---
8
+
9
+ ## Component Creation
10
+
11
+ ### Create a new component
12
+
13
+ ```jsx
14
+ import { tasty } from '@tenphi/tasty';
15
+
16
+ const Card = tasty({
17
+ as: 'div',
18
+ styles: {
19
+ padding: '4x',
20
+ fill: '#white',
21
+ border: true,
22
+ radius: true,
23
+ },
24
+ styleProps: ['padding', 'fill'],
25
+ });
26
+
27
+ <Card>Hello World</Card>
28
+ <Card padding="6x" fill="#gray.05">Custom Card</Card>
29
+ ```
30
+
31
+ ### Extend an existing component
32
+
33
+ ```jsx
34
+ const PrimaryButton = tasty(Button, {
35
+ styles: {
36
+ fill: '#purple',
37
+ color: '#white',
38
+ padding: '2x 4x',
39
+ },
40
+ });
41
+ ```
42
+
43
+ Style maps merge intelligently — see [Style DSL — Extending vs. Replacing State Maps](dsl.md#extending-vs-replacing-state-maps) for extend mode, replace mode, `@inherit`, `null`, and `false` tombstones.
44
+
45
+ ---
46
+
47
+ ## Style Props
48
+
49
+ Use `styleProps` to expose style properties as direct component props:
50
+
51
+ ```jsx
52
+ const FlexibleBox = tasty({
53
+ as: 'div',
54
+ styles: {
55
+ display: 'flex',
56
+ padding: '2x',
57
+ },
58
+ styleProps: ['gap', 'align', 'placeContent', 'fill'],
59
+ });
60
+
61
+ <FlexibleBox gap="2x" align="center" fill="#surface">
62
+ Content
63
+ </FlexibleBox>
64
+ ```
65
+
66
+ Style props accept state maps, so responsive values work through the same API:
67
+
68
+ ```jsx
69
+ <FlexibleBox
70
+ gap={{ '': '2x', '@tablet': '4x' }}
71
+ fill={{ '': '#surface', '@dark': '#surface-dark' }}
72
+ >
73
+ ```
74
+
75
+ For predefined style prop lists (`FLOW_STYLES`, `POSITION_STYLES`, `DIMENSION_STYLES`, etc.) and guidance on which props to expose per component category, see [Methodology — styleProps as the public API](methodology.md#styleprops-as-the-public-api).
76
+
77
+ ---
78
+
79
+ ## Mod Props
80
+
81
+ Use `modProps` to expose modifier keys as direct component props instead of requiring the `mods` object:
82
+
83
+ ```jsx
84
+ // Before: mods object
85
+ <Button mods={{ isLoading: true, size: 'large' }}>Submit</Button>
86
+
87
+ // After: mod props
88
+ <Button isLoading size="large">Submit</Button>
89
+ ```
90
+
91
+ ### Array form
92
+
93
+ List modifier key names. Types default to `ModValue` (`boolean | string | number | undefined | null`):
94
+
95
+ ```jsx
96
+ const Button = tasty({
97
+ modProps: ['isLoading', 'isSelected'] as const,
98
+ styles: {
99
+ fill: { '': '#surface', isLoading: '#surface.5' },
100
+ border: { '': '1bw solid #outline', isSelected: '2bw solid #primary' },
101
+ },
102
+ });
103
+
104
+ <Button isLoading isSelected>Submit</Button>
105
+ // Renders: <button data-is-loading="" data-is-selected="">Submit</button>
106
+ ```
107
+
108
+ ### Object form (typed)
109
+
110
+ Map modifier names to type descriptors for precise TypeScript types:
111
+
112
+ ```tsx
113
+ const Button = tasty({
114
+ modProps: {
115
+ isLoading: Boolean, // isLoading?: boolean
116
+ isSelected: Boolean, // isSelected?: boolean
117
+ size: ['small', 'medium', 'large'] as const, // size?: 'small' | 'medium' | 'large'
118
+ },
119
+ styles: {
120
+ padding: { '': '2x 4x', 'size=small': '1x 2x', 'size=large': '3x 6x' },
121
+ fill: { '': '#surface', isLoading: '#surface.5' },
122
+ },
123
+ });
124
+
125
+ <Button isLoading size="large">Submit</Button>
126
+ // Renders: <button data-is-loading="" data-size="large">Submit</button>
127
+ ```
128
+
129
+ Available type descriptors:
130
+
131
+ | Descriptor | TypeScript type | Example |
132
+ |---|---|---|
133
+ | `Boolean` | `boolean` | `isLoading: Boolean` |
134
+ | `String` | `string` | `label: String` |
135
+ | `Number` | `number` | `count: Number` |
136
+ | `['a', 'b'] as const` | `'a' \| 'b'` | `size: ['sm', 'md', 'lg'] as const` |
137
+
138
+ ### Merge with `mods`
139
+
140
+ Mod props and the `mods` object can be used together. Mod props take precedence:
141
+
142
+ ```jsx
143
+ <Button mods={{ isLoading: false, extra: true }} isLoading>
144
+ // isLoading=true wins (from mod prop), extra=true preserved from mods
145
+ ```
146
+
147
+ ### When to use `modProps` vs `mods`
148
+
149
+ | Use case | Recommendation |
150
+ |---|---|
151
+ | Component has a fixed set of known modifiers | `modProps` — cleaner API, better TypeScript autocomplete |
152
+ | Component needs arbitrary/dynamic modifiers | `mods` — open-ended `Record<string, ModValue>` |
153
+ | Both fixed and dynamic | Combine: `modProps` for known keys, `mods` for ad-hoc |
154
+
155
+ For architecture guidance on when to use modifiers vs `styleProps`, see [Methodology — modProps and mods](methodology.md#modprops-and-mods).
156
+
157
+ ---
158
+
159
+ ## Token Props
160
+
161
+ Use `tokenProps` to expose token keys as direct component props instead of requiring the `tokens` object:
162
+
163
+ ```jsx
164
+ // Before: tokens object
165
+ <ProgressBar tokens={{ $progress: '75%', '#accent': '#purple' }} />
166
+
167
+ // After: token props
168
+ <ProgressBar progress="75%" accentColor="#purple" />
169
+ ```
170
+
171
+ ### Array form
172
+
173
+ List prop names. Names ending in `Color` map to `#` color tokens; everything else maps to `$` custom property tokens:
174
+
175
+ ```jsx
176
+ const ProgressBar = tasty({
177
+ tokenProps: ['progress', 'accentColor'] as const,
178
+ styles: { width: '$progress', fill: '#accent' },
179
+ });
180
+
181
+ <ProgressBar progress="75%" accentColor="#purple" />
182
+ // 'progress' → $progress → --progress
183
+ // 'accentColor' → #accent → --accent-color + --accent-color-oklch
184
+ ```
185
+
186
+ ### Object form
187
+
188
+ Map prop names to explicit `$`/`#`-prefixed token keys:
189
+
190
+ ```tsx
191
+ const Card = tasty({
192
+ tokenProps: {
193
+ size: '$card-size',
194
+ color: '#card-accent',
195
+ },
196
+ styles: { padding: '$card-size', fill: '#card-accent' },
197
+ });
198
+
199
+ <Card size="4x" color="#purple" />
200
+ ```
201
+
202
+ ### Merge with `tokens`
203
+
204
+ Token props and the `tokens` prop can be used together. Token props take precedence over `tokens`, which takes precedence over default `tokens` in `tasty({...})`:
205
+
206
+ ```jsx
207
+ const Bar = tasty({
208
+ tokenProps: ['progress'] as const,
209
+ tokens: { $progress: '0%' }, // default
210
+ });
211
+
212
+ <Bar tokens={{ $progress: '50%' }} progress="90%" />
213
+ // progress="90%" wins (from token prop)
214
+ ```
215
+
216
+ ### When to use `tokenProps` vs `tokens`
217
+
218
+ | Use case | Recommendation |
219
+ |---|---|
220
+ | Component has a fixed set of known token keys | `tokenProps` — cleaner API, better TypeScript autocomplete |
221
+ | Component needs arbitrary/dynamic token values | `tokens` — open-ended `Record<string, TokenValue>` |
222
+ | Both fixed and dynamic | Combine: `tokenProps` for known keys, `tokens` for ad-hoc |
223
+
224
+ For architecture guidance, see [Methodology — tokenProps](methodology.md#tokenprops).
225
+
226
+ ---
227
+
228
+ ## Variants
229
+
230
+ Define named style variations. Only CSS for variants actually used at runtime is injected:
231
+
232
+ ```jsx
233
+ const Button = tasty({
234
+ styles: {
235
+ padding: '2x 4x',
236
+ border: true,
237
+ },
238
+ variants: {
239
+ default: { fill: '#blue', color: '#white' },
240
+ danger: { fill: '#red', color: '#white' },
241
+ outline: { fill: 'transparent', color: '#blue', border: '1bw solid #blue' },
242
+ },
243
+ });
244
+
245
+ <Button variant="danger">Delete</Button>
246
+ ```
247
+
248
+ ### Extending Variants with Base State Maps
249
+
250
+ 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:
251
+
252
+ ```jsx
253
+ const Badge = tasty({
254
+ styles: {
255
+ padding: '1x 2x',
256
+ border: {
257
+ 'type=primary': '#clear',
258
+ },
259
+ },
260
+ variants: {
261
+ primary: {
262
+ border: { '': '#white.2', pressed: '#primary-text', disabled: '#clear' },
263
+ fill: { '': '#white #primary', hovered: '#white #primary-text' },
264
+ },
265
+ secondary: {
266
+ border: { '': '#primary.15', pressed: '#primary.3' },
267
+ fill: '#primary.10',
268
+ },
269
+ },
270
+ });
271
+
272
+ // Both variants get 'type=primary': '#clear' appended to their border map
273
+ ```
274
+
275
+ 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.
276
+
277
+ ---
278
+
279
+ ## Sub-element Styling
280
+
281
+ Sub-elements are inner parts of a compound component, styled via capitalized keys in `styles` and identified by `data-element` attributes in the DOM.
282
+
283
+ > 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.
284
+
285
+ ```jsx
286
+ const Card = tasty({
287
+ styles: {
288
+ padding: '4x',
289
+ Title: { preset: 'h3', color: '#primary' },
290
+ Content: { color: '#text' },
291
+ },
292
+ elements: {
293
+ Title: 'h3',
294
+ Content: 'div',
295
+ },
296
+ });
297
+
298
+ <Card>
299
+ <Card.Title>Card Title</Card.Title>
300
+ <Card.Content>Card content</Card.Content>
301
+ </Card>
302
+ ```
303
+
304
+ Each entry in `elements` can be a tag name string or a config object:
305
+
306
+ ```jsx
307
+ elements: {
308
+ Title: 'h3', // shorthand: tag name only
309
+ Icon: { as: 'span', qa: 'card-icon' }, // full form: tag + QA attribute
310
+ }
311
+ ```
312
+
313
+ The sub-components produced by `elements` support `mods`, `tokens`, `isDisabled`, `isHidden`, and `isChecked` props — the same modifier interface as the root component.
314
+
315
+ 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:
316
+
317
+ ```jsx
318
+ const Card = tasty({
319
+ styles: {
320
+ padding: '4x',
321
+ Title: { preset: 'h3', color: '#primary' },
322
+ },
323
+ });
324
+
325
+ <Card>
326
+ <div data-element="Title">Card Title</div>
327
+ </Card>
328
+ ```
329
+
330
+ ### Selector Affix (`$`)
331
+
332
+ The `$` property inside a sub-element's styles controls how its selector attaches to the root selector — combinators, HTML tags, pseudo-elements, the `@` placeholder, and more. For the full reference table and injection rules, see [DSL — Selector Affix](dsl.md#selector-affix-).
333
+
334
+ For the mental model behind sub-elements — how they share root state context and how this differs from BEM — see [Methodology — Component architecture](methodology.md#component-architecture-root--sub-elements).
335
+
336
+ ---
337
+
338
+ ## computeStyles
339
+
340
+ Hook-free, synchronous style computation. Can be used anywhere — including React Server Components, plain functions, and non-React code:
341
+
342
+ ```tsx
343
+ import { computeStyles } from '@tenphi/tasty';
344
+
345
+ const { className } = computeStyles({
346
+ padding: '2x',
347
+ fill: '#surface',
348
+ radius: '1r',
349
+ });
350
+ ```
351
+
352
+ On the client, CSS is injected synchronously into the DOM (idempotent via the injector cache). On the server, CSS is collected via the SSR collector if one is available. This is the same function that `tasty()` components use internally.
353
+
354
+ ---
355
+
356
+ ## Style Functions
357
+
358
+ All style functions below are plain functions (not React hooks) and can be used in any environment: client components, SSR with a `ServerStyleCollector`, and React Server Components. They retain their `use` prefix for backward compatibility, but do not use any React hooks internally.
359
+
360
+ In server-only contexts (Next.js RSC without `'use client'`, Astro without `client:*` directives, SSG), components that use only Tasty style functions produce zero client JavaScript. Tasty never forces the `'use client'` boundary — that decision belongs to your component when it needs React interactivity (state, effects, event handlers).
361
+
362
+ ### useStyles
363
+
364
+ Generate a className from a style object. Thin wrapper around `computeStyles()`:
365
+
366
+ ```tsx
367
+ import { useStyles } from '@tenphi/tasty';
368
+
369
+ function MyComponent() {
370
+ const { className } = useStyles({
371
+ padding: '2x',
372
+ fill: '#surface',
373
+ radius: '1r',
374
+ });
375
+
376
+ return <div className={className}>Styled content</div>;
377
+ }
378
+ ```
379
+
380
+ ### useGlobalStyles
381
+
382
+ Inject global styles for a CSS selector. Accepts an optional third argument with an `id` for update tracking — when the styles change, the previous injection is disposed and the new one is injected:
383
+
384
+ ```tsx
385
+ import { useGlobalStyles } from '@tenphi/tasty';
386
+
387
+ function ThemeStyles() {
388
+ useGlobalStyles('.card', {
389
+ padding: '4x',
390
+ fill: '#surface',
391
+ radius: '1r',
392
+ });
393
+
394
+ return null;
395
+ }
396
+ ```
397
+
398
+ ### useRawCSS
399
+
400
+ Inject raw CSS strings. Accepts an optional `id` in the options for update tracking — when the CSS changes for the same id, the previous injection is replaced:
401
+
402
+ ```tsx
403
+ import { useRawCSS } from '@tenphi/tasty';
404
+
405
+ function GlobalReset() {
406
+ useRawCSS(`
407
+ body { margin: 0; padding: 0; }
408
+ `);
409
+
410
+ return null;
411
+ }
412
+ ```
413
+
414
+ ### useKeyframes
415
+
416
+ Inject `@keyframes` rules and return the generated animation name:
417
+
418
+ ```tsx
419
+ import { useKeyframes } from '@tenphi/tasty';
420
+
421
+ function Spinner() {
422
+ const spin = useKeyframes(
423
+ {
424
+ from: { transform: 'rotate(0deg)' },
425
+ to: { transform: 'rotate(360deg)' },
426
+ },
427
+ { name: 'spin' }
428
+ );
429
+
430
+ return <div style={{ animation: `${spin} 1s linear infinite` }} />;
431
+ }
432
+ ```
433
+
434
+ `useKeyframes()` also supports a factory function. The deps array is accepted for backward compatibility but the factory is called on every invocation — deduplication is handled internally by content hash:
435
+
436
+ ```tsx
437
+ function Pulse({ scale }: { scale: number }) {
438
+ const pulse = useKeyframes(
439
+ () => ({
440
+ '0%': { transform: 'scale(1)' },
441
+ '100%': { transform: `scale(${scale})` },
442
+ }),
443
+ [scale]
444
+ );
445
+
446
+ return <div style={{ animation: `${pulse} 500ms ease-in-out alternate infinite` }} />;
447
+ }
448
+ ```
449
+
450
+ ### useProperty
451
+
452
+ Register a CSS `@property` rule so a custom property can animate smoothly:
453
+
454
+ ```tsx
455
+ import { useProperty } from '@tenphi/tasty';
456
+
457
+ function Spinner() {
458
+ useProperty('$rotation', {
459
+ syntax: '<angle>',
460
+ inherits: false,
461
+ initialValue: '0deg',
462
+ });
463
+
464
+ return <div style={{ transform: 'rotate(var(--rotation))' }} />;
465
+ }
466
+ ```
467
+
468
+ `useProperty()` accepts Tasty token syntax for the property name:
469
+
470
+ - `$name` defines `--name`
471
+ - `#name` defines `--name-color` and auto-infers `<color>`
472
+ - `--name` is also supported for existing CSS variables
473
+
474
+ ### useFontFace
475
+
476
+ Inject `@font-face` rules for custom fonts. Permanent — no cleanup on unmount. Deduplicates by content.
477
+
478
+ ```tsx
479
+ import { useFontFace } from '@tenphi/tasty';
480
+
481
+ function App() {
482
+ useFontFace('Brand Sans', {
483
+ src: 'url("/fonts/brand-sans.woff2") format("woff2")',
484
+ fontWeight: '400 700',
485
+ fontDisplay: 'swap',
486
+ });
487
+
488
+ return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
489
+ }
490
+ ```
491
+
492
+ For multiple weights/styles, pass an array:
493
+
494
+ ```tsx
495
+ useFontFace('Brand Sans', [
496
+ { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
497
+ { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
498
+ ]);
499
+ ```
500
+
501
+ Signature:
502
+
503
+ ```ts
504
+ function useFontFace(family: string, input: FontFaceInput): void;
505
+ ```
506
+
507
+ ### useCounterStyle
508
+
509
+ Inject a `@counter-style` rule and get back the counter style name. Permanent — no cleanup on unmount. Deduplicates by name.
510
+
511
+ ```tsx
512
+ import { useCounterStyle } from '@tenphi/tasty';
513
+
514
+ function EmojiList() {
515
+ const styleName = useCounterStyle({
516
+ system: 'cyclic',
517
+ symbols: '"👍"',
518
+ suffix: '" "',
519
+ }, { name: 'thumbs' });
520
+
521
+ return (
522
+ <ol style={{ listStyleType: styleName }}>
523
+ <li>First</li>
524
+ <li>Second</li>
525
+ </ol>
526
+ );
527
+ }
528
+ ```
529
+
530
+ Signature:
531
+
532
+ ```ts
533
+ function useCounterStyle(
534
+ descriptors: CounterStyleDescriptors,
535
+ options?: { name?: string; root?: Document | ShadowRoot },
536
+ ): string;
537
+ ```
538
+
539
+ ### Troubleshooting
540
+
541
+ - Styles are not updating: make sure `configure()` runs before first render, and verify the generated class name or global rule with [Debug Utilities](debug.md).
542
+ - SSR output looks wrong: check the [SSR guide](ssr.md) for collector setup. All style functions discover the SSR collector via `AsyncLocalStorage` or the global getter registered by `TastyRegistry`.
543
+ - Animation/custom property issues: prefer `useKeyframes()` and `useProperty()` over raw CSS when you want Tasty to manage injection and SSR collection for you.
544
+ - For dynamic styles that change over the component lifecycle, use the `id` option in `useGlobalStyles()` and `useRawCSS()` to enable update tracking.
545
+ - RSC inline mode: CSS accumulated by standalone style functions (`useGlobalStyles`, `useRawCSS`, etc.) is flushed into inline `<style>` tags by the next `tasty()` component in the render tree. If your page uses only standalone style functions without any `tasty()` component, the CSS will not be emitted. Ensure at least one `tasty()` component is present in each RSC render tree.
546
+
547
+ ---
548
+
549
+ ## Learn more
550
+
551
+ - **[Style DSL](dsl.md)** — State maps, tokens, units, extending semantics, keyframes, @property
552
+ - **[Methodology](methodology.md)** — Recommended patterns: root + sub-elements, styleProps, tokens, wrapping
553
+ - **[Configuration](configuration.md)** — Tokens, recipes, custom units, style handlers, TypeScript extensions
554
+ - **[Style Properties](styles.md)** — Complete reference for all enhanced style properties
555
+ - **[Zero Runtime (tastyStatic)](tasty-static.md)** — Build-time static styling with Babel plugin
556
+ - **[Server-Side Rendering](ssr.md)** — SSR setup for Next.js, Astro, and generic frameworks
557
+ - **[Debug Utilities](debug.md)** — Inspect injected CSS, cache state, and active styles at runtime