@antadesign/anta 0.3.34 → 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 -1333
- package/dist/components/Banner.d.ts +25 -40
- package/dist/components/Banner.js +15 -17
- 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.js +2 -2
- 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 -35
- package/dist/components/Select.js +53 -97
- package/dist/components/SelectFaceted.d.ts +7 -3
- package/dist/components/SelectFaceted.js +21 -9
- 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.js +1 -11
- package/dist/components/Tabs.d.ts +17 -20
- package/dist/components/Tabs.js +5 -8
- package/dist/components/Text.d.ts +55 -36
- package/dist/components/Text.js +35 -22
- package/dist/components/Title.d.ts +16 -26
- 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-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-button.d.ts +2 -1
- 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 +66 -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-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 -1
- package/dist/elements/a-select-faceted.js +1 -1
- package/dist/elements/a-select.d.ts +1 -1
- package/dist/elements/a-select.js +1 -1
- 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-switch.css +1 -1
- package/dist/elements/a-tab.css +1 -1
- 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-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-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 +3 -3
- package/dist/elements/index.js +3 -7
- 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 +348 -2
- package/docs/comparison.md +2 -2
- package/docs/components/avatar.md +5 -0
- package/docs/components/banner.md +117 -187
- 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 +2 -1
- 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 +183 -26
- package/docs/packages/plot.md +170 -148
- package/docs/theming.md +7 -0
- package/package.json +41 -3
- package/theme-antithesis-license.md +66 -0
package/docs/install-config.md
CHANGED
|
@@ -52,7 +52,7 @@ import { Progress, Title, Tag } from '@antadesign/anta'
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
Each element entry imports its own CSS for your bundler to include and registers
|
|
55
|
-
its browser class when needed.
|
|
55
|
+
its browser class when needed. Some entries load only CSS and have no custom
|
|
56
56
|
element class to register. Element entries do not import global tokens or the reset.
|
|
57
57
|
|
|
58
58
|
JSX wrappers produce `<a-*>` tags and attributes. They do not register browser
|
|
@@ -223,6 +223,11 @@ imports with `import '@antadesign/anta/elements'`. Keep the shared tokens and
|
|
|
223
223
|
optional reset. Registration is idempotent and guarded when `customElements`
|
|
224
224
|
is unavailable. CSS imports need a bundler that handles stylesheets.
|
|
225
225
|
|
|
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.
|
|
230
|
+
|
|
226
231
|
Static imports register classes before the app's first client render or
|
|
227
232
|
hydration. Server-rendered HTML can paint before the browser loads JavaScript;
|
|
228
233
|
load its CSS with the initial document, as in the Next.js setup below.
|
|
@@ -265,14 +270,17 @@ import '@antadesign/anta/elements/a-title'
|
|
|
265
270
|
Rendering a JSX wrapper does not register its browser element. Raw `<a-*>`
|
|
266
271
|
markup uses the same browser entries and can omit the JSX wrappers.
|
|
267
272
|
For a custom JSX runtime, call `configure()` in the process or thread that
|
|
268
|
-
renders the wrappers; see [Framework setup](#framework-setup).
|
|
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.
|
|
269
276
|
|
|
270
277
|
## Framework setup
|
|
271
278
|
|
|
272
279
|
### React
|
|
273
280
|
|
|
274
|
-
React
|
|
275
|
-
chosen import strategy before rendering.
|
|
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).
|
|
276
284
|
|
|
277
285
|
### Next.js
|
|
278
286
|
|
|
@@ -294,11 +302,13 @@ Import the runtime and JSX wrappers in a Client Component:
|
|
|
294
302
|
// app/page.tsx
|
|
295
303
|
'use client'
|
|
296
304
|
|
|
297
|
-
import
|
|
298
|
-
import { Button, Title } from '@antadesign/anta/bundle'
|
|
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 })
|
|
299
309
|
|
|
300
310
|
export default function Page() {
|
|
301
|
-
const [count, setCount] = useState(0)
|
|
311
|
+
const [count, setCount] = React.useState(0)
|
|
302
312
|
return <>
|
|
303
313
|
<Title>Anta in Next.js</Title>
|
|
304
314
|
<Button label={`Count: ${count}`} onClick={() => setCount(value => value + 1)} />
|
|
@@ -310,6 +320,7 @@ Next.js prerenders Client Components on the server for the initial page load.
|
|
|
310
320
|
`'use client'` marks the client/server module boundary; it does not disable
|
|
311
321
|
server rendering. Anta guards element registration when browser APIs are absent
|
|
312
322
|
and registers the elements when the client module runs before hydration.
|
|
323
|
+
The configuration enables the event-prop workaround for that hydration.
|
|
313
324
|
|
|
314
325
|
For granular usage, replace the layout's bundle stylesheet with shared tokens
|
|
315
326
|
and the optional reset:
|
|
@@ -326,10 +337,12 @@ Keep the same page component and replace its imports with:
|
|
|
326
337
|
// app/page.tsx
|
|
327
338
|
'use client'
|
|
328
339
|
|
|
329
|
-
import
|
|
340
|
+
import * as React from 'react'
|
|
330
341
|
import '@antadesign/anta/elements/a-button'
|
|
331
342
|
import '@antadesign/anta/elements/a-title'
|
|
332
|
-
import { Button, Title } from '@antadesign/anta'
|
|
343
|
+
import { Button, Title, configure } from '@antadesign/anta'
|
|
344
|
+
|
|
345
|
+
configure(React.createElement, React.Fragment, React, { hydratingEvents: true })
|
|
333
346
|
```
|
|
334
347
|
|
|
335
348
|
Both setups work with Next.js's default Turbopack bundler.
|
|
@@ -337,8 +350,9 @@ Both setups work with Next.js's default Turbopack bundler.
|
|
|
337
350
|
### Preact with compat
|
|
338
351
|
|
|
339
352
|
If your bundler aliases `react` to `preact/compat`, Anta needs no `configure()`
|
|
340
|
-
call. Load the entries for your chosen import strategy.
|
|
341
|
-
provides these runtime aliases.
|
|
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).
|
|
342
356
|
|
|
343
357
|
### Preact without compat
|
|
344
358
|
|
|
@@ -349,20 +363,97 @@ to `configure()` before rendering Anta components. For full bundle usage:
|
|
|
349
363
|
import '@antadesign/anta/bundle.css'
|
|
350
364
|
import { configure } from '@antadesign/anta/bundle'
|
|
351
365
|
import { h, Fragment } from 'preact'
|
|
352
|
-
import
|
|
366
|
+
import * as hooks from 'preact/hooks'
|
|
353
367
|
import { useSyncExternalStore } from 'preact/compat'
|
|
354
368
|
|
|
355
|
-
configure(h, Fragment, {
|
|
356
|
-
useState, useId, useMemo, useRef, useLayoutEffect, useSyncExternalStore,
|
|
357
|
-
})
|
|
369
|
+
configure(h, Fragment, { ...hooks, useSyncExternalStore })
|
|
358
370
|
```
|
|
359
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
|
+
|
|
360
377
|
Import JSX wrappers from `@antadesign/anta/bundle` with this setup. For granular
|
|
361
378
|
usage, import both `configure` and the wrappers from `@antadesign/anta` and load
|
|
362
379
|
the UI entries separately. The root package and the prebuilt bundle each have
|
|
363
380
|
their own renderer configuration, so use `configure` from the same entry as
|
|
364
381
|
your wrappers. The explicit `preact/compat` hook import does not require an alias.
|
|
365
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
|
+
|
|
366
457
|
### TypeScript: typing raw `<a-*>` tags in JSX
|
|
367
458
|
|
|
368
459
|
JSX wrappers such as `<Button>` and `<Progress>` need no extra typing. Configure
|
|
@@ -420,7 +511,9 @@ bundler that processes module scripts and CSS imports:
|
|
|
420
511
|
import '@antadesign/anta/elements/a-progress'
|
|
421
512
|
</script>
|
|
422
513
|
|
|
423
|
-
<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>
|
|
424
517
|
```
|
|
425
518
|
|
|
426
519
|
An import map resolves module names but does not process the plain CSS imports
|
|
@@ -436,7 +529,9 @@ and root color scheme, including scrollbar colors. The reset, included in
|
|
|
436
529
|
```html
|
|
437
530
|
<html class="dark">
|
|
438
531
|
<body>
|
|
439
|
-
<a-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>
|
|
440
535
|
</body>
|
|
441
536
|
</html>
|
|
442
537
|
```
|
|
@@ -530,21 +625,83 @@ the range your font declares to avoid combining `slnt` with a synthetic oblique.
|
|
|
530
625
|
|
|
531
626
|
## Browser support
|
|
532
627
|
|
|
533
|
-
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.
|
|
534
632
|
|
|
535
633
|
| Browser | Minimum version |
|
|
536
634
|
| --- | --- |
|
|
537
|
-
| Chrome / Edge
|
|
538
|
-
| Safari | 17.4
|
|
539
|
-
| Firefox
|
|
635
|
+
| Chrome / Edge, including Android Chrome and WebView | 135 |
|
|
636
|
+
| Safari / iOS Safari | 17.4 |
|
|
637
|
+
| Firefox, including Android Firefox | 136 |
|
|
540
638
|
|
|
541
|
-
|
|
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
|
|
542
641
|
OKLCH, `:has()`, `dvh`, cascade layers, and constructable shadow DOM. Older
|
|
543
642
|
browsers can fail hard, including `:state()` being unrecognized or
|
|
544
643
|
`showPopover()` throwing. Gate Anta on your own support matrix when you support
|
|
545
644
|
older browsers.
|
|
546
645
|
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
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.
|