@antadesign/anta 0.3.33 → 0.3.35

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 (205) hide show
  1. package/LICENSE.md +14 -1
  2. package/README.md +9 -0
  3. package/dist/anta_helpers.d.ts +46 -30
  4. package/dist/anta_helpers.js +66 -25
  5. package/dist/bundle.css +1 -1
  6. package/dist/bundle.js +2 -1353
  7. package/dist/components/Banner.d.ts +25 -40
  8. package/dist/components/Banner.js +15 -17
  9. package/dist/components/Breadcrumbs.d.ts +0 -1
  10. package/dist/components/Breadcrumbs.js +0 -1
  11. package/dist/components/Button.d.ts +2 -3
  12. package/dist/components/Button.js +1 -0
  13. package/dist/components/ButtonCopy.js +3 -2
  14. package/dist/components/Calendar.js +13 -13
  15. package/dist/components/Card.d.ts +9 -17
  16. package/dist/components/Card.js +50 -46
  17. package/dist/components/Dialog.d.ts +1 -0
  18. package/dist/components/Dialog.js +16 -10
  19. package/dist/components/Expander.d.ts +6 -21
  20. package/dist/components/Expander.js +24 -23
  21. package/dist/components/Icon.d.ts +8 -14
  22. package/dist/components/Input.d.ts +77 -96
  23. package/dist/components/Input.js +23 -27
  24. package/dist/components/InputAutocomplete.d.ts +29 -10
  25. package/dist/components/InputAutocomplete.js +25 -8
  26. package/dist/components/InputDate.d.ts +0 -1
  27. package/dist/components/InputDate.js +2 -3
  28. package/dist/components/InputTime.d.ts +10 -4
  29. package/dist/components/InputTime.js +20 -16
  30. package/dist/components/Loader.d.ts +2 -2
  31. package/dist/components/Menu.d.ts +5 -4
  32. package/dist/components/Menu.js +13 -8
  33. package/dist/components/MenuItem.js +1 -14
  34. package/dist/components/MenuItemCopy.js +2 -2
  35. package/dist/components/Panel.d.ts +3 -1
  36. package/dist/components/Panel.js +17 -11
  37. package/dist/components/Progress.d.ts +21 -23
  38. package/dist/components/Progress.js +13 -9
  39. package/dist/components/RadioGroup.js +6 -8
  40. package/dist/components/{select-parts.css → Select.css} +1 -1
  41. package/dist/components/Select.d.ts +53 -36
  42. package/dist/components/Select.js +53 -98
  43. package/dist/components/SelectFaceted.d.ts +7 -4
  44. package/dist/components/SelectFaceted.js +21 -10
  45. package/dist/components/Slider.d.ts +28 -11
  46. package/dist/components/Slider.js +20 -20
  47. package/dist/components/Steps.css +1 -1
  48. package/dist/components/Steps.d.ts +0 -1
  49. package/dist/components/Steps.js +1 -12
  50. package/dist/components/Tabs.d.ts +17 -20
  51. package/dist/components/Tabs.js +7 -9
  52. package/dist/components/Text.d.ts +55 -36
  53. package/dist/components/Text.js +35 -22
  54. package/dist/components/Title.d.ts +19 -27
  55. package/dist/components/Title.js +2 -1
  56. package/dist/components/Toaster.js +9 -2
  57. package/dist/components/Tooltip.d.ts +10 -15
  58. package/dist/components/copy-props.d.ts +14 -3
  59. package/dist/components/copy-props.js +14 -3
  60. package/dist/components/select-tree.d.ts +24 -0
  61. package/dist/components/select-tree.js +35 -0
  62. package/dist/element-base.d.ts +10 -0
  63. package/dist/element-base.js +15 -0
  64. package/dist/elements/a-avatar.css +1 -1
  65. package/dist/elements/a-avatar.js +2 -28
  66. package/dist/elements/a-banner.css +1 -1
  67. package/dist/elements/a-banner.d.ts +4 -1
  68. package/dist/elements/a-banner.js +22 -112
  69. package/dist/elements/a-breadcrumbs.d.ts +1 -0
  70. package/dist/elements/a-breadcrumbs.js +1 -0
  71. package/dist/elements/a-button.css +1 -1
  72. package/dist/elements/a-button.d.ts +10 -7
  73. package/dist/elements/a-button.js +18 -1
  74. package/dist/elements/a-calendar.d.ts +14 -13
  75. package/dist/elements/a-calendar.js +29 -24
  76. package/dist/elements/a-card.css +1 -1
  77. package/dist/elements/a-card.d.ts +0 -9
  78. package/dist/elements/a-card.js +0 -184
  79. package/dist/elements/a-checkbox.css +1 -1
  80. package/dist/elements/a-copy.css +1 -1
  81. package/dist/elements/a-copy.d.ts +1 -5
  82. package/dist/elements/a-copy.js +129 -108
  83. package/dist/elements/a-dialog.css +1 -1
  84. package/dist/elements/a-dialog.d.ts +1 -1
  85. package/dist/elements/a-dialog.js +68 -194
  86. package/dist/elements/a-expander.css +1 -1
  87. package/dist/elements/a-expander.d.ts +4 -30
  88. package/dist/elements/a-expander.js +85 -344
  89. package/dist/elements/a-icon.d.ts +5 -23
  90. package/dist/elements/a-icon.js +1 -2
  91. package/dist/elements/a-input-date.d.ts +1 -0
  92. package/dist/elements/a-input-date.js +1 -0
  93. package/dist/elements/a-input-time.css +1 -1
  94. package/dist/elements/a-input-time.d.ts +2 -1
  95. package/dist/elements/a-input-time.js +101 -168
  96. package/dist/elements/a-input.css +1 -1
  97. package/dist/elements/a-input.d.ts +10 -8
  98. package/dist/elements/a-input.js +155 -230
  99. package/dist/elements/a-loader.d.ts +5 -8
  100. package/dist/elements/a-loader.js +1 -2
  101. package/dist/elements/a-menu-item.css +1 -1
  102. package/dist/elements/a-menu-item.d.ts +5 -3
  103. package/dist/elements/a-menu-item.js +5 -1
  104. package/dist/elements/a-menu.css +1 -1
  105. package/dist/elements/a-menu.d.ts +5 -7
  106. package/dist/elements/a-menu.js +383 -299
  107. package/dist/elements/a-panel.css +1 -1
  108. package/dist/elements/a-panel.js +19 -37
  109. package/dist/elements/a-progress.css +1 -1
  110. package/dist/elements/a-progress.d.ts +0 -22
  111. package/dist/elements/a-progress.js +0 -100
  112. package/dist/elements/a-radio-group.d.ts +1 -1
  113. package/dist/elements/a-radio-group.js +6 -4
  114. package/dist/elements/a-select-faceted.d.ts +1 -0
  115. package/dist/elements/a-select-faceted.js +1 -0
  116. package/dist/elements/a-select.d.ts +1 -0
  117. package/dist/elements/a-select.js +1 -0
  118. package/dist/elements/a-slider.css +1 -1
  119. package/dist/elements/a-slider.d.ts +11 -3
  120. package/dist/elements/a-slider.js +244 -242
  121. package/dist/elements/a-steps.d.ts +1 -0
  122. package/dist/elements/a-steps.js +1 -0
  123. package/dist/elements/a-switch.css +1 -1
  124. package/dist/elements/a-tab.css +1 -1
  125. package/dist/elements/a-tabpanel.d.ts +2 -2
  126. package/dist/elements/a-tabpanel.js +13 -3
  127. package/dist/elements/a-tabs.css +1 -1
  128. package/dist/elements/a-tabs.d.ts +1 -1
  129. package/dist/elements/a-tabs.js +6 -4
  130. package/dist/elements/a-tag.css +1 -1
  131. package/dist/elements/a-tag.d.ts +1 -0
  132. package/dist/elements/a-tag.js +1 -0
  133. package/dist/elements/a-text.css +1 -1
  134. package/dist/elements/a-text.d.ts +6 -43
  135. package/dist/elements/a-text.js +110 -193
  136. package/dist/elements/a-title.css +1 -1
  137. package/dist/elements/a-title.d.ts +1 -0
  138. package/dist/elements/a-title.js +1 -0
  139. package/dist/elements/a-toast.css +1 -1
  140. package/dist/elements/a-toast.d.ts +10 -45
  141. package/dist/elements/a-toast.js +80 -66
  142. package/dist/elements/a-toaster.css +1 -1
  143. package/dist/elements/a-toaster.js +9 -44
  144. package/dist/elements/a-tooltip.css +1 -1
  145. package/dist/elements/a-tooltip.d.ts +1 -1
  146. package/dist/elements/a-tooltip.js +142 -136
  147. package/dist/elements/copy-behavior.d.ts +1 -1
  148. package/dist/elements/copy-behavior.js +21 -21
  149. package/dist/elements/index.d.ts +9 -3
  150. package/dist/elements/index.js +6 -6
  151. package/dist/elements/input-focus-modality.d.ts +15 -0
  152. package/dist/elements/input-focus-modality.js +44 -0
  153. package/dist/elements/input-trailing-actions.d.ts +5 -0
  154. package/dist/elements/input-trailing-actions.js +38 -0
  155. package/dist/elements/shadow-aria.d.ts +2 -0
  156. package/dist/elements/shadow-aria.js +2 -1
  157. package/dist/elements/value-input.d.ts +3 -0
  158. package/dist/elements/value-input.js +12 -0
  159. package/dist/general_types.d.ts +103 -96
  160. package/dist/index.d.ts +1 -1
  161. package/dist/input-events.d.ts +4 -0
  162. package/dist/input-events.js +15 -0
  163. package/dist/jsx-runtime.d.ts +70 -23
  164. package/dist/jsx-runtime.js +26 -19
  165. package/dist/native-event-props.d.ts +2 -0
  166. package/dist/native-event-props.js +10 -0
  167. package/dist/reset.css +1 -1
  168. package/dist/theme-antithesis.css +10 -1
  169. package/dist/theme-antune.css +1 -1
  170. package/docs/accessibility.md +17 -3
  171. package/docs/changelog.md +384 -2
  172. package/docs/comparison.md +2 -2
  173. package/docs/components/avatar.md +5 -0
  174. package/docs/components/banner.md +117 -187
  175. package/docs/components/breadcrumbs.md +9 -6
  176. package/docs/components/button.md +22 -0
  177. package/docs/components/card.md +74 -28
  178. package/docs/components/checkbox.md +9 -10
  179. package/docs/components/dialog.md +83 -32
  180. package/docs/components/expander.md +198 -435
  181. package/docs/components/icon.md +11 -17
  182. package/docs/components/input-autocomplete.md +152 -52
  183. package/docs/components/input-date.md +175 -148
  184. package/docs/components/input-time.md +81 -38
  185. package/docs/components/input.md +343 -349
  186. package/docs/components/loader.md +2 -1
  187. package/docs/components/menu.md +35 -6
  188. package/docs/components/panel.md +18 -0
  189. package/docs/components/progress.md +83 -49
  190. package/docs/components/radio.md +39 -43
  191. package/docs/components/select-faceted.md +54 -7
  192. package/docs/components/select.md +390 -386
  193. package/docs/components/slider.md +136 -19
  194. package/docs/components/steps.md +6 -3
  195. package/docs/components/switch.md +8 -9
  196. package/docs/components/tabs.md +110 -104
  197. package/docs/components/text.md +110 -86
  198. package/docs/components/title.md +47 -33
  199. package/docs/components/toaster.md +242 -84
  200. package/docs/components/tooltip.md +204 -113
  201. package/docs/install-config.md +461 -96
  202. package/docs/packages/plot.md +228 -143
  203. package/docs/theming.md +29 -13
  204. package/package.json +43 -4
  205. package/theme-antithesis-license.md +66 -0
@@ -9,55 +9,127 @@ npm install @antadesign/anta # or pnpm / bun
9
9
  Pin an exact version in `package.json` (`"@antadesign/anta": "0.3.16"`) instead
10
10
  of a floating tag such as `"latest"`.
11
11
 
12
- ### Usage
12
+ ### Full bundle
13
+
14
+ Use the full bundle as the default setup. Import the JavaScript entry and its
15
+ stylesheet in your browser app entry:
13
16
 
14
17
  ```tsx
15
- import '@antadesign/anta/tokens.css' // CSS custom properties
16
- import '@antadesign/anta/reset.css' // reset and typography defaults
17
- import '@antadesign/anta/elements' // registers <a-*> elements
18
- import '@antadesign/anta/theme-antune.css' // optional Antune theme
19
- import { Progress } from '@antadesign/anta'
18
+ import '@antadesign/anta/bundle.css'
19
+ import { Progress } from '@antadesign/anta/bundle'
20
20
 
21
21
  <Progress value={42} label="Uploaded" hint="3 of 7" />
22
22
  ```
23
23
 
24
- ### Full bundle
24
+ `bundle` registers every custom element and exports the JSX wrappers.
25
+ `bundle.css` contains global tokens, the reset, element styles, and composed
26
+ wrapper styles. The JavaScript bundle does not import this stylesheet, so keep
27
+ both imports. Its React peer dependency and Preact configuration are the same
28
+ as the regular JSX entry.
29
+
30
+ Use this pair together. Adding granular element imports also loads their CSS,
31
+ duplicating rules already in `bundle.css`.
25
32
 
26
- For a single minified Anta runtime and stylesheet, use the bundle pair instead
27
- of the separate tokens, reset, elements, and JSX imports:
33
+ ### Granular usage (advanced)
34
+
35
+ Use granular imports to choose which browser elements and styles your app loads,
36
+ or to render JSX on a server or in a worker. Load shared tokens once, optionally
37
+ include the reset, and import the element entries you use:
28
38
 
29
39
  ```tsx
30
- import '@antadesign/anta/bundle.css'
31
- import { Progress } from '@antadesign/anta/bundle'
40
+ import '@antadesign/anta/tokens.css'
41
+ import '@antadesign/anta/reset.css'
42
+ import '@antadesign/anta/elements/a-progress'
43
+ import '@antadesign/anta/elements/a-title'
44
+ import '@antadesign/anta/elements/a-tag'
45
+ import { Progress, Title, Tag } from '@antadesign/anta'
46
+
47
+ <>
48
+ <Title>Uploads</Title>
49
+ <Progress value={42} label="Uploaded" hint="3 of 7" />
50
+ <Tag>In progress</Tag>
51
+ </>
52
+ ```
32
53
 
33
- <Progress value={42} label="Uploaded" hint="3 of 7" />
54
+ Each element entry imports its own CSS for your bundler to include and registers
55
+ its browser class when needed. Some entries load only CSS and have no custom
56
+ element class to register. Element entries do not import global tokens or the reset.
57
+
58
+ JSX wrappers produce `<a-*>` tags and attributes. They do not register browser
59
+ elements or import CSS. Load element entries in the browser's UI thread;
60
+ see [Registering elements](#registering-elements) for server and worker rendering.
61
+
62
+ Composed components have CSS-only entries for their layout styles:
63
+
64
+ | JSX wrapper | UI-side style entry |
65
+ |---|---|
66
+ | `Breadcrumbs` | `@antadesign/anta/elements/a-breadcrumbs` |
67
+ | `Steps` | `@antadesign/anta/elements/a-steps` |
68
+ | `InputDate` | `@antadesign/anta/elements/a-input-date` |
69
+ | `Select` | `@antadesign/anta/elements/a-select` |
70
+ | `SelectFaceted` | `@antadesign/anta/elements/a-select-faceted` |
71
+
72
+ These entries load layout CSS without registering a class or loading nested
73
+ elements. Import the browser elements used by the composition too. For example,
74
+ `Steps` uses Tabs and Tooltip, and may render icons, loaders, or panels depending
75
+ on its props:
76
+
77
+ ```ts
78
+ // Browser UI entry, alongside shared tokens and the optional reset.
79
+ import '@antadesign/anta/elements/a-steps'
80
+ import '@antadesign/anta/elements/a-tabs'
81
+ import '@antadesign/anta/elements/a-tab'
82
+ import '@antadesign/anta/elements/a-tabpanel'
83
+ import '@antadesign/anta/elements/a-tooltip'
84
+ import '@antadesign/anta/elements/a-icon'
85
+ import '@antadesign/anta/elements/a-loader'
34
86
  ```
35
87
 
36
- `bundle` registers every custom element and re-exports the JSX API. Its React
37
- peer dependency and Preact configuration are the same as the regular JSX entry.
88
+ Import `Steps` from `@antadesign/anta` where you render JSX, including in a worker
89
+ or on the server. Select and SelectFaceted share one stylesheet, which bundlers
90
+ include once when both style entries are imported.
38
91
 
39
- ### What you import (and why)
92
+ To load all elements through the separate entries, replace the per-element imports
93
+ with `import '@antadesign/anta/elements'`. Keep the tokens and optional reset.
94
+
95
+ Individual stylesheets are also exported for direct CSS imports. With a bundler
96
+ that supports `?raw`, you can read a stylesheet as text:
40
97
 
41
- Tokens, elements, and the JSX layer render a styled component. The reset is
42
- recommended; the reference theme is optional.
98
+ ```ts
99
+ import titleCss from '@antadesign/anta/elements/a-title.css?raw'
100
+ ```
43
101
 
44
- | Import | Provides | Skip if… |
45
- |---|---|---|
46
- | `@antadesign/anta/tokens.css` | Six seed tokens, derived role scales (`--bg-1…5`, `--text-1…5`, `--border-1…5`), `.dark` and its `color-scheme`, the 15px root size, and layer order. Override a seed to reskin its tone. | You provide those variables. |
47
- | `@antadesign/anta/reset.css` | A small reset plus Anta's focus, heading, list, and link typography in `@layer anta.reset`. | You use another reset and typography. |
48
- | `@antadesign/anta/elements` | Registers every `<a-*>` element and its CSS. Per-element entries register one; see [Registering elements](#registering-elements). | You render only on the server or register elements individually. |
49
- | `@antadesign/anta` | Typed React/Preact wrappers such as `Progress`, `Text`, and `Icon`. | You write `<a-*>` elements directly. |
50
- | `@antadesign/anta/bundle.css` | One minified stylesheet containing tokens, reset, element, and JSX-wrapper styles. | You want granular CSS imports. |
51
- | `@antadesign/anta/bundle` | One minified ESM runtime that registers every `<a-*>` element and re-exports the JSX API. | You want granular JS imports. |
52
- | `@antadesign/anta/theme-antune.css` *(optional)* | Antune, the hand-tuned reference palette. Import last to replace the seed-derived default. | You want the seed-derived or your own palette. |
53
- | `@antadesign/anta/theme-antithesis.css` *(optional)* | Antithesis: warm color seeds, pill buttons, square text fields, and `1px` tag corners. Import as the only theme. | You want Antune, the seed-derived palette, or your own theme. |
102
+ This returns CSS text; it does not apply styles or register an element.
54
103
 
55
- Load `tokens.css` before element CSS. Elements read its variables; without it,
56
- they render unstyled.
104
+ ### Optional theme
57
105
 
58
- To use the optional reference palette, import `theme-antune.css` after the element
59
- registration import. It ships in `@antadesign/anta`; omit it to keep the
60
- seed-derived default palette or provide your own theme.
106
+ Add one optional theme after either the full bundle CSS or the granular styles:
107
+
108
+ ```ts
109
+ import '@antadesign/anta/theme-antune.css'
110
+ ```
111
+
112
+ Use `theme-antithesis.css` for Antithesis, or omit both themes to keep the
113
+ seed-derived default palette. These theme files do not load fonts. Choose fonts
114
+ separately; see [Fonts](#fonts).
115
+
116
+ ### What you import (and why)
117
+
118
+ | Import | Provides |
119
+ |---|---|
120
+ | `@antadesign/anta/bundle` | All browser element definitions and the JSX API in one minified ESM runtime. |
121
+ | `@antadesign/anta/bundle.css` | Global tokens, reset, element, and composed wrapper styles in one minified stylesheet. |
122
+ | `@antadesign/anta/tokens.css` | Shared color roles, fonts, dark-mode support, and layer order for granular usage. |
123
+ | `@antadesign/anta/reset.css` | Optional reset and typography defaults in `@layer anta.reset`. |
124
+ | `@antadesign/anta/elements/a-*` | One element's behavior and CSS, or CSS alone for structural tags and composed layouts. |
125
+ | `@antadesign/anta/elements` | All browser element definitions, element styles, and composed layout styles through separate modules. |
126
+ | `@antadesign/anta` | Typed JSX wrappers for React, Preact, and configured runtimes, without CSS or element registration. |
127
+ | `@antadesign/anta/elements/*.css` | Individual stylesheets without element registration. |
128
+ | `@antadesign/anta/theme-antune.css` | Optional Antune theme. |
129
+ | `@antadesign/anta/theme-antithesis.css` | Optional Antithesis theme. |
130
+
131
+ With granular usage, include `tokens.css` before element styles unless your app
132
+ provides those variables. Elements depend on them for their default appearance.
61
133
 
62
134
  ### Cascade layers
63
135
 
@@ -121,71 +193,267 @@ and your installed Anta version. Web documentation may describe a newer release.
121
193
 
122
194
  ## Registering elements
123
195
 
124
- JSX wrappers render `<a-*>` tags. Register their classes before those tags reach
125
- the DOM. Registration needs `HTMLElement`, so the import is a no-op in Node.js
126
- and Worker threads.
196
+ JSX wrappers render `<a-*>` tags. Load their browser definitions and styles in
197
+ the UI thread before rendering or hydrating those tags. For full bundle usage,
198
+ and hooks:
127
199
 
128
200
  ```ts
129
- import '@antadesign/anta/elements' // auto-registers all elements
201
+ // src/main.tsx (or wherever your root render lives)
202
+ import '@antadesign/anta/bundle.css'
203
+ import '@antadesign/anta/bundle'
204
+ import { createRoot } from 'react-dom/client'
205
+ import App from './App'
206
+ createRoot(document.getElementById('root')!).render(<App />)
130
207
  ```
131
208
 
132
- `/elements` registers everything. Per-element entries register one element and
133
- load only its CSS:
209
+ The JavaScript bundle registers all browser elements. With granular usage, load
210
+ shared tokens, the optional reset, and the entries your app uses:
134
211
 
135
212
  ```ts
136
- import '@antadesign/anta/elements/a-tooltip' // only <a-tooltip> + its CSS
137
- import '@antadesign/anta/elements/a-button' // only <a-button> + its CSS
213
+ import '@antadesign/anta/tokens.css'
214
+ import '@antadesign/anta/reset.css'
215
+ import '@antadesign/anta/elements/a-tooltip' // <a-tooltip> behavior and CSS
216
+ import '@antadesign/anta/elements/a-button' // <a-button> behavior and CSS
217
+ import '@antadesign/anta/elements/a-title' // Title CSS only
218
+ import '@antadesign/anta/elements/a-tag' // Tag CSS only
138
219
  ```
139
220
 
140
- Both are idempotent, side-effect imports and safe during SSR.
221
+ To load all browser elements and layout styles, replace the individual element
222
+ imports with `import '@antadesign/anta/elements'`. Keep the shared tokens and
223
+ optional reset. Registration is idempotent and guarded when `customElements`
224
+ is unavailable. CSS imports need a bundler that handles stylesheets.
141
225
 
142
- Use a static import in your app entry, outside components and hooks:
226
+ CSS-only components such as Title, Tag, Progress, Icon, and Loader render
227
+ without custom element registration. Their entries load styles. Icon and Loader
228
+ retain `register_a_icon()` and `register_a_loader()` for integrations that
229
+ explicitly require a defined tag.
143
230
 
144
- ```ts
145
- // src/main.tsx (or wherever your root render lives)
146
- import '@antadesign/anta/elements'
147
- import { createRoot } from 'react-dom/client'
148
- import App from './App'
149
- createRoot(document.getElementById('root')!).render(<App />)
150
- ```
151
-
152
- Module initialisation registers the classes before the first render, avoiding a
153
- flash of un-upgraded elements.
231
+ Static imports register classes before the app's first client render or
232
+ hydration. Server-rendered HTML can paint before the browser loads JavaScript;
233
+ load its CSS with the initial document, as in the Next.js setup below.
154
234
 
155
- > **Why not `useEffect(() => import('@antadesign/anta/elements'), [])`?**
156
- > `useEffect` runs after paint and the import resolves later. The browser can
157
- > paint unregistered elements first. `useLayoutEffect` is still asynchronous and
158
- > warns during SSR hydration.
235
+ > Loading elements in `useEffect` can delay registration until after paint. The
236
+ > dynamic import resolves later, so unregistered elements can appear first.
237
+ > Moving the dynamic import into `useLayoutEffect` still leaves the import
238
+ > asynchronous. Use a static import at the top of the UI entry.
159
239
 
160
240
  Choose the entry point for your runtime:
161
241
 
162
- - **Plain HTML or static sites:** a `<script type="module">` in the document head.
163
- - **Astro or Next.js:** a client-only script. In Astro, use
164
- `<script>import '@antadesign/anta/elements'</script>`; in Next.js, import it
165
- from a `'use client'` file.
242
+ - **Plain HTML or static sites:** a module entry processed by a bundler that
243
+ handles CSS imports; see [Raw web components](#raw-web-components-no-jsx).
244
+ - **Astro:** import the runtime in an Astro-processed `<script>` and the CSS in
245
+ your layout. For full bundle usage, use `bundle` and `bundle.css`.
246
+ - **Next.js:** import the runtime from a `'use client'` file and the CSS from
247
+ your root layout; see [Next.js](#nextjs).
166
248
  - **Worker-rendered UI:** code that runs on the UI thread and initializes the
167
249
  DOM. A Worker has no `HTMLElement`.
168
250
 
251
+ ### Server and worker rendering
252
+
253
+ Import JSX wrappers in the code that renders your UI:
254
+
255
+ ```tsx
256
+ // Server or worker
257
+ import { Button, Title } from '@antadesign/anta'
258
+ ```
259
+
260
+ Load the matching browser definitions and styles in a separate UI entry:
261
+
262
+ ```ts
263
+ // Browser UI thread
264
+ import '@antadesign/anta/tokens.css'
265
+ import '@antadesign/anta/reset.css'
266
+ import '@antadesign/anta/elements/a-button'
267
+ import '@antadesign/anta/elements/a-title'
268
+ ```
269
+
270
+ Rendering a JSX wrapper does not register its browser element. Raw `<a-*>`
271
+ markup uses the same browser entries and can omit the JSX wrappers.
272
+ For a custom JSX runtime, call `configure()` in the process or thread that
273
+ renders the wrappers; see [Framework setup](#framework-setup). Worker renderers
274
+ receive native event subscriptions in the first projection. The browser listener
275
+ workaround does not delay worker subscriptions or require access to UI-thread DOM.
276
+
169
277
  ## Framework setup
170
278
 
171
279
  ### React
172
280
 
173
- Works out of the box.
281
+ Client-rendered React apps need no `configure()` call. Load the JavaScript and CSS
282
+ entries for your chosen import strategy before rendering. If your app hydrates
283
+ server-rendered HTML, enable [browser hydration](#browser-hydration).
284
+
285
+ ### Next.js
286
+
287
+ For the full bundle setup, import its stylesheet in the App Router root layout:
288
+
289
+ ```tsx
290
+ // app/layout.tsx
291
+ import '@antadesign/anta/bundle.css'
292
+ import type { ReactNode } from 'react'
293
+
294
+ export default function Layout({ children }: { children: ReactNode }) {
295
+ return <html lang="en"><body>{children}</body></html>
296
+ }
297
+ ```
298
+
299
+ Import the runtime and JSX wrappers in a Client Component:
300
+
301
+ ```tsx
302
+ // app/page.tsx
303
+ 'use client'
304
+
305
+ import * as React from 'react'
306
+ import { Button, Title, configure } from '@antadesign/anta/bundle'
307
+
308
+ configure(React.createElement, React.Fragment, React, { hydratingEvents: true })
309
+
310
+ export default function Page() {
311
+ const [count, setCount] = React.useState(0)
312
+ return <>
313
+ <Title>Anta in Next.js</Title>
314
+ <Button label={`Count: ${count}`} onClick={() => setCount(value => value + 1)} />
315
+ </>
316
+ }
317
+ ```
318
+
319
+ Next.js prerenders Client Components on the server for the initial page load.
320
+ `'use client'` marks the client/server module boundary; it does not disable
321
+ server rendering. Anta guards element registration when browser APIs are absent
322
+ and registers the elements when the client module runs before hydration.
323
+ The configuration enables the event-prop workaround for that hydration.
324
+
325
+ For granular usage, replace the layout's bundle stylesheet with shared tokens
326
+ and the optional reset:
327
+
328
+ ```ts
329
+ // app/layout.tsx imports
330
+ import '@antadesign/anta/tokens.css'
331
+ import '@antadesign/anta/reset.css'
332
+ ```
333
+
334
+ Keep the same page component and replace its imports with:
335
+
336
+ ```ts
337
+ // app/page.tsx
338
+ 'use client'
339
+
340
+ import * as React from 'react'
341
+ import '@antadesign/anta/elements/a-button'
342
+ import '@antadesign/anta/elements/a-title'
343
+ import { Button, Title, configure } from '@antadesign/anta'
344
+
345
+ configure(React.createElement, React.Fragment, React, { hydratingEvents: true })
346
+ ```
347
+
348
+ Both setups work with Next.js's default Turbopack bundler.
174
349
 
175
350
  ### Preact with compat
176
351
 
177
- If your bundler aliases `react` to `preact/compat`, Anta works without setup.
352
+ If your bundler aliases `react` to `preact/compat`, Anta needs no `configure()`
353
+ call for client rendering. Load the entries for your chosen import strategy.
354
+ The Vite Preact preset provides these runtime aliases. For server-rendered HTML,
355
+ enable [browser hydration](#browser-hydration).
178
356
 
179
357
  ### Preact without compat
180
358
 
181
- Call `configure()` before rendering any anta components:
359
+ If `react` is not aliased to `preact/compat`, pass Preact's JSX factory and hooks
360
+ to `configure()` before rendering Anta components. For full bundle usage:
182
361
 
183
362
  ```ts
184
- import { configure } from '@antadesign/anta'
363
+ import '@antadesign/anta/bundle.css'
364
+ import { configure } from '@antadesign/anta/bundle'
185
365
  import { h, Fragment } from 'preact'
186
- configure(h, Fragment)
366
+ import * as hooks from 'preact/hooks'
367
+ import { useSyncExternalStore } from 'preact/compat'
368
+
369
+ configure(h, Fragment, { ...hooks, useSyncExternalStore })
187
370
  ```
188
371
 
372
+ Pass the hooks object as a whole. It replaces the previous renderer's hooks;
373
+ missing hooks report an error when used. React's hooks are the default when no
374
+ object is supplied. The extra `useSyncExternalStore` export supports components
375
+ that subscribe to external stores.
376
+
377
+ Import JSX wrappers from `@antadesign/anta/bundle` with this setup. For granular
378
+ usage, import both `configure` and the wrappers from `@antadesign/anta` and load
379
+ the UI entries separately. The root package and the prebuilt bundle each have
380
+ their own renderer configuration, so use `configure` from the same entry as
381
+ your wrappers. The explicit `preact/compat` hook import does not require an alias.
382
+
383
+ ### Browser hydration
384
+
385
+ When your browser app hydrates server-rendered HTML, set `hydratingEvents: true`
386
+ before mounting Anta components:
387
+
388
+ ```ts
389
+ import * as React from 'react'
390
+ import { configure } from '@antadesign/anta/bundle'
391
+
392
+ configure(React.createElement, React.Fragment, React, {
393
+ hydratingEvents: true,
394
+ })
395
+ ```
396
+
397
+ This lets Input, Banner, Expander, and expandable Text attach their native event
398
+ handlers after the first browser commit. With `false` or no option, handlers
399
+ pass through immediately without a listener setup effect or extra mount render.
400
+ Client-only apps use that default without configuration.
401
+
402
+ Use `configure` from the same entry as your wrappers: `@antadesign/anta` or
403
+ `@antadesign/anta/bundle`. For Preact without compat aliases, pass its factory
404
+ and hooks with the same fourth argument. Configure each rendering process or
405
+ thread separately. Servers and workers without `window` forward immediately,
406
+ even when this option is enabled.
407
+
408
+ Keep the option unchanged while components are mounted. If any root using that
409
+ package entry hydrates server HTML, enable it before mounting any root. Each
410
+ `configure()` call resets an omitted option to `false`, so later setup calls must
411
+ preserve `hydratingEvents: true`. Next.js Client Components still hydrate on the
412
+ initial page load; `'use client'` does not make an app client-only.
413
+
414
+ ### Astro
415
+
416
+ For hydrated React or Preact islands, configure Anta before Astro hydrates them.
417
+ Use Astro's `before-hydration` script stage in an integration:
418
+
419
+ ```js
420
+ // astro.config.mjs: add to integrations alongside your React or Preact integration
421
+ {
422
+ name: 'anta-hydration',
423
+ hooks: {
424
+ 'astro:config:setup': ({ injectScript }) => {
425
+ injectScript('before-hydration', `
426
+ import * as React from 'react';
427
+ import { configure } from '@antadesign/anta/bundle';
428
+ configure(React.createElement, React.Fragment, React, {
429
+ hydratingEvents: true,
430
+ });
431
+ `)
432
+ },
433
+ },
434
+ }
435
+ ```
436
+
437
+ This example uses full bundle wrappers. For granular wrappers, use
438
+ `@antadesign/anta` instead and load browser elements separately. Import
439
+ `bundle.css` in your layout for the full bundle. Preact requires the
440
+ `@astrojs/preact` integration's `compat: true` setting for this example.
441
+ Static markup and `client:only` islands do not need the hydration option.
442
+
443
+ ### Custom renderer events
444
+
445
+ Worker renderers receive event subscriptions in their first projection by
446
+ default, including renderers with a `window` shim:
447
+
448
+ ```ts
449
+ configure(h, Fragment, hooks)
450
+ ```
451
+
452
+ Pass the runtime's hooks object as a whole. You do not need to opt into browser
453
+ hydration for worker projections. If shared setup previously enabled it, pass
454
+ `{ hydratingEvents: false }` as the fourth argument before mounting the worker
455
+ UI.
456
+
189
457
  ### TypeScript: typing raw `<a-*>` tags in JSX
190
458
 
191
459
  JSX wrappers such as `<Button>` and `<Progress>` need no extra typing. Configure
@@ -233,43 +501,73 @@ upgrades; there is no per-tag list to maintain.
233
501
 
234
502
  ### Raw web components (no JSX)
235
503
 
236
- Elements also work in plain HTML. Registration loads their CSS; resolve the bare
237
- specifier with a bundler or import map.
504
+ Elements also work in plain HTML without JSX wrappers. This example requires a
505
+ bundler that processes module scripts and CSS imports:
238
506
 
239
507
  ```html
240
508
  <script type="module">
241
- import '@antadesign/anta/elements'
509
+ import '@antadesign/anta/tokens.css'
510
+ import '@antadesign/anta/reset.css'
511
+ import '@antadesign/anta/elements/a-progress'
242
512
  </script>
243
513
 
244
- <a-progress value="42" max="100" tone="info"></a-progress>
514
+ <a-progress value="42" max="100" tone="info" role="progressbar"
515
+ aria-label="Upload" aria-valuenow="42" aria-valuemin="0" aria-valuemax="100">
516
+ </a-progress>
245
517
  ```
246
518
 
519
+ An import map resolves module names but does not process the plain CSS imports
520
+ in Anta's element entries. When serving native modules without a bundler, use
521
+ a separately prepared JavaScript entry and linked stylesheets.
522
+
247
523
  ## Dark mode
248
524
 
249
- For a page-wide dark mode, add `dark` to `html`. The `body` `--bg-2` background
250
- then paints the browser canvas, and the root controls scrollbar colors:
525
+ For a page-wide dark mode, add `dark` to `html`. Shared tokens switch the palette
526
+ and root color scheme, including scrollbar colors. The reset, included in
527
+ `bundle.css` or loaded separately as `reset.css`, paints `body` with `--bg-2`:
251
528
 
252
529
  ```html
253
530
  <html class="dark">
254
531
  <body>
255
- <Progress value={50} />
532
+ <a-progress value="50" role="progressbar" aria-label="Upload"
533
+ aria-valuenow="50" aria-valuemin="0" aria-valuemax="100">
534
+ </a-progress>
256
535
  </body>
257
536
  </html>
258
537
  ```
259
538
 
260
539
  Use `dark` or `light` on another ancestor to scope its color scheme and palette.
540
+ If you omit the reset, set your app's background and text color in your own CSS,
541
+ for example with `--bg-2` and `--text-2`.
261
542
 
262
543
  ## Fonts
263
544
 
264
- Without an optional theme, `tokens.css` defines system stacks in `--sans-serif`,
265
- `--serif`, and `--monospace`. Reference themes register hosted fonts and replace
266
- some of those same variables. Components and theme rules decide which stack to
267
- use. Theme-free components do not force font-specific stylistic sets or
268
- variable-font axes. `tokens.css` also sets `1rem` to 15px.
545
+ Anta works with system fonts without any font downloads. `tokens.css`, also
546
+ included in `bundle.css`, defines system stacks in `--sans-serif`, `--serif`,
547
+ and `--monospace`, and sets `1rem` to 15px. The optional themes keep those stacks
548
+ and do not register font faces or request font files. Components and theme rules
549
+ choose which stack to use.
550
+
551
+ Use fonts from Google Fonts or host font files in your application. Manage font
552
+ loading in a separate application stylesheet such as `fonts.css`, and import it
553
+ after the Anta styles and optional theme:
554
+
555
+ ```ts
556
+ import '@antadesign/anta/bundle.css'
557
+ import '@antadesign/anta/theme-antune.css' // Optional
558
+ import './fonts.css'
559
+ ```
269
560
 
270
- Register application-owned fonts and redefine the variables in CSS loaded after
271
- the Anta styles and optional theme. This example uses separate Roman and Italic
272
- variable files:
561
+ With granular usage, load `fonts.css` after `tokens.css`, your element styles,
562
+ and the optional theme. Anta.design also loads its reference fonts through a
563
+ separate stylesheet. That setup is an example, and is not imported by the
564
+ package. See [Font examples](./theming.md#fonts-in-a-theme) for that setup and
565
+ Google Fonts examples.
566
+
567
+ Register your fonts and override only the stacks you want to change. Keep
568
+ fallback families after each custom font name. This `fonts.css` example uses
569
+ separate Roman and Italic variable files and keeps the default serif and
570
+ monospace stacks:
273
571
 
274
572
  ```css
275
573
  @font-face {
@@ -277,6 +575,7 @@ variable files:
277
575
  src: url("/fonts/app-sans-roman.woff2") format("woff2");
278
576
  font-style: normal;
279
577
  font-weight: 100 900;
578
+ font-display: swap;
280
579
  }
281
580
 
282
581
  @font-face {
@@ -284,19 +583,22 @@ variable files:
284
583
  src: url("/fonts/app-sans-italic.woff2") format("woff2");
285
584
  font-style: italic;
286
585
  font-weight: 100 900;
586
+ font-display: swap;
287
587
  }
288
588
 
289
589
  :root {
290
- --sans-serif: "App Sans", sans-serif;
291
- --serif: Georgia, serif;
292
- --monospace: ui-monospace, monospace;
590
+ --sans-serif: "App Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
293
591
  }
294
592
  ```
295
593
 
296
- Place this application stylesheet after `theme-antune.css` or
297
- `theme-antithesis.css`, not before it. When all stylesheets are in the document
298
- head, the override applies before the first paint. Anta's semantic italics
299
- (`em`, `i`, `var`, and `dt`) select the Italic face.
594
+ [Font display](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@font-face/font-display)
595
+ with `swap` shows fallback text while the custom font loads, then switches to
596
+ that font when it is ready. If the font fails to load, the browser keeps using a
597
+ fallback family. The variables remain valid in either case.
598
+
599
+ Anta's reset styles semantic italics (`em`, `i`, `var`, and `dt`) to select the
600
+ Italic face. If you omit the reset, your application or the browser's default
601
+ rules provide those styles.
300
602
 
301
603
  ### Variable slant
302
604
 
@@ -310,6 +612,7 @@ through `font-style: oblique` instead of setting `slnt` on italic elements:
310
612
  font-style: oblique 0deg 12deg;
311
613
  font-weight: 100 900;
312
614
  font-stretch: 75% 100%;
615
+ font-display: swap;
313
616
  }
314
617
 
315
618
  :root {
@@ -322,21 +625,83 @@ the range your font declares to avoid combining `slnt` with a synthetic oblique.
322
625
 
323
626
  ## Browser support
324
627
 
325
- Anta targets evergreen browsers and ships **no baseline polyfills**. Its floor is [custom-element states](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet), used throughout the components for their internal CSS state, alongside the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API):
628
+ Anta requires [ARIA element references](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLabelledByElements),
629
+ [custom-element states](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
630
+ and the [Popover API](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API).
631
+ It ships no baseline polyfills or copied-text fallback for ARIA references.
326
632
 
327
633
  | Browser | Minimum version |
328
634
  | --- | --- |
329
- | Chrome / Edge | 125 (May 2024) |
330
- | Safari | 17.4 (Mar 2024) |
331
- | Firefox | 126 (May 2024) |
635
+ | Chrome / Edge, including Android Chrome and WebView | 135 |
636
+ | Safari / iOS Safari | 17.4 |
637
+ | Firefox, including Android Firefox | 136 |
332
638
 
333
- This is [Baseline 2024](https://web.dev/baseline). Anta also relies on relative
639
+ ARIA element references are [Baseline 2025](https://developer.mozilla.org/en-US/docs/Web/API/Element/ariaLabelledByElements#browser_compatibility).
640
+ Anta also relies on relative
334
641
  OKLCH, `:has()`, `dvh`, cascade layers, and constructable shadow DOM. Older
335
642
  browsers can fail hard, including `:state()` being unrecognized or
336
643
  `showPopover()` throwing. Gate Anta on your own support matrix when you support
337
644
  older browsers.
338
645
 
339
- Two features progressively enhance with fallbacks: `checkVisibility()` falls
340
- back to `getClientRects()`, and typed CSS `attr()` supports raw
341
- `<a-icon size>` in Chrome 133+ and Safari 18.2+. Elsewhere use `<Icon size>`
342
- or `--icon-size`.
646
+ `checkVisibility()` falls back to `getClientRects()`. Some raw attributes use
647
+ [typed CSS `attr()`](https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/attr#browser_compatibility),
648
+ whose support extends beyond Anta's minimum browser requirements. JSX wrappers
649
+ supply CSS variables for these values. Each component's Web Component reference
650
+ describes its raw attribute requirements.
651
+
652
+ ## Content Security Policy
653
+
654
+ Anta's tokens, component stylesheets, and optional themes work when your
655
+ [Content Security Policy](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP)
656
+ (CSP) allows their stylesheet URLs through `style-src-elem` or
657
+ its `style-src` fallback. External CSS and named theme values do not require
658
+ inline style attributes.
659
+
660
+ Custom color props such as `tone="#6750a4"`, explicit lengths such as
661
+ `round={12}` or Icon's `size={24}`, and some dynamic value props produce inline
662
+ CSS custom properties. The `style` prop also produces inline styles.
663
+ Server rendering serializes these values into HTML `style` attributes, which
664
+ `style-src-attr 'none'` blocks. Named tones, preset sizes, and boolean `round`
665
+ use external CSS without these attributes.
666
+
667
+ When inline attributes are forbidden, omit the customization prop and apply
668
+ its value through `className` and an allowed stylesheet. For example, replace
669
+ `<Icon shape="check" size={24} />` with:
670
+
671
+ ```tsx
672
+ <Icon shape="check" className="confirmation-icon" />
673
+ ```
674
+
675
+ ```css
676
+ .confirmation-icon {
677
+ --icon-size: 24px;
678
+ }
679
+ ```
680
+
681
+ Define runtime values in an application-managed stylesheet permitted by your
682
+ policy when they cannot be expressed with predefined classes. Check each
683
+ component's reference for its styling surface and dynamic-value requirements.
684
+ Client-side assignments to individual CSS properties can behave
685
+ differently; do not rely on hydration to repair blocked server-rendered styles.
686
+ See [CSP rules for style attributes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src-attr).
687
+
688
+ Server-rendered `<style>` blocks also need CSP permission. They follow
689
+ `style-src-elem`, falling back to `style-src` and then `default-src`.
690
+ `'self'` allows same-origin stylesheet files, but does not authorize inline
691
+ `<style>` blocks. Use a matching nonce or hash for those blocks under a strict
692
+ policy. A nonce on a `<style>` element does not authorize HTML `style`
693
+ attributes. See [CSP rules for stylesheet elements](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy/style-src-elem).
694
+
695
+ Component defaults in `@antadesign/anta`, including Panel's maximized surface
696
+ and backdrop, use external stylesheets. Load the UI entry or bundle CSS as
697
+ described in [Installation](#installation). Custom props and application
698
+ styles can still require inline-style permission as described here.
699
+
700
+ When placing an Anta component inside an application-owned shadow root, load
701
+ its external CSS in that root through a stylesheet link. Document styles do
702
+ not cross that boundary.
703
+
704
+ The separate `@antadesign/stickers` package has its own CSP requirements. Its
705
+ static and animated elements still inject shadow `<style>` blocks, which a
706
+ policy allowing only external styles blocks. Loading Anta's external CSS or a
707
+ theme does not authorize those blocks.