@acronis-platform/ui-react 2.0.0 → 4.0.0
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/dist/components/ui/accordion-container/accordion-container.js +144 -0
- package/dist/components/ui/accordion-container/accordion-container.js.map +1 -0
- package/dist/components/ui/app-shell-chat/app-shell-chat.js.map +1 -1
- package/dist/components/ui/area-chart/area-chart.js +141 -139
- package/dist/components/ui/area-chart/area-chart.js.map +1 -1
- package/dist/components/ui/avatar/avatar.js +33 -22
- package/dist/components/ui/avatar/avatar.js.map +1 -1
- package/dist/components/ui/bar-chart/bar-chart.js +295 -293
- package/dist/components/ui/bar-chart/bar-chart.js.map +1 -1
- package/dist/components/ui/card/card.js +150 -74
- package/dist/components/ui/card/card.js.map +1 -1
- package/dist/components/ui/card-section/card-section.js +111 -0
- package/dist/components/ui/card-section/card-section.js.map +1 -0
- package/dist/components/ui/category-bar/category-bar.js +109 -93
- package/dist/components/ui/category-bar/category-bar.js.map +1 -1
- package/dist/components/ui/chart/chart-palette.js +113 -0
- package/dist/components/ui/chart/chart-palette.js.map +1 -0
- package/dist/components/ui/chart/chart.js +176 -129
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/chart-state/chart-state-illustrations.js +310 -0
- package/dist/components/ui/chart-state/chart-state-illustrations.js.map +1 -0
- package/dist/components/ui/chart-state/chart-state.js +48 -34
- package/dist/components/ui/chart-state/chart-state.js.map +1 -1
- package/dist/components/ui/chart-widget/chart-widget.js +87 -0
- package/dist/components/ui/chart-widget/chart-widget.js.map +1 -0
- package/dist/components/ui/composed-chart/composed-chart.js +117 -115
- package/dist/components/ui/composed-chart/composed-chart.js.map +1 -1
- package/dist/components/ui/confidence-cone/confidence-cone.js +166 -158
- package/dist/components/ui/confidence-cone/confidence-cone.js.map +1 -1
- package/dist/components/ui/data-table/data-table.js +4 -2
- package/dist/components/ui/data-table/data-table.js.map +1 -1
- package/dist/components/ui/empty-overlay/empty-overlay.js +49 -0
- package/dist/components/ui/empty-overlay/empty-overlay.js.map +1 -0
- package/dist/components/ui/funnel-chart/funnel-chart.js +162 -161
- package/dist/components/ui/funnel-chart/funnel-chart.js.map +1 -1
- package/dist/components/ui/histogram/histogram.js +94 -92
- package/dist/components/ui/histogram/histogram.js.map +1 -1
- package/dist/components/ui/input/input.js.map +1 -1
- package/dist/components/ui/label/label.js +2 -9
- package/dist/components/ui/label/label.js.map +1 -1
- package/dist/components/ui/line-chart/line-chart.js +143 -141
- package/dist/components/ui/line-chart/line-chart.js.map +1 -1
- package/dist/components/ui/metric/metric.js +74 -185
- package/dist/components/ui/metric/metric.js.map +1 -1
- package/dist/components/ui/page-content/page-content.js.map +1 -1
- package/dist/components/ui/pie-chart/pie-chart.js +201 -195
- package/dist/components/ui/pie-chart/pie-chart.js.map +1 -1
- package/dist/components/ui/radar-chart/radar-chart.js +133 -131
- package/dist/components/ui/radar-chart/radar-chart.js.map +1 -1
- package/dist/components/ui/radial-bar-chart/radial-bar-chart.js +297 -265
- package/dist/components/ui/radial-bar-chart/radial-bar-chart.js.map +1 -1
- package/dist/components/ui/sankey-chart/sankey-chart.js +123 -101
- package/dist/components/ui/sankey-chart/sankey-chart.js.map +1 -1
- package/dist/components/ui/scatter-chart/scatter-chart.js +76 -74
- package/dist/components/ui/scatter-chart/scatter-chart.js.map +1 -1
- package/dist/components/ui/section/section.js +157 -31
- package/dist/components/ui/section/section.js.map +1 -1
- package/dist/components/ui/stepper/stepper.js +24 -24
- package/dist/components/ui/stepper/stepper.js.map +1 -1
- package/dist/components/ui/stepper-item/stepper-item.js +43 -24
- package/dist/components/ui/stepper-item/stepper-item.js.map +1 -1
- package/dist/components/ui/table/table.js +27 -27
- package/dist/components/ui/table/table.js.map +1 -1
- package/dist/components/ui/treemap/treemap.js +133 -124
- package/dist/components/ui/treemap/treemap.js.map +1 -1
- package/dist/components/ui/trend-indicator/trend-indicator.js +34 -69
- package/dist/components/ui/trend-indicator/trend-indicator.js.map +1 -1
- package/dist/components/ui/wizard/wizard.js +59 -0
- package/dist/components/ui/wizard/wizard.js.map +1 -0
- package/dist/hooks/use-wizard.js +75 -0
- package/dist/hooks/use-wizard.js.map +1 -0
- package/dist/index.js +540 -525
- package/dist/index.js.map +1 -1
- package/dist/llms/accordion-container.md +181 -0
- package/dist/llms/accordion.md +124 -0
- package/dist/llms/alert.md +225 -0
- package/dist/llms/app-shell-chat.md +415 -0
- package/dist/llms/area-chart.md +355 -0
- package/dist/llms/avatar.md +208 -0
- package/dist/llms/bar-chart.md +406 -0
- package/dist/llms/breadcrumb.md +326 -0
- package/dist/llms/button-group.md +298 -0
- package/dist/llms/button-icon-input.md +142 -0
- package/dist/llms/button-icon-menu.md +209 -0
- package/dist/llms/button-icon.md +128 -0
- package/dist/llms/button-menu.md +172 -0
- package/dist/llms/button.md +185 -0
- package/dist/llms/calendar-panel.md +733 -0
- package/dist/llms/calendar.md +188 -0
- package/dist/llms/card-filter.md +214 -0
- package/dist/llms/card-section.md +293 -0
- package/dist/llms/card.md +447 -0
- package/dist/llms/carousel-dialog.md +156 -0
- package/dist/llms/category-bar.md +193 -0
- package/dist/llms/chart-state.md +190 -0
- package/dist/llms/chart-widget.md +209 -0
- package/dist/llms/chart.md +182 -0
- package/dist/llms/checkbox.md +257 -0
- package/dist/llms/chip.md +195 -0
- package/dist/llms/combobox.md +164 -0
- package/dist/llms/composed-chart.md +508 -0
- package/dist/llms/confidence-cone.md +277 -0
- package/dist/llms/data-table.md +474 -0
- package/dist/llms/date-range-picker.md +272 -0
- package/dist/llms/description-list.md +131 -0
- package/dist/llms/dialog-footer-carousel.md +147 -0
- package/dist/llms/dialog-footer-default.md +142 -0
- package/dist/llms/dialog-root.md +246 -0
- package/dist/llms/dialog-welcome.md +223 -0
- package/dist/llms/dialog.md +403 -0
- package/dist/llms/dropdown-menu.md +193 -0
- package/dist/llms/empty-overlay.md +146 -0
- package/dist/llms/empty.md +156 -0
- package/dist/llms/field.md +185 -0
- package/dist/llms/filter-cards.md +157 -0
- package/dist/llms/filter-chips.md +323 -0
- package/dist/llms/filter-search.md +512 -0
- package/dist/llms/form.md +154 -0
- package/dist/llms/funnel-chart.md +333 -0
- package/dist/llms/grid.md +80 -0
- package/dist/llms/histogram.md +190 -0
- package/dist/llms/input-date-picker.md +203 -0
- package/dist/llms/input-otp.md +173 -0
- package/dist/llms/input-password.md +197 -0
- package/dist/llms/input-search.md +170 -0
- package/dist/llms/input-select.md +278 -0
- package/dist/llms/input-text-area.md +271 -0
- package/dist/llms/input-text.md +192 -0
- package/dist/llms/line-chart.md +369 -0
- package/dist/llms/link.md +209 -0
- package/dist/llms/loading.md +130 -0
- package/dist/llms/meter.md +177 -0
- package/dist/llms/metric.md +204 -0
- package/dist/llms/number-field.md +122 -0
- package/dist/llms/page-content.md +69 -0
- package/dist/llms/page-header.md +182 -0
- package/dist/llms/pagination.md +133 -0
- package/dist/llms/pie-chart.md +307 -0
- package/dist/llms/popover.md +252 -0
- package/dist/llms/progress-circle.md +126 -0
- package/dist/llms/progress.md +111 -0
- package/dist/llms/radar-chart.md +316 -0
- package/dist/llms/radial-bar-chart.md +319 -0
- package/dist/llms/radio.md +255 -0
- package/dist/llms/resizable.md +195 -0
- package/dist/llms/sankey-chart.md +208 -0
- package/dist/llms/scatter-chart.md +239 -0
- package/dist/llms/scroll-area.md +183 -0
- package/dist/llms/section.md +401 -0
- package/dist/llms/select.md +210 -0
- package/dist/llms/separator.md +87 -0
- package/dist/llms/sheet.md +202 -0
- package/dist/llms/sidebar-primary.md +360 -0
- package/dist/llms/sidebar-secondary.md +417 -0
- package/dist/llms/skeleton.md +81 -0
- package/dist/llms/slider.md +97 -0
- package/dist/llms/spinner.md +100 -0
- package/dist/llms/stack.md +80 -0
- package/dist/llms/stepper-item.md +309 -0
- package/dist/llms/stepper.md +251 -0
- package/dist/llms/switch.md +140 -0
- package/dist/llms/table.md +436 -0
- package/dist/llms/tabs.md +197 -0
- package/dist/llms/tag.md +139 -0
- package/dist/llms/timeline.md +361 -0
- package/dist/llms/timer.md +259 -0
- package/dist/llms/toast.md +241 -0
- package/dist/llms/toggle-group.md +121 -0
- package/dist/llms/toolbar.md +453 -0
- package/dist/llms/tooltip.md +164 -0
- package/dist/llms/treemap.md +254 -0
- package/dist/llms/trend-indicator.md +132 -0
- package/dist/llms/widget-placeholder.md +169 -0
- package/dist/llms/wizard.md +412 -0
- package/dist/llms.txt +142 -0
- package/dist/react.js +540 -525
- package/dist/react.js.map +1 -1
- package/dist/src/components/ui/accordion-container/accordion-container.d.ts +44 -0
- package/dist/src/components/ui/accordion-container/index.d.ts +1 -0
- package/dist/src/components/ui/area-chart/area-chart.d.ts +9 -4
- package/dist/src/components/ui/avatar/avatar.d.ts +27 -8
- package/dist/src/components/ui/bar-chart/bar-chart.d.ts +9 -4
- package/dist/src/components/ui/button/button.d.ts +1 -1
- package/dist/src/components/ui/card/card.d.ts +69 -8
- package/dist/src/components/ui/card/index.d.ts +1 -1
- package/dist/src/components/ui/card-section/card-section.d.ts +50 -0
- package/dist/src/components/ui/card-section/index.d.ts +1 -0
- package/dist/src/components/ui/category-bar/category-bar.d.ts +10 -4
- package/dist/src/components/ui/chart/__stories__/palette-control.d.ts +48 -0
- package/dist/src/components/ui/chart/__tests__/chart-palette.test.d.ts +1 -0
- package/dist/src/components/ui/chart/chart-palette.d.ts +128 -0
- package/dist/src/components/ui/chart/chart.d.ts +66 -15
- package/dist/src/components/ui/chart/index.d.ts +4 -2
- package/dist/src/components/ui/chart-state/chart-state-illustrations.d.ts +6 -0
- package/dist/src/components/ui/chart-state/chart-state.d.ts +13 -2
- package/dist/src/components/ui/chart-state/index.d.ts +1 -0
- package/dist/src/components/ui/chart-widget/chart-widget.d.ts +64 -0
- package/dist/src/components/ui/chart-widget/index.d.ts +1 -0
- package/dist/src/components/ui/composed-chart/composed-chart.d.ts +12 -7
- package/dist/src/components/ui/confidence-cone/confidence-cone.d.ts +10 -5
- package/dist/src/components/ui/dialog/dialog.d.ts +1 -1
- package/dist/src/components/ui/empty-overlay/empty-overlay.d.ts +20 -0
- package/dist/src/components/ui/empty-overlay/index.d.ts +2 -0
- package/dist/src/components/ui/funnel-chart/funnel-chart.d.ts +11 -5
- package/dist/src/components/ui/grid/grid.d.ts +1 -1
- package/dist/src/components/ui/histogram/histogram.d.ts +10 -4
- package/dist/src/components/ui/label/index.d.ts +1 -1
- package/dist/src/components/ui/label/label.d.ts +1 -5
- package/dist/src/components/ui/line-chart/line-chart.d.ts +9 -4
- package/dist/src/components/ui/metric/metric.d.ts +13 -14
- package/dist/src/components/ui/pie-chart/pie-chart.d.ts +17 -8
- package/dist/src/components/ui/radar-chart/radar-chart.d.ts +10 -5
- package/dist/src/components/ui/radial-bar-chart/radial-bar-chart.d.ts +17 -6
- package/dist/src/components/ui/sankey-chart/sankey-chart.d.ts +10 -5
- package/dist/src/components/ui/scatter-chart/scatter-chart.d.ts +10 -5
- package/dist/src/components/ui/section/index.d.ts +1 -1
- package/dist/src/components/ui/section/section.d.ts +75 -6
- package/dist/src/components/ui/sheet/sheet.d.ts +1 -1
- package/dist/src/components/ui/stack/stack.d.ts +1 -1
- package/dist/src/components/ui/stepper-item/stepper-item.d.ts +6 -5
- package/dist/src/components/ui/tag/tag.d.ts +1 -1
- package/dist/src/components/ui/treemap/treemap.d.ts +11 -5
- package/dist/src/components/ui/trend-indicator/trend-indicator.d.ts +3 -7
- package/dist/src/components/ui/wizard/index.d.ts +1 -0
- package/dist/src/components/ui/wizard/wizard.d.ts +6 -0
- package/dist/src/hooks/index.d.ts +1 -0
- package/dist/src/hooks/use-wizard.d.ts +80 -0
- package/dist/src/index.d.ts +5 -3
- package/dist/ui-react.css +1 -1
- package/package.json +12 -6
- package/dist/components/ui/app-shell/app-shell.js +0 -75
- package/dist/components/ui/app-shell/app-shell.js.map +0 -1
- package/dist/components/ui/auth-layout/auth-layout.js +0 -56
- package/dist/components/ui/auth-layout/auth-layout.js.map +0 -1
- package/dist/components/ui/collapsible/collapsible.js +0 -22
- package/dist/components/ui/collapsible/collapsible.js.map +0 -1
- package/dist/src/components/ui/app-shell/app-shell.d.ts +0 -8
- package/dist/src/components/ui/app-shell/index.d.ts +0 -1
- package/dist/src/components/ui/auth-layout/auth-layout.d.ts +0 -6
- package/dist/src/components/ui/auth-layout/index.d.ts +0 -1
- package/dist/src/components/ui/collapsible/collapsible.d.ts +0 -5
- package/dist/src/components/ui/collapsible/index.d.ts +0 -1
- package/dist/src/components/ui/label/label.docs.d.ts +0 -10
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
# AreaChart
|
|
2
|
+
|
|
3
|
+
> A typed area-chart composition over the shared `Chart` primitives. Takes `data` + `config` + a set of series `dataKeys` and renders a themed recharts `AreaChart` inside a `ChartContainer`, with tooltip and legend chrome. Two variant axes: `layout` (single / stacked areas) and `fill` (solid flat fill / vertical gradient); single vs multi area is driven by the number of `dataKeys`. Ported from the apps/demo `AreaChartPlayground`.
|
|
4
|
+
|
|
5
|
+
**Status:** draft · **Category:** data-display · **Since:** v0.58.0
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { AreaChart } from '@acronis-platform/ui-react'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick example
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<AreaChart
|
|
17
|
+
config={config}
|
|
18
|
+
data={data}
|
|
19
|
+
dataKeys={['desktop', 'mobile']}
|
|
20
|
+
xKey="month"
|
|
21
|
+
layout="single"
|
|
22
|
+
fill="gradient"
|
|
23
|
+
className="h-[320px] w-[560px]"
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
A typed area-chart built on the shared `Chart` primitives. Give it `data`, a
|
|
28
|
+
per-series `config`, the series to plot (`dataKeys`), and the category key
|
|
29
|
+
(`xKey`); it renders a themed recharts `AreaChart` — tooltip, legend, axes, and
|
|
30
|
+
grid included — so you don't hand-compose recharts children.
|
|
31
|
+
|
|
32
|
+
Series colors come from the `palette` prop — a dataviz palette resolving to the
|
|
33
|
+
`--ui-dataviz-*` tokens, `categorical` by default — not from `config`.
|
|
34
|
+
|
|
35
|
+
> **Design-pending v1.** Ported from the apps/demo `AreaChartPlayground`. The
|
|
36
|
+
> chrome is reconciled with Figma later; Code Connect is deferred.
|
|
37
|
+
|
|
38
|
+
## When to use
|
|
39
|
+
|
|
40
|
+
- Emphasizing the magnitude of a trend over a continuous or ordered dimension
|
|
41
|
+
(traffic over time, cumulative usage).
|
|
42
|
+
- Showing part-to-whole composition over time — with `layout="stacked"`.
|
|
43
|
+
|
|
44
|
+
## When not to use
|
|
45
|
+
|
|
46
|
+
- Comparing exact values across a few series — a line chart reads more precisely
|
|
47
|
+
(overlapping fills obscure each other).
|
|
48
|
+
- Comparing a quantity across discrete categories — use a bar chart.
|
|
49
|
+
- A single metric or KPI — use a `Tag`, `Badge`, or plain text.
|
|
50
|
+
- Tabular detail — use `Table` / `DataTable`.
|
|
51
|
+
|
|
52
|
+
## Variants
|
|
53
|
+
|
|
54
|
+
| Axis | Values | Effect |
|
|
55
|
+
| -------- | -------------------- | ----------------------------------------------------------- |
|
|
56
|
+
| `layout` | `single` · `stacked` | Overlapping independent areas vs summed on a shared stack. |
|
|
57
|
+
| `fill` | `solid` · `gradient` | Flat translucent fill vs a vertical top-to-bottom gradient. |
|
|
58
|
+
|
|
59
|
+
Single vs multi area is not a variant — it follows from how many `dataKeys` you
|
|
60
|
+
plot.
|
|
61
|
+
|
|
62
|
+
## Example
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { AreaChart } from '@acronis-platform/ui-react';
|
|
66
|
+
import type { ChartConfig } from '@acronis-platform/ui-react';
|
|
67
|
+
|
|
68
|
+
const data = [
|
|
69
|
+
{ month: 'Jan', desktop: 186, mobile: 80 },
|
|
70
|
+
{ month: 'Feb', desktop: 305, mobile: 200 },
|
|
71
|
+
{ month: 'Mar', desktop: 237, mobile: 120 },
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const config = {
|
|
75
|
+
desktop: { label: 'Desktop', color: 'var(--ui-background-brand-secondary)' },
|
|
76
|
+
mobile: {
|
|
77
|
+
label: 'Mobile',
|
|
78
|
+
color: 'var(--ui-background-status-strong-danger)',
|
|
79
|
+
},
|
|
80
|
+
} satisfies ChartConfig;
|
|
81
|
+
|
|
82
|
+
<AreaChart
|
|
83
|
+
config={config}
|
|
84
|
+
data={data}
|
|
85
|
+
dataKeys={['desktop', 'mobile']}
|
|
86
|
+
xKey="month"
|
|
87
|
+
className="h-[320px] w-[560px]"
|
|
88
|
+
/>;
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Series colors reference existing semantic `--ui-*` tokens. `--ui-background-status-strong-*`
|
|
92
|
+
is chromatic in every brand; `--ui-background-brand-secondary` is brand-dependent
|
|
93
|
+
(blue in `default`, neutral in some white-label brands), so it is not color-stable
|
|
94
|
+
across brands until the real data-viz palette lands.
|
|
95
|
+
|
|
96
|
+
## Props
|
|
97
|
+
|
|
98
|
+
| Prop | Type | Default | Required | Description |
|
|
99
|
+
|------|------|---------|----------|-------------|
|
|
100
|
+
| `layout` | `'single' | 'stacked'` | `'single'` | no | How multiple series are arranged. `single` = areas overlap independently; `stacked` = areas share a `stackId` and sum into one band. |
|
|
101
|
+
| `fill` | `'solid' | 'gradient'` | `'gradient'` | no | How each area is filled. `solid` = a flat translucent fill (`fillOpacity`); `gradient` = a vertical top-opaque → bottom-transparent gradient. |
|
|
102
|
+
| `data` | `ReadonlyArray<Record<string, string | number | null>>` | — | yes | Row-per-point data — each row holds `xKey` plus one numeric field per series. A `null` breaks the area at that point unless `connectNulls`. |
|
|
103
|
+
| `config` | `ChartConfig` | — | yes | Series take their colour from the container's `palette`; each entry maps a data key to a `label` and an optional `tone`. Resolved into the `--color-<key>` custom properties the areas stroke and fill from. |
|
|
104
|
+
| `dataKeys` | `string[]` | — | yes | Series to plot — one area per key. Each must exist in `config` and every data row. |
|
|
105
|
+
| `xKey` | `string` | — | yes | The category dimension key shared across rows. |
|
|
106
|
+
| `xAxisLabel` | `string` | — | no | Title rendered beneath the horizontal (X) axis. |
|
|
107
|
+
| `yAxisLabel` | `string` | — | no | Title rendered beside the vertical (Y) axis (rotated). |
|
|
108
|
+
| `yUnit` | `string` | — | no | Unit suffix appended to Y-axis tick values (recharts `unit`); the X axis is categorical. |
|
|
109
|
+
| `curve` | `'linear' | 'monotone' | 'natural' | 'basis' | 'step' | 'stepBefore' | 'stepAfter'` | `'monotone'` | no | Interpolation between points. `linear` = straight segments; `monotone` = a smoothed curve that never overshoots a point; `natural` = a natural cubic spline (smoother, may overshoot); `basis` = the smoothest option, and not required to pass through the points at all; `step` = right-angle segments changing at the midpoint, with `stepBefore` / `stepAfter` changing at the leading or trailing point instead. |
|
|
110
|
+
| `strokeWidth` | `number` | `2` | no | Stroke width of each area's top border. |
|
|
111
|
+
| `fillOpacity` | `number` | `0.4` | no | Flat-fill opacity — applies only when `fill="solid"`. |
|
|
112
|
+
| `showDots` | `boolean` | `false` | no | Render a dot at each data point. |
|
|
113
|
+
| `dotSize` | `number` | `3` | no | Radius of each point's dot, in px. Its hover dot is 2px larger. |
|
|
114
|
+
| `showActiveDot` | `boolean` | — | no | Enlarge the hovered point's dot. Defaults to following `showDots`, so set it explicitly for a hover-only area (dots off, active dot on) or a static-only area (dots on, active dot off). |
|
|
115
|
+
| `areaSettings` | `Record<string, { color?: string; strokeWidth?: number; dashed?: boolean; curveType?: CurveType; fillOpacity?: number; showDots?: boolean; dotSize?: number; showLabel?: boolean; labelPosition?: LabelPosition }>` | — | no | Per-series style override keyed by `dataKeys` entry — anything unset falls back to the chart-wide prop, so an entry states only what differs (e.g. a faint dashed projection beside solid actuals). `color` also recolors that series' gradient stops; under `fill="gradient"` a `fillOpacity` scales the gradient's own alpha rather than replacing it. |
|
|
116
|
+
| `referenceLine` | `Line | Line[] where Line = { value?: number; average?: boolean | string; label?: string; labelPosition?: 'top' | 'insideTopLeft' | 'insideTopRight' | 'insideBottomLeft' | 'insideBottomRight' }` | — | no | One or more dashed reference/average lines on the value axis. Pass a single object or an array. Per line, a fixed `value` wins; otherwise the mean of one series (`average: '<key>'`) or of every plotted series (`average: true`). An optional `label` captions each, at the rule's top right unless `labelPosition` moves it away from a series it would sit on. On a stacked chart the value is read against the stack's axis, which measures stack totals — `average` still means the mean of the individual series' values, so pass an explicit `value` when the rule should compare against the stacked total. The same config shape as `BarChart` / `LineChart`. |
|
|
117
|
+
| `connectNulls` | `boolean` | `false` | no | Bridge `null` gaps in the data instead of breaking the area. |
|
|
118
|
+
| `showGrid` | `boolean` | `true` | no | Render the CartesianGrid. |
|
|
119
|
+
| `showTooltip` | `boolean` | `true` | no | Render the hover tooltip. |
|
|
120
|
+
| `showLegend` | `boolean` | `true` | no | Render the legend. |
|
|
121
|
+
| `tooltipContent` | `ReactElement | ((props) => ReactNode)` | — | no | Replace the default tooltip. Pass a configured ChartTooltipContent (from this library) — e.g. with a formatter / labelFormatter — to customize the tooltip content without composing recharts. Ignored when showTooltip is false. |
|
|
122
|
+
| `showXAxis` | `boolean` | `true` | no | Render the X axis (its ticks and title). Set false to hide it. |
|
|
123
|
+
| `showYAxis` | `boolean` | `true` | no | Render the Y axis (its ticks and title). Set false to hide it. |
|
|
124
|
+
| `xTickFormatter` | `(value: number | string, index?: number) => string` | — | no | Format each X-axis tick value. Unlike the `unit` suffix (append-only), a formatter transforms the value — abbreviate, prefix a symbol, or map to a label. Use formatCompactNumber / formatPercent / createTickFormatter from the shared Chart primitives, or any function. |
|
|
125
|
+
| `yTickFormatter` | `(value: number | string, index?: number) => string` | — | no | Format each Y-axis tick value (see xTickFormatter). |
|
|
126
|
+
| `xAxisAngle` | `number` | — | no | Rotate the X-axis tick labels by this many degrees (a negative angle tilts them up toward the right); the tick anchor + axis height adjust. |
|
|
127
|
+
| `xAxisInterval` | `number | 'preserveStart' | 'preserveEnd' | 'preserveStartEnd' | 'equidistantPreserveStart'` | — | no | X-axis tick density — a recharts placement strategy, or a fixed number of ticks to skip between two rendered ones (recharts interval: 0 shows every tick, 1 every other one, 2 every third). |
|
|
128
|
+
| `yAxisTickCount` | `number` | — | no | Desired number of ticks on the value axis (recharts tickCount; a hint, not exact). Applies to whichever axis holds the values — Y for most charts, X for BarChart with orientation="horizontal". |
|
|
129
|
+
| `yAxisDomain` | `'auto' | 'dataMin-dataMax' | 'zero'` | — | no | Value-axis domain preset — auto (fit the data at both ends; the axis need not include 0), zero (anchor the axis at 0, which is also recharts' behaviour when the prop is omitted), or dataMin-dataMax (tight to the data, no padding). Applies to whichever axis holds the values — Y for most charts, X for BarChart with orientation="horizontal". |
|
|
130
|
+
| `gridDashed` | `boolean` | — | no | Draw grid lines dashed instead of solid. |
|
|
131
|
+
| `gridHorizontal` | `boolean` | — | no | Show horizontal grid lines (defaults to the chart's own default when unset). |
|
|
132
|
+
| `gridVertical` | `boolean` | — | no | Show vertical grid lines (defaults to the chart's own default when unset). |
|
|
133
|
+
| `animate` | `boolean` | `false` | no | Enable entrance animation. Off by default so output/baselines are unchanged. |
|
|
134
|
+
| `animationDuration` | `number` | — | no | Animation duration in ms. |
|
|
135
|
+
| `animationBegin` | `number` | — | no | Delay before the animation starts, in ms. |
|
|
136
|
+
| `animationEasing` | `'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'` | — | no | Easing curve. |
|
|
137
|
+
| `showLabels` | `boolean` | `false` | no | Render a value label on each data point/segment. |
|
|
138
|
+
| `labelPosition` | `'top' | 'bottom' | 'left' | 'right' | 'center' | 'insideTop' | 'insideBottom' | 'insideLeft' | 'insideRight' | 'insideStart' | 'insideEnd'` | — | no | Where the value labels sit. |
|
|
139
|
+
| `labelFormatter` | `(value) => string` | — | no | Format each label value (reuses the tick formatters). |
|
|
140
|
+
| `showBrush` | `boolean` | `false` | no | Render a range brush beneath the chart — drag a handle (or the selected window) to zoom the series into a slice of the data. |
|
|
141
|
+
| `brushHeight` | `number` | `28` | no | Height of the brush strip in px. A non-positive value falls back to the default rather than erasing the brush. |
|
|
142
|
+
| `brushAriaLabel` | `string` | `'Chart range selector'` | no | Accessible name for the brush's two range handles, which are focusable `role="slider"` elements. Consumers localize by passing their own. |
|
|
143
|
+
|
|
144
|
+
## Behavior
|
|
145
|
+
|
|
146
|
+
`AreaChart` is a typed [recharts](https://recharts.org) composition over the
|
|
147
|
+
shared `Chart` primitives. It takes `data`, a per-series `config`, the series to
|
|
148
|
+
plot (`dataKeys`), and the category key (`xKey`), and renders a themed recharts
|
|
149
|
+
`AreaChart` inside a `ChartContainer`.
|
|
150
|
+
|
|
151
|
+
```gherkin
|
|
152
|
+
Scenario: Render areas from data and config
|
|
153
|
+
Given data rows and a config mapping each series key to a label and color
|
|
154
|
+
And dataKeys ["desktop", "mobile"]
|
|
155
|
+
Then one <Area> renders per dataKey
|
|
156
|
+
And each area strokes and fills from its injected --color-<key> custom property
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```gherkin
|
|
160
|
+
Scenario: Single layout (default)
|
|
161
|
+
Given layout is "single" and two or more dataKeys
|
|
162
|
+
Then each area is plotted independently and they may overlap
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
```gherkin
|
|
166
|
+
Scenario: Stacked layout
|
|
167
|
+
Given layout is "stacked" and two or more dataKeys
|
|
168
|
+
Then the areas share a stackId and sum into one band
|
|
169
|
+
And the value axis grows to the stacked total
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
```gherkin
|
|
173
|
+
Scenario: Gradient fill (default)
|
|
174
|
+
Given fill is "gradient"
|
|
175
|
+
Then a vertical linear gradient (top-opaque to bottom-transparent) is defined per series
|
|
176
|
+
And each area fills from its gradient
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```gherkin
|
|
180
|
+
Scenario: Solid fill
|
|
181
|
+
Given fill is "solid"
|
|
182
|
+
Then no gradient defs are emitted
|
|
183
|
+
And each area fills flat at fillOpacity
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```gherkin
|
|
187
|
+
Scenario: Curve interpolation (default monotone)
|
|
188
|
+
Given curve is one of linear, monotone, natural, basis, step, stepBefore, stepAfter
|
|
189
|
+
Then every area's top edge uses that recharts `type`
|
|
190
|
+
And "natural" smooths further than "monotone" and may overshoot, while "basis" need not pass through the points
|
|
191
|
+
And "stepBefore" / "stepAfter" move the step to the leading or trailing point
|
|
192
|
+
And each type draws distinct geometry — an unrecognized value would silently fall back to straight segments
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
```gherkin
|
|
196
|
+
Scenario: Dots
|
|
197
|
+
Given showDots is true
|
|
198
|
+
Then a dot renders at each data point with radius dotSize
|
|
199
|
+
And hovering a point enlarges its active dot by 2px
|
|
200
|
+
And showActiveDot decides the hover dot on its own when set, instead of following showDots
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
```gherkin
|
|
204
|
+
Scenario: Restyle one series
|
|
205
|
+
Given areaSettings maps "mobile" to { dashed: true, fillOpacity: 0.1, showDots: false }
|
|
206
|
+
Then only the "mobile" area has a dashed top edge, a fainter fill, and no dots
|
|
207
|
+
And every other series renders from the chart-wide props
|
|
208
|
+
And an unset field in the entry falls back to the chart-wide prop
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
```gherkin
|
|
212
|
+
Scenario: Recolor one series
|
|
213
|
+
Given areaSettings maps a series to a color
|
|
214
|
+
And fill is "gradient"
|
|
215
|
+
Then that series' gradient stops take the override color, not its config color
|
|
216
|
+
And the other series keep their config colors
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
```gherkin
|
|
220
|
+
Scenario: Per-series value labels
|
|
221
|
+
Given areaSettings maps a series to { showLabel: false }
|
|
222
|
+
And showLabels is true
|
|
223
|
+
Then that series renders no value labels while the others do
|
|
224
|
+
And a { showLabel: true } entry labels only that series with showLabels unset
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```gherkin
|
|
228
|
+
Scenario: Reference line
|
|
229
|
+
Given referenceLine is { value: 250, label: "Target" }
|
|
230
|
+
Then a dashed rule draws across the value axis at 250, captioned "Target"
|
|
231
|
+
And it is drawn in the muted text token, over the series
|
|
232
|
+
And the axis domain extends to include it, so a target above the data maximum stays visible
|
|
233
|
+
And the caption sits at the rule's top right unless labelPosition moves it
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
```gherkin
|
|
237
|
+
Scenario: Averaged reference line
|
|
238
|
+
Given referenceLine is { average: true } (or a single series key)
|
|
239
|
+
Then the rule draws at the mean of every plotted series' values (or that one series)
|
|
240
|
+
And null values are skipped rather than counted as zero
|
|
241
|
+
And when there is nothing numeric to average, no rule is drawn
|
|
242
|
+
But under layout="stacked" the axis measures stack totals while the mean is still per-series,
|
|
243
|
+
so an explicit value is the honest way to compare against the stacked total
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```gherkin
|
|
247
|
+
Scenario: Multiple reference lines
|
|
248
|
+
Given referenceLine is an array of configs (e.g. a fixed target and an average)
|
|
249
|
+
Then one dashed rule draws per config
|
|
250
|
+
And each is resolved independently (a config with nothing to draw is skipped)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
```gherkin
|
|
254
|
+
Scenario: Null gaps
|
|
255
|
+
Given a data row has a null value for a series
|
|
256
|
+
And connectNulls is false
|
|
257
|
+
Then that area breaks at the gap
|
|
258
|
+
But when connectNulls is true the area bridges the gap
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```gherkin
|
|
262
|
+
Scenario: Tooltip on hover
|
|
263
|
+
Given showTooltip is true
|
|
264
|
+
When the user hovers a point
|
|
265
|
+
Then a card shows the category label and one row per series (indicator + value)
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
```gherkin
|
|
269
|
+
Scenario: Legend
|
|
270
|
+
Given showLegend is true
|
|
271
|
+
Then a swatch + label renders for each series in dataKeys
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
```gherkin
|
|
275
|
+
Scenario: Empty data
|
|
276
|
+
Given data is an empty array
|
|
277
|
+
Then the chart renders its axes and grid with no areas and does not throw
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
```gherkin
|
|
281
|
+
Scenario: Entrance animation is opt-in
|
|
282
|
+
Given animate is unset
|
|
283
|
+
Then the series render at their final geometry with no entrance animation
|
|
284
|
+
And the committed visual baselines are unaffected
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
```gherkin
|
|
288
|
+
Scenario: Reduced motion
|
|
289
|
+
Given animate is true
|
|
290
|
+
And a user with prefers-reduced-motion
|
|
291
|
+
Then the entrance animation does not play and the series render at their final geometry
|
|
292
|
+
And the same applies when rendering on the server
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
```gherkin
|
|
296
|
+
Scenario: Range brush
|
|
297
|
+
Given showBrush is true
|
|
298
|
+
Then a brush strip renders beneath the plot with a handle at each end
|
|
299
|
+
And dragging a handle (or the selected window) zooms the series to that slice
|
|
300
|
+
And the category axis and tooltip follow the selected range
|
|
301
|
+
And the brush renders whether or not the category axis is shown
|
|
302
|
+
And unset renders no brush
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
```gherkin
|
|
306
|
+
Scenario: Range brush keyboard and accessible name
|
|
307
|
+
Given showBrush is true
|
|
308
|
+
Then each of the two handles is reachable by Tab
|
|
309
|
+
And the focused handle moves one row per left/right arrow key press
|
|
310
|
+
And each handle exposes brushAriaLabel as its accessible name
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Accessibility
|
|
314
|
+
|
|
315
|
+
- recharts' `accessibilityLayer` is **on by default** (recharts v3), giving the
|
|
316
|
+
chart keyboard focus and an accessible description of the plotted points.
|
|
317
|
+
- The **range brush** (`showBrush`) is the only interactive control these charts
|
|
318
|
+
render. It adds two focusable `role="slider"` handles: Tab reaches each one and
|
|
319
|
+
the left/right arrow keys move the selection a row at a time, so the whole
|
|
320
|
+
feature is operable without a pointer.
|
|
321
|
+
- Both handles take their accessible name from `brushAriaLabel` (default
|
|
322
|
+
`'Chart range selector'`); pass your own to localize it. Never leave it to
|
|
323
|
+
recharts' fallback, which names the handles from a `name` field on the data
|
|
324
|
+
row and otherwise announces "Min value: undefined, Max value: undefined".
|
|
325
|
+
- The handles keep a visible focus indicator: the shared `ChartContainer`
|
|
326
|
+
suppresses outlines on recharts layers, so it re-enables one for
|
|
327
|
+
`.recharts-brush-traveller` specifically (an `outline`, since `box-shadow`
|
|
328
|
+
does not paint on SVG children).
|
|
329
|
+
- The two range captions only appear while a handle is hovered, dragged, or
|
|
330
|
+
focused — they are a supplement to the category axis, not a replacement for
|
|
331
|
+
it. Zooming changes which rows are plotted, so **pair the brush with a text
|
|
332
|
+
alternative that reflects the current range** rather than the full series.
|
|
333
|
+
- An area chart is inherently visual. **Pair it with a text alternative** — a
|
|
334
|
+
caption, a summary sentence, or an adjacent data table carrying the same
|
|
335
|
+
numbers — and give the chart an accessible name (`aria-label` /
|
|
336
|
+
`aria-labelledby` referencing a visible heading) when it is meaningful on its
|
|
337
|
+
own. The wrapper forwards native `div` attributes, so `aria-*` pass through.
|
|
338
|
+
- Do **not** rely on color alone to distinguish series. Keep `showLegend` (or the
|
|
339
|
+
tooltip) visible so each color is paired with a text label. Overlapping
|
|
340
|
+
translucent fills can be hard to read — prefer `layout="stacked"` or a solid
|
|
341
|
+
`fill` when legibility matters, and keep enough opacity contrast between series.
|
|
342
|
+
- The chrome (tooltip, legend, axis ticks, grid) resolves to semantic `--ui-*`
|
|
343
|
+
tokens that meet contrast in light and dark. **Series colors are
|
|
344
|
+
caller-supplied** via `config` — pick values that meet 3:1 against the surface
|
|
345
|
+
and are distinguishable for color-vision deficiencies. The borrowed semantic
|
|
346
|
+
tokens are a design-pending stopgap until the `--ui-chart-*` palette lands.
|
|
347
|
+
- Watch recharts issue [#4809](https://github.com/recharts/recharts/issues/4809)
|
|
348
|
+
on the a11y layer for heavily-customized charts.
|
|
349
|
+
|
|
350
|
+
## Contrast
|
|
351
|
+
|
|
352
|
+
Chart chrome meets contrast in both themes via the semantic tokens. Area fills
|
|
353
|
+
and strokes come from `config` and are the caller's responsibility — note that
|
|
354
|
+
translucent fills (solid `fillOpacity`, gradient stops) lower the effective
|
|
355
|
+
contrast against the surface.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Avatar
|
|
2
|
+
|
|
3
|
+
> A user or entity avatar — a circular badge showing a profile image, initials, or an icon. Eight color schemes; stack several with AvatarGroup for an overlapping row.
|
|
4
|
+
|
|
5
|
+
**Status:** ready · **Category:** data-display · **Since:** v0.22.0
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { Avatar, AvatarImage, AvatarFallback, AvatarGroup } from '@acronis-platform/ui-react'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick example
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
<Avatar color="teal">
|
|
17
|
+
<AvatarImage src="/me.png" alt="Sam N." />
|
|
18
|
+
<AvatarFallback>SN</AvatarFallback>
|
|
19
|
+
</Avatar>
|
|
20
|
+
|
|
21
|
+
<Avatar color="blue" label="SB" />
|
|
22
|
+
<Avatar color="blue" variant="icon" icon={<UserIcon size={16} />} />
|
|
23
|
+
|
|
24
|
+
<AvatarGroup>
|
|
25
|
+
<Avatar color="teal"><AvatarFallback>SN</AvatarFallback></Avatar>
|
|
26
|
+
<Avatar color="violet"><AvatarFallback>GA</AvatarFallback></Avatar>
|
|
27
|
+
</AvatarGroup>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A circular badge for a user or entity — a profile image, initials, or an icon
|
|
31
|
+
on a tinted background when no image is available. Eight color schemes. Stack
|
|
32
|
+
several with `AvatarGroup` for an overlapping row (e.g. assignees on a ticket).
|
|
33
|
+
|
|
34
|
+
## When to use
|
|
35
|
+
|
|
36
|
+
- Represent a person/entity next to their name, in a row, table, or comment.
|
|
37
|
+
- Show a set of participants compactly via an overlapping `AvatarGroup`.
|
|
38
|
+
- Use `variant="icon"` for a non-personal entity (a team, a bot, a system
|
|
39
|
+
actor) where an icon reads better than initials.
|
|
40
|
+
|
|
41
|
+
## When not to use
|
|
42
|
+
|
|
43
|
+
- As a button/link target without a proper interactive wrapper (Avatar is
|
|
44
|
+
presentational — wrap it in a control that owns focus and an accessible name).
|
|
45
|
+
- For non-identity imagery (logos, thumbnails, decorative icons) — use an
|
|
46
|
+
image or `Icon` directly.
|
|
47
|
+
|
|
48
|
+
## Parts
|
|
49
|
+
|
|
50
|
+
| Part | Component | Notes |
|
|
51
|
+
| -------- | ---------------- | --------------------------------------------------- |
|
|
52
|
+
| root | `Avatar` | The circle; `color` tints the fallback. |
|
|
53
|
+
| image | `AvatarImage` | Optional; shown once it loads, else the fallback. |
|
|
54
|
+
| fallback | `AvatarFallback` | Initials shown when there's no image (or it fails). |
|
|
55
|
+
| icon | — | Consumer-supplied icon, shown for `variant="icon"`. |
|
|
56
|
+
| group | `AvatarGroup` | Optional overlapping row of avatars. |
|
|
57
|
+
|
|
58
|
+
## Examples
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
// Image with initials fallback
|
|
62
|
+
<Avatar color="teal">
|
|
63
|
+
<AvatarImage src="/me.png" alt="Sam Nguyen" />
|
|
64
|
+
<AvatarFallback>SN</AvatarFallback>
|
|
65
|
+
</Avatar>
|
|
66
|
+
|
|
67
|
+
// Initials only, via children
|
|
68
|
+
<Avatar color="violet">
|
|
69
|
+
<AvatarFallback>GA</AvatarFallback>
|
|
70
|
+
</Avatar>
|
|
71
|
+
|
|
72
|
+
// Initials only, via the `label` convenience prop (equivalent to the above)
|
|
73
|
+
<Avatar color="violet" label="GA" />
|
|
74
|
+
|
|
75
|
+
// Icon avatar (no children composed)
|
|
76
|
+
<Avatar color="gray" variant="icon" icon={<UserIcon size={16} />} />
|
|
77
|
+
|
|
78
|
+
// Overlapping group with a label
|
|
79
|
+
<div className="flex items-center gap-[var(--ui-avatar-global-container-gap)]">
|
|
80
|
+
<AvatarGroup>
|
|
81
|
+
<Avatar color="teal"><AvatarFallback>SN</AvatarFallback></Avatar>
|
|
82
|
+
<Avatar color="violet"><AvatarFallback>GA</AvatarFallback></Avatar>
|
|
83
|
+
<Avatar color="red"><AvatarFallback>SI</AvatarFallback></Avatar>
|
|
84
|
+
</AvatarGroup>
|
|
85
|
+
<span>On this ticket</span>
|
|
86
|
+
</div>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Color schemes
|
|
90
|
+
|
|
91
|
+
`teal` (default), `violet`, `red`, `yellow`, `orange`, `blue`, `gray`, `green`.
|
|
92
|
+
Each pairs a tinted background with a matching initials color from the
|
|
93
|
+
`--ui-avatar-*` token tier.
|
|
94
|
+
|
|
95
|
+
## Variants
|
|
96
|
+
|
|
97
|
+
`text` (default) shows `label` (initials); `icon` shows a consumer-supplied
|
|
98
|
+
`icon`. Both are ignored once `children` (`AvatarImage`/`AvatarFallback`) are
|
|
99
|
+
composed directly — `variant`/`label`/`icon` only drive the no-children case.
|
|
100
|
+
|
|
101
|
+
"No children" means the slot is left unset. Passing an explicit `null` child is
|
|
102
|
+
a deliberate "render nothing" and yields an empty circle rather than the default
|
|
103
|
+
`'SB'` label — that's how `Timeline` renders a blank marker.
|
|
104
|
+
|
|
105
|
+
## Props
|
|
106
|
+
|
|
107
|
+
| Prop | Type | Default | Required | Description |
|
|
108
|
+
|------|------|---------|----------|-------------|
|
|
109
|
+
| `color` | `'teal' | 'violet' | 'red' | 'yellow' | 'orange' | 'blue' | 'gray' | 'green'` | `teal` | no | Color scheme for the fallback. Maps to `--ui-avatar-color-<scheme>` (background) and `--ui-avatar-label-color-<scheme>` (initials). Ignored once an image is shown. |
|
|
110
|
+
| `variant` | `'text' | 'icon'` | `text` | no | Selects the auto-rendered fallback content when no `children` are composed: initials (`label`) or an `icon`. Ignored once `children` (e.g. `AvatarImage`/`AvatarFallback`) are composed directly — including an explicit `null`, which renders an empty circle. |
|
|
111
|
+
| `label` | `string` | `SB` | no | Initials shown for the `text` variant when no `children` are composed. |
|
|
112
|
+
| `icon` | `ReactNode` | — | no | Icon shown for the `icon` variant when no `children` are composed — typically a 16px icon from `@acronis-platform/icons-react`. |
|
|
113
|
+
|
|
114
|
+
## Content slots
|
|
115
|
+
|
|
116
|
+
| Slot | Description |
|
|
117
|
+
|------|-------------|
|
|
118
|
+
| `default` | The avatar's children — an `AvatarImage` and/or an `AvatarFallback` (the initials). When the slot is left unset, `variant`/`label`/`icon` drive the content instead; an explicitly empty (`null`) slot renders an empty circle and does not fall back to them. |
|
|
119
|
+
|
|
120
|
+
## Behavior
|
|
121
|
+
|
|
122
|
+
### Image with a fallback
|
|
123
|
+
|
|
124
|
+
- **Given** an `Avatar` with an `AvatarImage` (valid `src`) and an `AvatarFallback`
|
|
125
|
+
**When** the image is still loading
|
|
126
|
+
**Then** the fallback (initials) is shown until the image finishes loading,
|
|
127
|
+
then the image replaces it.
|
|
128
|
+
|
|
129
|
+
- **Given** an `Avatar` whose image `src` fails to load
|
|
130
|
+
**When** the load errors
|
|
131
|
+
**Then** the fallback remains visible (the broken image is not shown).
|
|
132
|
+
|
|
133
|
+
### Fallback only
|
|
134
|
+
|
|
135
|
+
- **Given** an `Avatar` with only an `AvatarFallback` (no image)
|
|
136
|
+
**Then** the initials render on the `color` scheme's tinted background, using
|
|
137
|
+
that scheme's label color.
|
|
138
|
+
|
|
139
|
+
### `variant` / `label` / `icon` (no children composed)
|
|
140
|
+
|
|
141
|
+
- **Given** an `Avatar` with no `children`
|
|
142
|
+
**Then** `variant` (default `'text'`) selects the auto-rendered content:
|
|
143
|
+
`label` (default `'SB'`) for `'text'`, or `icon` for `'icon'`.
|
|
144
|
+
|
|
145
|
+
- **Given** an `Avatar` with `children` composed (e.g. `AvatarImage`/
|
|
146
|
+
`AvatarFallback`)
|
|
147
|
+
**Then** `variant`/`label`/`icon` have no effect — `children` always takes
|
|
148
|
+
precedence.
|
|
149
|
+
|
|
150
|
+
- **Given** an `Avatar` whose children slot is explicitly empty (`null`) — e.g.
|
|
151
|
+
`Timeline`'s marker with neither an `icon` nor `initials`
|
|
152
|
+
**Then** the circle renders empty. An explicit `null` is a deliberate "render
|
|
153
|
+
nothing", so it does **not** fall back to the default `label` (`'SB'`); only
|
|
154
|
+
an unset (`undefined`) slot does.
|
|
155
|
+
|
|
156
|
+
### Color scheme
|
|
157
|
+
|
|
158
|
+
- **Given** `color="violet"`
|
|
159
|
+
**Then** the background resolves to `--ui-avatar-color-violet` and the initials
|
|
160
|
+
to `--ui-avatar-label-color-violet`. The default scheme is `teal`.
|
|
161
|
+
|
|
162
|
+
- **Given** an avatar showing an image
|
|
163
|
+
**Then** `color` has no visible effect (the image covers the circle).
|
|
164
|
+
|
|
165
|
+
### Group overlap
|
|
166
|
+
|
|
167
|
+
- **Given** an `AvatarGroup` wrapping several `Avatar`s
|
|
168
|
+
**Then** each avatar after the first is offset left by
|
|
169
|
+
`--ui-avatar-global-avatar-group-gap` (a negative value), so the avatars
|
|
170
|
+
overlap; each 2px ring (`--ui-avatar-global-avatar-border-color`, drawn outside
|
|
171
|
+
the 32px circle as a `box-shadow`) separates them, and later avatars paint above
|
|
172
|
+
earlier ones.
|
|
173
|
+
|
|
174
|
+
## Accessibility
|
|
175
|
+
|
|
176
|
+
## Role & semantics
|
|
177
|
+
|
|
178
|
+
- The avatar root renders a `<span>` and is **presentational** — it conveys no
|
|
179
|
+
interactive semantics on its own.
|
|
180
|
+
- When an `AvatarImage` is shown, provide a meaningful `alt` describing the
|
|
181
|
+
person/entity (e.g. `alt="Sam Nguyen"`). If the avatar is purely decorative
|
|
182
|
+
beside an already-labeled name, use `alt=""`.
|
|
183
|
+
- The `AvatarFallback` initials are text and are read as-is. Initials alone are a
|
|
184
|
+
weak label — prefer an adjacent visible name, or set `alt` on the image, so the
|
|
185
|
+
entity is identifiable by more than two letters.
|
|
186
|
+
- For `variant="icon"`, the icon alone conveys no name — always pair it with a
|
|
187
|
+
visible label in the surrounding context (the icon is presentational, not an
|
|
188
|
+
accessible name by itself).
|
|
189
|
+
|
|
190
|
+
## Keyboard & focus
|
|
191
|
+
|
|
192
|
+
- Avatar is not focusable or interactive by default. If you make an avatar
|
|
193
|
+
actionable (e.g. wrap it in a button or link, or pass `render`), the wrapping
|
|
194
|
+
control owns the role, focus ring, and keyboard behavior — give it an
|
|
195
|
+
accessible name.
|
|
196
|
+
|
|
197
|
+
## Groups
|
|
198
|
+
|
|
199
|
+
- An `AvatarGroup` is a layout container; it adds no semantics. If it represents
|
|
200
|
+
a meaningful set (e.g. "people on this ticket"), label the surrounding context
|
|
201
|
+
in text. A common pattern is a trailing `+N` count and a visible label next to
|
|
202
|
+
the group.
|
|
203
|
+
|
|
204
|
+
## Contrast
|
|
205
|
+
|
|
206
|
+
- Initials use the per-scheme `--ui-avatar-label-color-<scheme>` on the matching
|
|
207
|
+
`--ui-avatar-color-<scheme>` background; these pairs are defined in the design
|
|
208
|
+
tokens to meet contrast for short text. Do not override one without the other.
|