@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.
- package/LICENSE.md +14 -1
- package/README.md +9 -0
- package/dist/anta_helpers.d.ts +46 -30
- package/dist/anta_helpers.js +66 -25
- package/dist/bundle.css +1 -1
- package/dist/bundle.js +2 -1353
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- package/dist/components/Breadcrumbs.d.ts +0 -1
- package/dist/components/Breadcrumbs.js +0 -1
- package/dist/components/Button.d.ts +2 -3
- package/dist/components/Button.js +1 -0
- package/dist/components/ButtonCopy.js +3 -2
- package/dist/components/Calendar.js +13 -13
- package/dist/components/Card.d.ts +9 -17
- package/dist/components/Card.js +50 -46
- package/dist/components/Dialog.d.ts +1 -0
- package/dist/components/Dialog.js +16 -10
- package/dist/components/Expander.d.ts +6 -21
- package/dist/components/Expander.js +24 -23
- package/dist/components/Icon.d.ts +8 -14
- package/dist/components/Input.d.ts +77 -96
- package/dist/components/Input.js +23 -27
- package/dist/components/InputAutocomplete.d.ts +29 -10
- package/dist/components/InputAutocomplete.js +25 -8
- package/dist/components/InputDate.d.ts +0 -1
- package/dist/components/InputDate.js +2 -3
- package/dist/components/InputTime.d.ts +10 -4
- package/dist/components/InputTime.js +20 -16
- package/dist/components/Loader.d.ts +2 -2
- package/dist/components/Menu.d.ts +5 -4
- package/dist/components/Menu.js +13 -8
- package/dist/components/MenuItem.js +1 -14
- package/dist/components/MenuItemCopy.js +2 -2
- package/dist/components/Panel.d.ts +3 -1
- package/dist/components/Panel.js +17 -11
- package/dist/components/Progress.d.ts +21 -23
- package/dist/components/Progress.js +13 -9
- package/dist/components/RadioGroup.js +6 -8
- package/dist/components/{select-parts.css → Select.css} +1 -1
- package/dist/components/Select.d.ts +53 -36
- package/dist/components/Select.js +53 -98
- package/dist/components/SelectFaceted.d.ts +7 -4
- package/dist/components/SelectFaceted.js +21 -10
- package/dist/components/Slider.d.ts +28 -11
- package/dist/components/Slider.js +20 -20
- package/dist/components/Steps.css +1 -1
- package/dist/components/Steps.d.ts +0 -1
- package/dist/components/Steps.js +1 -12
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +7 -9
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +19 -27
- package/dist/components/Title.js +2 -1
- package/dist/components/Toaster.js +9 -2
- package/dist/components/Tooltip.d.ts +10 -15
- package/dist/components/copy-props.d.ts +14 -3
- package/dist/components/copy-props.js +14 -3
- package/dist/components/select-tree.d.ts +24 -0
- package/dist/components/select-tree.js +35 -0
- package/dist/element-base.d.ts +10 -0
- package/dist/element-base.js +15 -0
- package/dist/elements/a-avatar.css +1 -1
- package/dist/elements/a-avatar.js +2 -28
- package/dist/elements/a-banner.css +1 -1
- package/dist/elements/a-banner.d.ts +4 -1
- package/dist/elements/a-banner.js +22 -112
- package/dist/elements/a-breadcrumbs.d.ts +1 -0
- package/dist/elements/a-breadcrumbs.js +1 -0
- package/dist/elements/a-button.css +1 -1
- package/dist/elements/a-button.d.ts +10 -7
- package/dist/elements/a-button.js +18 -1
- package/dist/elements/a-calendar.d.ts +14 -13
- package/dist/elements/a-calendar.js +29 -24
- package/dist/elements/a-card.css +1 -1
- package/dist/elements/a-card.d.ts +0 -9
- package/dist/elements/a-card.js +0 -184
- package/dist/elements/a-checkbox.css +1 -1
- package/dist/elements/a-copy.css +1 -1
- package/dist/elements/a-copy.d.ts +1 -5
- package/dist/elements/a-copy.js +129 -108
- package/dist/elements/a-dialog.css +1 -1
- package/dist/elements/a-dialog.d.ts +1 -1
- package/dist/elements/a-dialog.js +68 -194
- package/dist/elements/a-expander.css +1 -1
- package/dist/elements/a-expander.d.ts +4 -30
- package/dist/elements/a-expander.js +85 -344
- package/dist/elements/a-icon.d.ts +5 -23
- package/dist/elements/a-icon.js +1 -2
- package/dist/elements/a-input-date.d.ts +1 -0
- package/dist/elements/a-input-date.js +1 -0
- package/dist/elements/a-input-time.css +1 -1
- package/dist/elements/a-input-time.d.ts +2 -1
- package/dist/elements/a-input-time.js +101 -168
- package/dist/elements/a-input.css +1 -1
- package/dist/elements/a-input.d.ts +10 -8
- package/dist/elements/a-input.js +155 -230
- package/dist/elements/a-loader.d.ts +5 -8
- package/dist/elements/a-loader.js +1 -2
- package/dist/elements/a-menu-item.css +1 -1
- package/dist/elements/a-menu-item.d.ts +5 -3
- package/dist/elements/a-menu-item.js +5 -1
- package/dist/elements/a-menu.css +1 -1
- package/dist/elements/a-menu.d.ts +5 -7
- package/dist/elements/a-menu.js +383 -299
- package/dist/elements/a-panel.css +1 -1
- package/dist/elements/a-panel.js +19 -37
- package/dist/elements/a-progress.css +1 -1
- package/dist/elements/a-progress.d.ts +0 -22
- package/dist/elements/a-progress.js +0 -100
- package/dist/elements/a-radio-group.d.ts +1 -1
- package/dist/elements/a-radio-group.js +6 -4
- package/dist/elements/a-select-faceted.d.ts +1 -0
- package/dist/elements/a-select-faceted.js +1 -0
- package/dist/elements/a-select.d.ts +1 -0
- package/dist/elements/a-select.js +1 -0
- package/dist/elements/a-slider.css +1 -1
- package/dist/elements/a-slider.d.ts +11 -3
- package/dist/elements/a-slider.js +244 -242
- package/dist/elements/a-steps.d.ts +1 -0
- package/dist/elements/a-steps.js +1 -0
- package/dist/elements/a-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- package/dist/elements/a-tabpanel.d.ts +2 -2
- package/dist/elements/a-tabpanel.js +13 -3
- package/dist/elements/a-tabs.css +1 -1
- package/dist/elements/a-tabs.d.ts +1 -1
- package/dist/elements/a-tabs.js +6 -4
- package/dist/elements/a-tag.css +1 -1
- package/dist/elements/a-tag.d.ts +1 -0
- package/dist/elements/a-tag.js +1 -0
- package/dist/elements/a-text.css +1 -1
- package/dist/elements/a-text.d.ts +6 -43
- package/dist/elements/a-text.js +110 -193
- package/dist/elements/a-title.css +1 -1
- package/dist/elements/a-title.d.ts +1 -0
- package/dist/elements/a-title.js +1 -0
- package/dist/elements/a-toast.css +1 -1
- package/dist/elements/a-toast.d.ts +10 -45
- package/dist/elements/a-toast.js +80 -66
- package/dist/elements/a-toaster.css +1 -1
- package/dist/elements/a-toaster.js +9 -44
- package/dist/elements/a-tooltip.css +1 -1
- package/dist/elements/a-tooltip.d.ts +1 -1
- package/dist/elements/a-tooltip.js +142 -136
- package/dist/elements/copy-behavior.d.ts +1 -1
- package/dist/elements/copy-behavior.js +21 -21
- package/dist/elements/index.d.ts +9 -3
- package/dist/elements/index.js +6 -6
- package/dist/elements/input-focus-modality.d.ts +15 -0
- package/dist/elements/input-focus-modality.js +44 -0
- package/dist/elements/input-trailing-actions.d.ts +5 -0
- package/dist/elements/input-trailing-actions.js +38 -0
- package/dist/elements/shadow-aria.d.ts +2 -0
- package/dist/elements/shadow-aria.js +2 -1
- package/dist/elements/value-input.d.ts +3 -0
- package/dist/elements/value-input.js +12 -0
- package/dist/general_types.d.ts +103 -96
- package/dist/index.d.ts +1 -1
- package/dist/input-events.d.ts +4 -0
- package/dist/input-events.js +15 -0
- package/dist/jsx-runtime.d.ts +70 -23
- package/dist/jsx-runtime.js +26 -19
- package/dist/native-event-props.d.ts +2 -0
- package/dist/native-event-props.js +10 -0
- package/dist/reset.css +1 -1
- package/dist/theme-antithesis.css +10 -1
- package/dist/theme-antune.css +1 -1
- package/docs/accessibility.md +17 -3
- package/docs/changelog.md +384 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- package/docs/components/breadcrumbs.md +9 -6
- package/docs/components/button.md +22 -0
- package/docs/components/card.md +74 -28
- package/docs/components/checkbox.md +9 -10
- package/docs/components/dialog.md +83 -32
- package/docs/components/expander.md +198 -435
- package/docs/components/icon.md +11 -17
- package/docs/components/input-autocomplete.md +152 -52
- package/docs/components/input-date.md +175 -148
- package/docs/components/input-time.md +81 -38
- package/docs/components/input.md +343 -349
- package/docs/components/loader.md +2 -1
- package/docs/components/menu.md +35 -6
- package/docs/components/panel.md +18 -0
- package/docs/components/progress.md +83 -49
- package/docs/components/radio.md +39 -43
- package/docs/components/select-faceted.md +54 -7
- package/docs/components/select.md +390 -386
- package/docs/components/slider.md +136 -19
- package/docs/components/steps.md +6 -3
- package/docs/components/switch.md +8 -9
- package/docs/components/tabs.md +110 -104
- package/docs/components/text.md +110 -86
- package/docs/components/title.md +47 -33
- package/docs/components/toaster.md +242 -84
- package/docs/components/tooltip.md +204 -113
- package/docs/install-config.md +461 -96
- package/docs/packages/plot.md +228 -143
- package/docs/theming.md +29 -13
- package/package.json +43 -4
- package/theme-antithesis-license.md +66 -0
package/docs/install-config.md
CHANGED
|
@@ -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
|
-
###
|
|
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/
|
|
16
|
-
import '@antadesign/anta/
|
|
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
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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/
|
|
31
|
-
import
|
|
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
|
-
|
|
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
|
-
`
|
|
37
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
98
|
+
```ts
|
|
99
|
+
import titleCss from '@antadesign/anta/elements/a-title.css?raw'
|
|
100
|
+
```
|
|
43
101
|
|
|
44
|
-
|
|
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
|
-
|
|
56
|
-
they render unstyled.
|
|
104
|
+
### Optional theme
|
|
57
105
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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.
|
|
125
|
-
the
|
|
126
|
-
and
|
|
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
|
-
|
|
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
|
-
|
|
133
|
-
|
|
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/
|
|
137
|
-
import '@antadesign/anta/
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
>
|
|
156
|
-
>
|
|
157
|
-
>
|
|
158
|
-
>
|
|
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
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
363
|
+
import '@antadesign/anta/bundle.css'
|
|
364
|
+
import { configure } from '@antadesign/anta/bundle'
|
|
185
365
|
import { h, Fragment } from 'preact'
|
|
186
|
-
|
|
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
|
|
237
|
-
|
|
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/
|
|
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"
|
|
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`.
|
|
250
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
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
|
-
|
|
271
|
-
the
|
|
272
|
-
|
|
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
|
-
|
|
297
|
-
`
|
|
298
|
-
|
|
299
|
-
|
|
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
|
|
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
|
|
330
|
-
| Safari | 17.4
|
|
331
|
-
| Firefox
|
|
635
|
+
| Chrome / Edge, including Android Chrome and WebView | 135 |
|
|
636
|
+
| Safari / iOS Safari | 17.4 |
|
|
637
|
+
| Firefox, including Android Firefox | 136 |
|
|
332
638
|
|
|
333
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
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.
|