prime-ui-kit 0.2.5 → 0.3.1
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/README.md +161 -35
- package/dist/components/accordion/Accordion.d.ts +70 -0
- package/dist/components/accordion/Accordion.d.ts.map +1 -0
- package/dist/components/avatar/Avatar.d.ts +58 -0
- package/dist/components/avatar/Avatar.d.ts.map +1 -0
- package/dist/components/badge/Badge.d.ts +51 -0
- package/dist/components/badge/Badge.d.ts.map +1 -0
- package/dist/components/banner/Banner.d.ts +78 -0
- package/dist/components/banner/Banner.d.ts.map +1 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts +47 -0
- package/dist/components/breadcrumb/Breadcrumb.d.ts.map +1 -0
- package/dist/components/button/Button.d.ts +57 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button-group/ButtonGroup.d.ts +34 -0
- package/dist/components/button-group/ButtonGroup.d.ts.map +1 -0
- package/dist/components/card/Card.d.ts +234 -0
- package/dist/components/card/Card.d.ts.map +1 -0
- package/dist/components/checkbox/Checkbox.d.ts +42 -0
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -0
- package/dist/components/code-block/CodeBlock.d.ts +17 -0
- package/dist/components/code-block/CodeBlock.d.ts.map +1 -0
- package/dist/components/color-picker/ColorPicker.d.ts +76 -0
- package/dist/components/color-picker/ColorPicker.d.ts.map +1 -0
- package/dist/components/color-picker/ColorPickerRac.d.ts +76 -0
- package/dist/components/color-picker/ColorPickerRac.d.ts.map +1 -0
- package/dist/components/command-menu/CommandMenu.d.ts +74 -0
- package/dist/components/command-menu/CommandMenu.d.ts.map +1 -0
- package/dist/components/data-table/DataTable.d.ts +78 -0
- package/dist/components/data-table/DataTable.d.ts.map +1 -0
- package/dist/components/datepicker/Datepicker.d.ts +104 -0
- package/dist/components/datepicker/Datepicker.d.ts.map +1 -0
- package/dist/components/digit-input/DigitInput.d.ts +21 -0
- package/dist/components/digit-input/DigitInput.d.ts.map +1 -0
- package/dist/components/divider/Divider.d.ts +26 -0
- package/dist/components/divider/Divider.d.ts.map +1 -0
- package/dist/components/drawer/Drawer.d.ts +71 -0
- package/dist/components/drawer/Drawer.d.ts.map +1 -0
- package/dist/components/dropdown/Dropdown.d.ts +147 -0
- package/dist/components/dropdown/Dropdown.d.ts.map +1 -0
- package/dist/components/dropdown/dropdownGeometry.d.ts +10 -0
- package/dist/components/dropdown/dropdownGeometry.d.ts.map +1 -0
- package/dist/components/dropdown/menuKeyboard.d.ts +4 -0
- package/dist/components/dropdown/menuKeyboard.d.ts.map +1 -0
- package/dist/components/dropdown/useDropdownPosition.d.ts +18 -0
- package/dist/components/dropdown/useDropdownPosition.d.ts.map +1 -0
- package/dist/components/example-frame/ExampleFrame.d.ts +53 -0
- package/dist/components/example-frame/ExampleFrame.d.ts.map +1 -0
- package/dist/components/file-upload/FileUpload.d.ts +176 -0
- package/dist/components/file-upload/FileUpload.d.ts.map +1 -0
- package/dist/components/hint/Hint.d.ts +27 -0
- package/dist/components/hint/Hint.d.ts.map +1 -0
- package/dist/components/index.css +6101 -5759
- package/dist/components/index.css.map +4 -4
- package/dist/components/index.d.ts +95 -2679
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +8510 -7659
- package/dist/components/index.js.map +4 -4
- package/dist/components/input/Input.d.ts +73 -0
- package/dist/components/input/Input.d.ts.map +1 -0
- package/dist/components/kbd/Kbd.d.ts +15 -0
- package/dist/components/kbd/Kbd.d.ts.map +1 -0
- package/dist/components/label/Label.d.ts +29 -0
- package/dist/components/label/Label.d.ts.map +1 -0
- package/dist/components/link-button/LinkButton.d.ts +18 -0
- package/dist/components/link-button/LinkButton.d.ts.map +1 -0
- package/dist/components/modal/Modal.d.ts +58 -0
- package/dist/components/modal/Modal.d.ts.map +1 -0
- package/dist/components/notification/Notification.d.ts +42 -0
- package/dist/components/notification/Notification.d.ts.map +1 -0
- package/dist/components/notification/NotificationStore.d.ts +18 -0
- package/dist/components/notification/NotificationStore.d.ts.map +1 -0
- package/dist/components/page-content/PageContent.d.ts +51 -0
- package/dist/components/page-content/PageContent.d.ts.map +1 -0
- package/dist/components/pagination/Pagination.d.ts +19 -0
- package/dist/components/pagination/Pagination.d.ts.map +1 -0
- package/dist/components/popover/Popover.d.ts +48 -0
- package/dist/components/popover/Popover.d.ts.map +1 -0
- package/dist/components/popover/popoverGeometry.d.ts +6 -0
- package/dist/components/popover/popoverGeometry.d.ts.map +1 -0
- package/dist/components/popover/usePopoverPosition.d.ts +18 -0
- package/dist/components/popover/usePopoverPosition.d.ts.map +1 -0
- package/dist/components/progress-bar/ProgressBar.d.ts +14 -0
- package/dist/components/progress-bar/ProgressBar.d.ts.map +1 -0
- package/dist/components/progress-circle/ProgressCircle.d.ts +33 -0
- package/dist/components/progress-circle/ProgressCircle.d.ts.map +1 -0
- package/dist/components/radio/Radio.d.ts +40 -0
- package/dist/components/radio/Radio.d.ts.map +1 -0
- package/dist/components/scroll-container/ScrollContainer.d.ts +42 -0
- package/dist/components/scroll-container/ScrollContainer.d.ts.map +1 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts +40 -0
- package/dist/components/segmented-control/SegmentedControl.d.ts.map +1 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts +22 -0
- package/dist/components/segmented-progress-bar/SegmentedProgressBar.d.ts.map +1 -0
- package/dist/components/select/Select.d.ts +84 -0
- package/dist/components/select/Select.d.ts.map +1 -0
- package/dist/components/select/selectListbox.d.ts +13 -0
- package/dist/components/select/selectListbox.d.ts.map +1 -0
- package/dist/components/slider/Slider.d.ts +23 -0
- package/dist/components/slider/Slider.d.ts.map +1 -0
- package/dist/components/stepper/HorizontalStepper.d.ts +41 -0
- package/dist/components/stepper/HorizontalStepper.d.ts.map +1 -0
- package/dist/components/stepper/Stepper.d.ts +77 -0
- package/dist/components/stepper/Stepper.d.ts.map +1 -0
- package/dist/components/stepper/VerticalStepper.d.ts +41 -0
- package/dist/components/stepper/VerticalStepper.d.ts.map +1 -0
- package/dist/components/stepper/stepperAlignContext.d.ts +11 -0
- package/dist/components/stepper/stepperAlignContext.d.ts.map +1 -0
- package/dist/components/switch/Switch.d.ts +48 -0
- package/dist/components/switch/Switch.d.ts.map +1 -0
- package/dist/components/tabs/Tabs.d.ts +69 -0
- package/dist/components/tabs/Tabs.d.ts.map +1 -0
- package/dist/components/tag/Tag.d.ts +29 -0
- package/dist/components/tag/Tag.d.ts.map +1 -0
- package/dist/components/textarea/Textarea.d.ts +43 -0
- package/dist/components/textarea/Textarea.d.ts.map +1 -0
- package/dist/components/tooltip/Tooltip.d.ts +47 -0
- package/dist/components/tooltip/Tooltip.d.ts.map +1 -0
- package/dist/components/typography/Typography.d.ts +30 -0
- package/dist/components/typography/Typography.d.ts.map +1 -0
- package/dist/hooks/useControllableState.d.ts +8 -0
- package/dist/hooks/useControllableState.d.ts.map +1 -0
- package/dist/hooks/useEscapeKey.d.ts +7 -0
- package/dist/hooks/useEscapeKey.d.ts.map +1 -0
- package/dist/hooks/useFieldIds.d.ts +17 -0
- package/dist/hooks/useFieldIds.d.ts.map +1 -0
- package/dist/hooks/useFocusTrap.d.ts +16 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -0
- package/dist/hooks/useMergedRefs.d.ts +3 -0
- package/dist/hooks/useMergedRefs.d.ts.map +1 -0
- package/dist/hooks/useOutsideClick.d.ts +16 -0
- package/dist/hooks/useOutsideClick.d.ts.map +1 -0
- package/dist/hooks/useOverlayModal.d.ts +7 -0
- package/dist/hooks/useOverlayModal.d.ts.map +1 -0
- package/dist/hooks/usePosition.d.ts +41 -0
- package/dist/hooks/usePosition.d.ts.map +1 -0
- package/dist/hooks/useResponsiveMonths.d.ts +18 -0
- package/dist/hooks/useResponsiveMonths.d.ts.map +1 -0
- package/dist/hooks/useScrollLock.d.ts +8 -0
- package/dist/hooks/useScrollLock.d.ts.map +1 -0
- package/dist/icons/Icon.d.ts +13 -0
- package/dist/icons/Icon.d.ts.map +1 -0
- package/dist/icons/index.d.ts +40 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/index.css +6101 -5759
- package/dist/index.css.map +4 -4
- package/dist/index.d.ts +4 -8
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8509 -7660
- package/dist/index.js.map +4 -4
- package/dist/internal/ControlSizeContext.d.ts +17 -0
- package/dist/internal/ControlSizeContext.d.ts.map +1 -0
- package/dist/internal/DividerContentContext.d.ts +4 -0
- package/dist/internal/DividerContentContext.d.ts.map +1 -0
- package/dist/internal/OverlayPortalLayerContext.d.ts +13 -0
- package/dist/internal/OverlayPortalLayerContext.d.ts.map +1 -0
- package/dist/internal/Portal.d.ts +8 -0
- package/dist/internal/Portal.d.ts.map +1 -0
- package/dist/internal/context.d.ts +11 -0
- package/dist/internal/context.d.ts.map +1 -0
- package/dist/internal/cx.d.ts +2 -0
- package/dist/internal/cx.d.ts.map +1 -0
- package/dist/internal/data-attributes.d.ts +6 -0
- package/dist/internal/data-attributes.d.ts.map +1 -0
- package/dist/internal/highlightTsxHtml.d.ts +3 -0
- package/dist/internal/highlightTsxHtml.d.ts.map +1 -0
- package/dist/internal/layoutPxFromPrimitives.d.ts +13 -0
- package/dist/internal/layoutPxFromPrimitives.d.ts.map +1 -0
- package/dist/internal/mergeRefs.d.ts +4 -0
- package/dist/internal/mergeRefs.d.ts.map +1 -0
- package/dist/internal/runtimeUnits.d.ts +3 -0
- package/dist/internal/runtimeUnits.d.ts.map +1 -0
- package/dist/internal/scrollAncestors.d.ts +3 -0
- package/dist/internal/scrollAncestors.d.ts.map +1 -0
- package/dist/internal/slot.d.ts +19 -0
- package/dist/internal/slot.d.ts.map +1 -0
- package/dist/internal/states.d.ts +87 -0
- package/dist/internal/states.d.ts.map +1 -0
- package/dist/layout/app-shell/AppShell.d.ts +54 -0
- package/dist/layout/app-shell/AppShell.d.ts.map +1 -0
- package/dist/layout/index.d.ts +7 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/sidebar/Sidebar.d.ts +241 -0
- package/dist/layout/sidebar/Sidebar.d.ts.map +1 -0
- package/dist/layout/sidebar/SidebarRoot.d.ts +51 -0
- package/dist/layout/sidebar/SidebarRoot.d.ts.map +1 -0
- package/dist/layout/sidebar/sidebar-context.d.ts +19 -0
- package/dist/layout/sidebar/sidebar-context.d.ts.map +1 -0
- package/dist/layout/sidebar/sidebarLayout.d.ts +12 -0
- package/dist/layout/sidebar/sidebarLayout.d.ts.map +1 -0
- package/dist/tokens/primitives.d.ts +390 -0
- package/dist/tokens/primitives.d.ts.map +1 -0
- package/dist/tokens/semantic.d.ts +732 -0
- package/dist/tokens/semantic.d.ts.map +1 -0
- package/dist/tokens/themes/dark.d.ts +143 -0
- package/dist/tokens/themes/dark.d.ts.map +1 -0
- package/dist/tokens/themes/light.d.ts +16 -0
- package/dist/tokens/themes/light.d.ts.map +1 -0
- package/package.json +9 -4
- package/src/components/accordion/COMPONENT.md +137 -0
- package/src/components/avatar/COMPONENT.md +100 -0
- package/src/components/badge/COMPONENT.md +78 -0
- package/src/components/banner/COMPONENT.md +118 -0
- package/src/components/breadcrumb/COMPONENT.md +94 -0
- package/src/components/button/COMPONENT.md +80 -0
- package/src/components/button-group/COMPONENT.md +83 -0
- package/src/components/card/COMPONENT.md +489 -0
- package/src/components/checkbox/COMPONENT.md +98 -0
- package/src/components/code-block/COMPONENT.md +58 -0
- package/src/components/color-picker/COMPONENT.md +149 -0
- package/src/components/command-menu/COMPONENT.md +167 -0
- package/src/components/data-table/COMPONENT.md +113 -0
- package/src/components/datepicker/COMPONENT.md +137 -0
- package/src/components/digit-input/COMPONENT.md +68 -0
- package/src/components/divider/COMPONENT.md +70 -0
- package/src/components/drawer/COMPONENT.md +149 -0
- package/src/components/dropdown/COMPONENT.md +192 -0
- package/src/components/file-upload/COMPONENT.md +200 -0
- package/src/components/hint/COMPONENT.md +67 -0
- package/src/components/input/COMPONENT.md +119 -0
- package/src/components/kbd/COMPONENT.md +59 -0
- package/src/components/label/COMPONENT.md +94 -0
- package/src/components/link-button/COMPONENT.md +60 -0
- package/src/components/modal/COMPONENT.md +105 -0
- package/src/components/notification/COMPONENT.md +120 -0
- package/src/components/pagination/COMPONENT.md +61 -0
- package/src/components/popover/COMPONENT.md +93 -0
- package/src/components/progress-bar/COMPONENT.md +59 -0
- package/src/components/progress-circle/COMPONENT.md +63 -0
- package/src/components/radio/COMPONENT.md +95 -0
- package/src/components/segmented-control/COMPONENT.md +86 -0
- package/src/components/segmented-progress-bar/COMPONENT.md +75 -0
- package/src/components/select/COMPONENT.md +175 -0
- package/src/components/slider/COMPONENT.md +62 -0
- package/src/components/stepper/COMPONENT.md +186 -0
- package/src/components/switch/COMPONENT.md +98 -0
- package/src/components/tabs/COMPONENT.md +114 -0
- package/src/components/tag/COMPONENT.md +67 -0
- package/src/components/textarea/COMPONENT.md +98 -0
- package/src/components/tooltip/COMPONENT.md +87 -0
- package/src/components/typography/COMPONENT.md +89 -0
- package/src/styles/theme-dark.css +43 -0
- package/src/styles/theme-light.css +43 -0
- package/src/styles/tokens.css +23 -4
- package/src/styles/tokens.test.ts +0 -27
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** для демо и экранов используйте **`variant`** и слоты как в примерах ниже; **`flat`** включайте, когда карточка должна визуально совпадать с плоским слоем страницы (без тени).
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
Composable surfaces for **dashboard KPIs**, **lists**, **CTA tiles**, **split metrics**, **media headers**, and **chart shells**: layout presets driven by **`variant`** on **`Card.Root`**. Typography and spacing use semantic tokens (`--prime-sys-*`). The kit does not ship chart primitives — pass any chart, SVG sparkline, or [ProgressBar](../progress-bar/COMPONENT.md) into **`Card.Media`**, **`Card.Chart`** (**`panel`**, edge-to-edge), padded **`Card.Body`**, or **`Card.Cover`**.
|
|
8
|
+
|
|
9
|
+
**Ссылки на паттерны карточек и дашбордов (для ориентира по типам плиток):**
|
|
10
|
+
|
|
11
|
+
1. [Material Design 3 — Cards (guidelines)](https://m3.material.io/components/cards/guidelines)
|
|
12
|
+
2. [IBM Carbon — Tile (usage)](https://carbondesignsystem.com/components/tile/usage/)
|
|
13
|
+
3. [Ant Design — Card](https://ant.design/components/card)
|
|
14
|
+
4. [Shopify Polaris — Legacy Card](https://polaris.shopify.com/components/layout-and-structure/legacy-card)
|
|
15
|
+
5. [shadcn/ui — Card](https://ui.shadcn.com/docs/components/card)
|
|
16
|
+
6. [Atlassian Design — Composition](https://atlassian.design/get-started/develop/composition)
|
|
17
|
+
7. [PatternFly — Card](https://www.patternfly.org/components/card/)
|
|
18
|
+
8. [GOV.UK Design System — Card](https://design-system.service.gov.uk/components/card/)
|
|
19
|
+
9. [Nielsen Norman Group — Dashboard Design](https://www.nngroup.com/articles/dashboard-design/)
|
|
20
|
+
10. [GitHub Primer — Card](https://primer.style/product/components/card/)
|
|
21
|
+
|
|
22
|
+
**Кратко по смыслу:** MD3 и большинство дизайн-систем описывают карточку как контейнер с заголовком, опциональным медиа и действиями; Carbon использует **tile** для группировки на сетке; в дашбордах часто выделяют KPI, списки активности, CTA и сравнение метрик — см. NN/g про структуру дашборда. **Responsive dashboards (prime-ui-kit):** CSS Grid для рядов KPI (`repeat(auto-fill, minmax(...))`) — [prime-ui skill](https://github.com/esurkov1/prime-ui/blob/main/SKILL/SKILL.md).
|
|
23
|
+
|
|
24
|
+
- **Use** **`variant="mini"`** for a compact KPI: optional **`IconBox`** + **`Stack`** with **`Label`** and **`Value`**.
|
|
25
|
+
- **Use** **`variant="mini-media"`** for the same **`IconBox`** + **`Stack`** row as **`mini`**, then **`Media`** for a sparkline, ring, or thin progress strip (full width below).
|
|
26
|
+
- **Use** **`variant="metric"`** for a title row: **`HeaderRow`** with **`Lead`** (badge or icon) and **`Value`**, plus **`Description`** underneath.
|
|
27
|
+
- **Use** **`variant="panel"`** for a titled block: **`SectionHeader`** + **`Body`** (padded copy or tables) and/or **`Chart`** (full-width chart area, no inner padding).
|
|
28
|
+
- **Use** **`variant="stat-trend"`** for a large KPI with period delta: **`Label`**, **`Value`**, **`Delta`** (`trend`: `up` | `down` | `neutral`).
|
|
29
|
+
- **Use** **`variant="cta"`** for a call-to-action tile: **`Title`**, **`CtaBody`**, **`Actions`** (buttons / links).
|
|
30
|
+
- **Use** **`variant="list"`** for activity or alerts: **`ListHeader`** (e.g. **`Title`** + link), **`List`** / **`ListItem`**.
|
|
31
|
+
- **Use** **`variant="split"`** for two related metrics: **`Split`** with two **`SplitCell`** blocks (typically **`Label`** + **`Value`** each). Optionally **`IconBox`** + **`Stack`** (same pattern as **`mini`**) — **`IconBox`** surface + label/value column.
|
|
32
|
+
- **Use** **`variant="cover"`** for media on top: **`Cover`** (image or block), then **`Stack`** and optional **`Actions`**.
|
|
33
|
+
- **Do not use** as the only focus target for navigation; wrap a [LinkButton](../link-button/COMPONENT.md) or make an inner control focusable instead of the whole card, unless you add explicit `role`/`tabIndex` and keyboard handling.
|
|
34
|
+
- **Do not use** decorative icons without **`aria-hidden`** when the text repeats the meaning.
|
|
35
|
+
|
|
36
|
+
## Composition
|
|
37
|
+
|
|
38
|
+
- **`Card.Root`** — required **`variant`**: `"mini"` \| `"mini-media"` \| `"metric"` \| `"panel"` \| `"stat-trend"` \| `"cta"` \| `"list"` \| `"split"` \| `"cover"`. Optional **`flat`** removes the default surface shadow (tile-like). Sets `data-variant` / `data-flat` for styling.
|
|
39
|
+
- **`Card.IconBox`** — square leading area in **`mini`** and **`mini-media`**: background **`status-information-background`**, radius **`size-control-m-radius`**, icon color via **`status-information-foreground`** (decorative icons: **`aria-hidden`**).
|
|
40
|
+
- **`Card.Lead`** — left cluster in **`HeaderRow`** (badge from [Badge](../badge/COMPONENT.md), raw icon, or both).
|
|
41
|
+
- **`Card.HeaderRow`** — top row for **`metric`**: typically **`Lead`** + **`Value`**.
|
|
42
|
+
- **`Card.Stack`** — vertical block for **`Label`** + **`Value`** in **`mini`** and **`mini-media`**.
|
|
43
|
+
- **`Card.Label`** — secondary line (muted).
|
|
44
|
+
- **`Card.Value`** — primary metric string.
|
|
45
|
+
- **`Card.Description`** — supporting line under the header row (`p`).
|
|
46
|
+
- **`Card.Media`** — bottom region with top border; place charts/progress here.
|
|
47
|
+
- **`Card.SectionHeader`** — bar with bottom border for **`panel`**.
|
|
48
|
+
- **`Card.SectionTitle`** — `h3` title.
|
|
49
|
+
- **`Card.SectionTrailing`** — optional actions or icon on the right.
|
|
50
|
+
- **`Card.Body`** — **`panel`**: padded region for text, summaries, or tables. With **`variant="panel"`**, the shell has a **minimum height**; a **single element child** can stretch inside the padded box. Override height via **`className`** on **`Root`** if needed.
|
|
51
|
+
- **`Card.Chart`** — **`panel`**: **no** horizontal or vertical inner padding; mount the chart library root here for **edge-to-edge** drawing under the header. Optional after **`Body`**; then **`Chart`** fills remaining height.
|
|
52
|
+
- **`Card.Title`** — **`h3`** with **`title`** styles; use in **`cta`**, **`list`** header, **`cover`** stack.
|
|
53
|
+
- **`Card.Delta`** — supporting line for **`stat-trend`**; optional **`trend`** sets `data-trend` for color (`up` \| `down` \| `neutral`).
|
|
54
|
+
- **`Card.CtaBody`** — body copy in **`cta`**.
|
|
55
|
+
- **`Card.Actions`** — row of actions (border-top); use in **`cta`** and **`cover`**.
|
|
56
|
+
- **`Card.Cover`** — top media region for **`cover`** (image or decorative block; keep meaningful images described elsewhere for a11y).
|
|
57
|
+
- **`Card.Split`** / **`Card.SplitCell`** — two-column grid for **`split`**.
|
|
58
|
+
- **`Card.ListHeader`** — top bar for **`list`** (border-bottom).
|
|
59
|
+
- **`Card.List`** / **`Card.ListItem`** — semantic **`ul`** / **`li`** for **`list`**.
|
|
60
|
+
|
|
61
|
+
### Mini example
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { Card } from "prime-ui-kit";
|
|
65
|
+
|
|
66
|
+
export function MiniKpi() {
|
|
67
|
+
return (
|
|
68
|
+
<Card.Root variant="mini">
|
|
69
|
+
<Card.IconBox aria-hidden>…</Card.IconBox>
|
|
70
|
+
<Card.Stack>
|
|
71
|
+
<Card.Label>Age</Card.Label>
|
|
72
|
+
<Card.Value>36 years</Card.Value>
|
|
73
|
+
</Card.Stack>
|
|
74
|
+
</Card.Root>
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Mini + media example
|
|
80
|
+
|
|
81
|
+
```tsx
|
|
82
|
+
import { Card } from "prime-ui-kit";
|
|
83
|
+
|
|
84
|
+
export function MiniKpiWithSparkline() {
|
|
85
|
+
return (
|
|
86
|
+
<Card.Root variant="mini-media">
|
|
87
|
+
<Card.IconBox aria-hidden>…</Card.IconBox>
|
|
88
|
+
<Card.Stack>
|
|
89
|
+
<Card.Label>Glucose</Card.Label>
|
|
90
|
+
<Card.Value>5.4 mmol/L</Card.Value>
|
|
91
|
+
</Card.Stack>
|
|
92
|
+
<Card.Media>
|
|
93
|
+
<svg aria-hidden viewBox="0 0 120 40" />
|
|
94
|
+
</Card.Media>
|
|
95
|
+
</Card.Root>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Metric example
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import { Badge } from "prime-ui-kit";
|
|
104
|
+
import { Card } from "prime-ui-kit";
|
|
105
|
+
|
|
106
|
+
export function MetricCard() {
|
|
107
|
+
return (
|
|
108
|
+
<Card.Root variant="metric">
|
|
109
|
+
<Card.HeaderRow>
|
|
110
|
+
<Card.Lead>
|
|
111
|
+
<Badge.Root color="blue" variant="filled" size="s">
|
|
112
|
+
CRP
|
|
113
|
+
</Badge.Root>
|
|
114
|
+
</Card.Lead>
|
|
115
|
+
<Card.Value>1.8 mg/L</Card.Value>
|
|
116
|
+
</Card.HeaderRow>
|
|
117
|
+
<Card.Description>Slightly elevated</Card.Description>
|
|
118
|
+
</Card.Root>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Panel example (chart only)
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { Card } from "prime-ui-kit";
|
|
127
|
+
|
|
128
|
+
export function ChartSection() {
|
|
129
|
+
return (
|
|
130
|
+
<Card.Root variant="panel">
|
|
131
|
+
<Card.SectionHeader>
|
|
132
|
+
<Card.SectionTitle>Revenue</Card.SectionTitle>
|
|
133
|
+
</Card.SectionHeader>
|
|
134
|
+
<Card.Chart>
|
|
135
|
+
<div id="revenue-chart" />
|
|
136
|
+
</Card.Chart>
|
|
137
|
+
</Card.Root>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Panel example (padded content + chart)
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { Card } from "prime-ui-kit";
|
|
146
|
+
|
|
147
|
+
export function ChartSectionWithIntro() {
|
|
148
|
+
return (
|
|
149
|
+
<Card.Root variant="panel">
|
|
150
|
+
<Card.SectionHeader>
|
|
151
|
+
<Card.SectionTitle>Revenue</Card.SectionTitle>
|
|
152
|
+
</Card.SectionHeader>
|
|
153
|
+
<Card.Body>
|
|
154
|
+
<p>Short summary or filters.</p>
|
|
155
|
+
</Card.Body>
|
|
156
|
+
<Card.Chart>
|
|
157
|
+
<div id="revenue-chart" />
|
|
158
|
+
</Card.Chart>
|
|
159
|
+
</Card.Root>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Stat + trend example
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { Card } from "prime-ui-kit";
|
|
168
|
+
|
|
169
|
+
export function StatTrendCard() {
|
|
170
|
+
return (
|
|
171
|
+
<Card.Root variant="stat-trend">
|
|
172
|
+
<Card.Label>Revenue (30d)</Card.Label>
|
|
173
|
+
<Card.Value>$420k</Card.Value>
|
|
174
|
+
<Card.Delta trend="up">+18% vs prior month</Card.Delta>
|
|
175
|
+
</Card.Root>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### CTA example
|
|
181
|
+
|
|
182
|
+
```tsx
|
|
183
|
+
import { Button, Card, LinkButton } from "prime-ui-kit";
|
|
184
|
+
|
|
185
|
+
export function CtaCard() {
|
|
186
|
+
return (
|
|
187
|
+
<Card.Root variant="cta">
|
|
188
|
+
<Card.Title>Export report</Card.Title>
|
|
189
|
+
<Card.CtaBody>Download a CSV for the selected period.</Card.CtaBody>
|
|
190
|
+
<Card.Actions>
|
|
191
|
+
<LinkButton.Root href="#">Download</LinkButton.Root>
|
|
192
|
+
<Button.Root mode="ghost" type="button" variant="neutral">
|
|
193
|
+
Cancel
|
|
194
|
+
</Button.Root>
|
|
195
|
+
</Card.Actions>
|
|
196
|
+
</Card.Root>
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### List example
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
import { Card } from "prime-ui-kit";
|
|
205
|
+
import { LinkButton } from "prime-ui-kit";
|
|
206
|
+
|
|
207
|
+
export function ListCard() {
|
|
208
|
+
return (
|
|
209
|
+
<Card.Root variant="list">
|
|
210
|
+
<Card.ListHeader>
|
|
211
|
+
<Card.Title>Recent activity</Card.Title>
|
|
212
|
+
<LinkButton.Root href="#">View all</LinkButton.Root>
|
|
213
|
+
</Card.ListHeader>
|
|
214
|
+
<Card.List>
|
|
215
|
+
<Card.ListItem>Payment received</Card.ListItem>
|
|
216
|
+
<Card.ListItem>New comment on ticket #12</Card.ListItem>
|
|
217
|
+
</Card.List>
|
|
218
|
+
</Card.Root>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Split example
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
import { Card } from "prime-ui-kit";
|
|
227
|
+
|
|
228
|
+
export function SplitCard() {
|
|
229
|
+
return (
|
|
230
|
+
<Card.Root variant="split">
|
|
231
|
+
<Card.Split>
|
|
232
|
+
<Card.SplitCell>
|
|
233
|
+
<Card.IconBox>{/* icon */}</Card.IconBox>
|
|
234
|
+
<Card.Stack>
|
|
235
|
+
<Card.Label>Conversion</Card.Label>
|
|
236
|
+
<Card.Value>3.8%</Card.Value>
|
|
237
|
+
</Card.Stack>
|
|
238
|
+
</Card.SplitCell>
|
|
239
|
+
<Card.SplitCell>
|
|
240
|
+
<Card.IconBox>{/* icon */}</Card.IconBox>
|
|
241
|
+
<Card.Stack>
|
|
242
|
+
<Card.Label>AOV</Card.Label>
|
|
243
|
+
<Card.Value>$64</Card.Value>
|
|
244
|
+
</Card.Stack>
|
|
245
|
+
</Card.SplitCell>
|
|
246
|
+
</Card.Split>
|
|
247
|
+
</Card.Root>
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### Cover example
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
import { Card } from "prime-ui-kit";
|
|
256
|
+
|
|
257
|
+
export function CoverCard() {
|
|
258
|
+
return (
|
|
259
|
+
<Card.Root variant="cover">
|
|
260
|
+
<Card.Cover>
|
|
261
|
+
<img alt="" src="/hero.jpg" />
|
|
262
|
+
</Card.Cover>
|
|
263
|
+
<Card.Stack>
|
|
264
|
+
<Card.Title>Campaign</Card.Title>
|
|
265
|
+
<Card.Label>Last 7 days</Card.Label>
|
|
266
|
+
<Card.Description>Compared to control.</Card.Description>
|
|
267
|
+
</Card.Stack>
|
|
268
|
+
</Card.Root>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Rules
|
|
274
|
+
|
|
275
|
+
- Typography follows the **control `m` tier** (`--prime-sys-size-control-m-text` for values and section titles, `--prime-sys-size-control-m-supportText` for labels and descriptions), aligned with [Label](../label/COMPONENT.md) / [Input](../input/COMPONENT.md) defaults — not reading `headingSection` / `headingSubsection` roles, so KPI copy stays visually consistent with form density.
|
|
276
|
+
- Prefer **`flat`** on dense dashboards if shadows feel noisy; default shadow uses **`--prime-sys-elevation-shadow-surface`**.
|
|
277
|
+
- **`SectionTitle`** is an **`h3`**; ensure heading levels match the page outline (skip levels appropriately).
|
|
278
|
+
- **`Description`** is a **`p`** — only one block per card unless you compose custom markup inside **`Body`** for **`panel`**.
|
|
279
|
+
- **`variant="panel"`** sets a **minimum height** on **`Root`**. Order after **`SectionHeader`**: optional **`Body`** (inset content), optional **`Chart`** (full bleed). If both are present, **`Body`** sizes to its content and **`Chart`** takes the **remaining height**. A **single element child** in **`Chart`** (or in **`Body`** when it is the only block) stretches within that region.
|
|
280
|
+
- For **`mini-media`**, keep **`Media`** height predictable so rows in a grid stay aligned, or use one column on narrow viewports.
|
|
281
|
+
- Icons in **`IconBox`** / **`Lead`** should not be the sole carrier of meaning; pair with visible text.
|
|
282
|
+
- **`Title`** is an **`h3`** (like **`SectionTitle`**); avoid duplicate heading levels on the same screen.
|
|
283
|
+
- Decorative content in **`Cover`** should not rely on **`img alt`** alone for critical information — repeat key facts in **`Stack`**.
|
|
284
|
+
- **`List`** uses a real **`ul`**; keep **`ListItem`** text meaningful for screen readers.
|
|
285
|
+
|
|
286
|
+
## API
|
|
287
|
+
|
|
288
|
+
### Card.Root
|
|
289
|
+
|
|
290
|
+
| Prop | Type | Default | Required | Description |
|
|
291
|
+
|------|------|---------|----------|-------------|
|
|
292
|
+
| variant | `"mini" \| "mini-media" \| "metric" \| "panel" \| "stat-trend" \| "cta" \| "list" \| "split" \| "cover"` | — | Yes | Layout preset and padding. |
|
|
293
|
+
| flat | `boolean` | `false` | No | When `true`, no drop shadow (surface still bordered). |
|
|
294
|
+
| className | `string` | — | No | Extra class on the root. |
|
|
295
|
+
| children | `React.ReactNode` | — | No | Slots listed in Composition. |
|
|
296
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Native attributes on the root `div`. |
|
|
297
|
+
|
|
298
|
+
### Card.IconBox
|
|
299
|
+
|
|
300
|
+
| Prop | Type | Default | Required | Description |
|
|
301
|
+
|------|------|---------|----------|-------------|
|
|
302
|
+
| className | `string` | — | No | Extra class. |
|
|
303
|
+
| children | `React.ReactNode` | — | No | Icon node. |
|
|
304
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the wrapper `div`. |
|
|
305
|
+
|
|
306
|
+
### Card.Lead
|
|
307
|
+
|
|
308
|
+
| Prop | Type | Default | Required | Description |
|
|
309
|
+
|------|------|---------|----------|-------------|
|
|
310
|
+
| className | `string` | — | No | Extra class. |
|
|
311
|
+
| children | `React.ReactNode` | — | No | Badge, icon, or group. |
|
|
312
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the wrapper `div`. |
|
|
313
|
+
|
|
314
|
+
### Card.HeaderRow
|
|
315
|
+
|
|
316
|
+
| Prop | Type | Default | Required | Description |
|
|
317
|
+
|------|------|---------|----------|-------------|
|
|
318
|
+
| className | `string` | — | No | Extra class. |
|
|
319
|
+
| children | `React.ReactNode` | — | No | Typically `Lead` + `Value`. |
|
|
320
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the flex row. |
|
|
321
|
+
|
|
322
|
+
### Card.Stack
|
|
323
|
+
|
|
324
|
+
| Prop | Type | Default | Required | Description |
|
|
325
|
+
|------|------|---------|----------|-------------|
|
|
326
|
+
| className | `string` | — | No | Extra class. |
|
|
327
|
+
| children | `React.ReactNode` | — | No | `Label` + `Value` for mini. |
|
|
328
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the stack `div`. |
|
|
329
|
+
|
|
330
|
+
### Card.Label
|
|
331
|
+
|
|
332
|
+
| Prop | Type | Default | Required | Description |
|
|
333
|
+
|------|------|---------|----------|-------------|
|
|
334
|
+
| className | `string` | — | No | Extra class. |
|
|
335
|
+
| children | `React.ReactNode` | — | No | Secondary label text. |
|
|
336
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Attributes on the `span`. |
|
|
337
|
+
|
|
338
|
+
### Card.Value
|
|
339
|
+
|
|
340
|
+
| Prop | Type | Default | Required | Description |
|
|
341
|
+
|------|------|---------|----------|-------------|
|
|
342
|
+
| className | `string` | — | No | Extra class. |
|
|
343
|
+
| children | `React.ReactNode` | — | No | Primary value. |
|
|
344
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Attributes on the `span`. |
|
|
345
|
+
|
|
346
|
+
### Card.Description
|
|
347
|
+
|
|
348
|
+
| Prop | Type | Default | Required | Description |
|
|
349
|
+
|------|------|---------|----------|-------------|
|
|
350
|
+
| className | `string` | — | No | Extra class. |
|
|
351
|
+
| children | `React.ReactNode` | — | No | Supporting copy. |
|
|
352
|
+
| …rest | `React.HTMLAttributes<HTMLParagraphElement>` | — | No | Attributes on the `p`. |
|
|
353
|
+
|
|
354
|
+
### Card.Media
|
|
355
|
+
|
|
356
|
+
| Prop | Type | Default | Required | Description |
|
|
357
|
+
|------|------|---------|----------|-------------|
|
|
358
|
+
| className | `string` | — | No | Extra class. |
|
|
359
|
+
| children | `React.ReactNode` | — | No | Chart, SVG, or progress. |
|
|
360
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the region `div`. |
|
|
361
|
+
|
|
362
|
+
### Card.Title
|
|
363
|
+
|
|
364
|
+
| Prop | Type | Default | Required | Description |
|
|
365
|
+
|------|------|---------|----------|-------------|
|
|
366
|
+
| className | `string` | — | No | Extra class. |
|
|
367
|
+
| children | `React.ReactNode` | — | No | Heading text (`h3`). |
|
|
368
|
+
| …rest | `React.HTMLAttributes<HTMLHeadingElement>` | — | No | Attributes on the `h3`. |
|
|
369
|
+
|
|
370
|
+
### Card.Delta
|
|
371
|
+
|
|
372
|
+
| Prop | Type | Default | Required | Description |
|
|
373
|
+
|------|------|---------|----------|-------------|
|
|
374
|
+
| trend | `"up" \| "down" \| "neutral"` | — | No | Sets `data-trend` for color. |
|
|
375
|
+
| className | `string` | — | No | Extra class. |
|
|
376
|
+
| children | `React.ReactNode` | — | No | Delta / period copy. |
|
|
377
|
+
| …rest | `React.HTMLAttributes<HTMLSpanElement>` | — | No | Attributes on the `span`. |
|
|
378
|
+
|
|
379
|
+
### Card.CtaBody
|
|
380
|
+
|
|
381
|
+
| Prop | Type | Default | Required | Description |
|
|
382
|
+
|------|------|---------|----------|-------------|
|
|
383
|
+
| className | `string` | — | No | Extra class. |
|
|
384
|
+
| children | `React.ReactNode` | — | No | Supporting copy in **`cta`**. |
|
|
385
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the `div`. |
|
|
386
|
+
|
|
387
|
+
### Card.Actions
|
|
388
|
+
|
|
389
|
+
| Prop | Type | Default | Required | Description |
|
|
390
|
+
|------|------|---------|----------|-------------|
|
|
391
|
+
| className | `string` | — | No | Extra class. |
|
|
392
|
+
| children | `React.ReactNode` | — | No | Buttons / links row. |
|
|
393
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the `div`. |
|
|
394
|
+
|
|
395
|
+
### Card.Cover
|
|
396
|
+
|
|
397
|
+
| Prop | Type | Default | Required | Description |
|
|
398
|
+
|------|------|---------|----------|-------------|
|
|
399
|
+
| className | `string` | — | No | Extra class. |
|
|
400
|
+
| children | `React.ReactNode` | — | No | Image or media block (`cover` variant). |
|
|
401
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the `div`. |
|
|
402
|
+
|
|
403
|
+
### Card.Split
|
|
404
|
+
|
|
405
|
+
| Prop | Type | Default | Required | Description |
|
|
406
|
+
|------|------|---------|----------|-------------|
|
|
407
|
+
| className | `string` | — | No | Extra class. |
|
|
408
|
+
| children | `React.ReactNode` | — | No | Typically two **`SplitCell`** children. |
|
|
409
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the grid `div`. |
|
|
410
|
+
|
|
411
|
+
### Card.SplitCell
|
|
412
|
+
|
|
413
|
+
| Prop | Type | Default | Required | Description |
|
|
414
|
+
|------|------|---------|----------|-------------|
|
|
415
|
+
| className | `string` | — | No | Extra class. |
|
|
416
|
+
| children | `React.ReactNode` | — | No | One metric column: **`Label`** + **`Value`**, or **`IconBox`** + **`Stack`** (as in **`mini`**) when using the icon tile. |
|
|
417
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the cell `div`. |
|
|
418
|
+
|
|
419
|
+
### Card.ListHeader
|
|
420
|
+
|
|
421
|
+
| Prop | Type | Default | Required | Description |
|
|
422
|
+
|------|------|---------|----------|-------------|
|
|
423
|
+
| className | `string` | — | No | Extra class. |
|
|
424
|
+
| children | `React.ReactNode` | — | No | Title row for **`list`**. |
|
|
425
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the `div`. |
|
|
426
|
+
|
|
427
|
+
### Card.List
|
|
428
|
+
|
|
429
|
+
| Prop | Type | Default | Required | Description |
|
|
430
|
+
|------|------|---------|----------|-------------|
|
|
431
|
+
| className | `string` | — | No | Extra class. |
|
|
432
|
+
| children | `React.ReactNode` | — | No | **`ListItem`** nodes. |
|
|
433
|
+
| …rest | `React.HTMLAttributes<HTMLUListElement>` | — | No | Attributes on the `ul` (forwardRef). |
|
|
434
|
+
|
|
435
|
+
### Card.ListItem
|
|
436
|
+
|
|
437
|
+
| Prop | Type | Default | Required | Description |
|
|
438
|
+
|------|------|---------|----------|-------------|
|
|
439
|
+
| className | `string` | — | No | Extra class. |
|
|
440
|
+
| children | `React.ReactNode` | — | No | Row content. |
|
|
441
|
+
| …rest | `React.HTMLAttributes<HTMLLIElement>` | — | No | Attributes on the `li` (forwardRef). |
|
|
442
|
+
|
|
443
|
+
### Card.SectionHeader
|
|
444
|
+
|
|
445
|
+
| Prop | Type | Default | Required | Description |
|
|
446
|
+
|------|------|---------|----------|-------------|
|
|
447
|
+
| className | `string` | — | No | Extra class. |
|
|
448
|
+
| children | `React.ReactNode` | — | No | Title row content. |
|
|
449
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the header `div`. |
|
|
450
|
+
|
|
451
|
+
### Card.SectionTitle
|
|
452
|
+
|
|
453
|
+
| Prop | Type | Default | Required | Description |
|
|
454
|
+
|------|------|---------|----------|-------------|
|
|
455
|
+
| className | `string` | — | No | Extra class. |
|
|
456
|
+
| children | `React.ReactNode` | — | No | Heading text. |
|
|
457
|
+
| …rest | `React.HTMLAttributes<HTMLHeadingElement>` | — | No | Attributes on the `h3`. |
|
|
458
|
+
|
|
459
|
+
### Card.SectionTrailing
|
|
460
|
+
|
|
461
|
+
| Prop | Type | Default | Required | Description |
|
|
462
|
+
|------|------|---------|----------|-------------|
|
|
463
|
+
| className | `string` | — | No | Extra class. |
|
|
464
|
+
| children | `React.ReactNode` | — | No | Icons or actions. |
|
|
465
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the trailing `div`. |
|
|
466
|
+
|
|
467
|
+
### Card.Body
|
|
468
|
+
|
|
469
|
+
| Prop | Type | Default | Required | Description |
|
|
470
|
+
|------|------|---------|----------|-------------|
|
|
471
|
+
| className | `string` | — | No | Extra class. |
|
|
472
|
+
| children | `React.ReactNode` | — | No | Padded **`panel`** content (text, tables). One **element** child can stretch inside the padded area. |
|
|
473
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the body `div`. |
|
|
474
|
+
|
|
475
|
+
### Card.Chart
|
|
476
|
+
|
|
477
|
+
| Prop | Type | Default | Required | Description |
|
|
478
|
+
|------|------|---------|----------|-------------|
|
|
479
|
+
| className | `string` | — | No | Extra class. |
|
|
480
|
+
| children | `React.ReactNode` | — | No | **`panel`** chart root; **no** inner padding (edge-to-edge). |
|
|
481
|
+
| …rest | `React.HTMLAttributes<HTMLDivElement>` | — | No | Attributes on the chart region `div`. |
|
|
482
|
+
|
|
483
|
+
## Imports
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
import { Card } from "prime-ui-kit";
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
CSS for this component is included in the main bundle (`prime-ui-kit/styles.css` / `bundle.css`) when you import the library styles.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Checkbox
|
|
2
|
+
|
|
3
|
+
**Проектирование по умолчанию:** при проектировании экранов и примеров изначально выбирай **`m`** для `size` (где есть ось размера), если явно не оговорено иное.
|
|
4
|
+
|
|
5
|
+
## About
|
|
6
|
+
|
|
7
|
+
A compound checkbox: a visually hidden native `input type="checkbox"`, a decorative box with check or indeterminate mark, and optional label, hint, and error text wired to `aria-describedby` and invalid state.
|
|
8
|
+
|
|
9
|
+
- **When to use** — explicit consent, terms, or other “yes/no” fields that submit with the form (`name`, `value`, `required`).
|
|
10
|
+
- **When to use** — row or “select all” patterns where the parent shows **indeterminate** when only some children are checked.
|
|
11
|
+
- **When to use** — independent toggles (filters, optional features) rather than one-of-many choices.
|
|
12
|
+
- **When to use** — hint text or inline validation aligned under the label column.
|
|
13
|
+
- **When not to use** — exactly one option from a set of alternatives (prefer [Radio](../radio/COMPONENT.md)).
|
|
14
|
+
- **When not to use** — a single binary setting where a switch fits the product language (prefer [Switch](../switch/COMPONENT.md)).
|
|
15
|
+
- **When not to use** — you need `asChild` or fully custom markup; the control is a fixed [Label](../label/COMPONENT.md) row with a hidden input and SVG.
|
|
16
|
+
|
|
17
|
+
## Composition
|
|
18
|
+
|
|
19
|
+
- **`Checkbox.Root`** — wraps the field in a `div` with `data-size`, `data-variant`, `data-disabled`, `data-invalid`, `data-checked`, `data-indeterminate`; provides context and `ControlSizeProvider` for child parts.
|
|
20
|
+
- **`Checkbox.Label`** — required for the control: hosts the native checkbox and decorative SVG, then optional text in a trailing column; sets `htmlFor` to the input id.
|
|
21
|
+
- **`Checkbox.Hint`** — optional; registers hint text and contributes its id to the input’s `aria-describedby`.
|
|
22
|
+
- **`Checkbox.Error`** — optional; error-styled [Hint](../hint/COMPONENT.md) and registers invalid state when mounted (with `variant="error"` on the root when you want error chrome without the slot).
|
|
23
|
+
- **Order:** `Root` → `Label` (always) → `Hint` / `Error` below when needed. Public API: `Checkbox` with `Root`, `Label`, `Hint`, `Error`.
|
|
24
|
+
|
|
25
|
+
### Minimal example
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { Checkbox } from "prime-ui-kit";
|
|
29
|
+
|
|
30
|
+
export function Example() {
|
|
31
|
+
return (
|
|
32
|
+
<Checkbox.Root name="terms" value="yes">
|
|
33
|
+
<Checkbox.Label>Accept terms</Checkbox.Label>
|
|
34
|
+
</Checkbox.Root>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Rules
|
|
40
|
+
|
|
41
|
+
- Вертикальный ритм между **подписью и hint** задаётся самим компонентом; не вставляйте между ними лишний [Typography](../typography/COMPONENT.md) с другой ролью чтения без необходимости.
|
|
42
|
+
- Support **controlled** (`checked` + `onChange`) and **uncontrolled** (`defaultChecked`); internal state updates from the change handler before your `onChange` runs.
|
|
43
|
+
- **`indeterminate`** only affects visuals and the DOM `indeterminate` property; it is not a separate submitted value—clear or sync it in your handler when the user clicks.
|
|
44
|
+
- Set **`aria-label`** or **`aria-labelledby`** on **`Checkbox.Root`** when **`Checkbox.Label`** has no visible text (icon-only or header “select all” cell).
|
|
45
|
+
- **`aria-describedby`** on the root is merged with hint and error ids when those slots are mounted; include your own ids in `aria-describedby` if you need extra descriptors.
|
|
46
|
+
- **`variant="error"`** or a mounted **`Checkbox.Error`** sets `aria-invalid` and error styling; **`disabled`** disables the input and dims hint styling.
|
|
47
|
+
- Focus and keyboard activation use the native checkbox; the visible focus ring targets the decorative control via `focus-visible`.
|
|
48
|
+
- There is no loading or `asChild` API; **`size`** on the root does not forward to the DOM input (layout token only).
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### Checkbox.Root
|
|
53
|
+
|
|
54
|
+
| Prop | Type | Default | Required | Description |
|
|
55
|
+
|------|------|---------|----------|-------------|
|
|
56
|
+
| variant | `"default" \| "error"` | `"default"` | no | Error-colored outline for `error`; `invalid` is also true when `Checkbox.Error` is mounted. |
|
|
57
|
+
| size | `"s" \| "m" \| "l" \| "xl"` | `"m"` | no | Box and typography scale. |
|
|
58
|
+
| indeterminate | `boolean` | `false` | no | Indeterminate visuals; syncs `input.indeterminate`. |
|
|
59
|
+
| id | `string` | auto (`useId`) | no | Stable input id; paired with `Checkbox.Label` via `htmlFor`. |
|
|
60
|
+
| className | `string` | — | no | Class on the field wrapper `div`. |
|
|
61
|
+
| checked | `boolean` | — | no | Controlled checked state. |
|
|
62
|
+
| defaultChecked | `boolean` | `false` | no | Initial checked state when uncontrolled. |
|
|
63
|
+
| onChange | `React.ChangeEventHandler<HTMLInputElement>` | — | no | Fired on toggle; internal checked state updates before this runs. |
|
|
64
|
+
| disabled | `boolean` | — | no | Disables the input and label row. |
|
|
65
|
+
| aria-describedby | `string` | — | no | Combined with hint and error ids when those slots exist. |
|
|
66
|
+
| children | `React.ReactNode` | — | no | Typically `Label`, optional `Hint` / `Error`. |
|
|
67
|
+
| ref | `React.Ref<HTMLInputElement>` | — | no | Ref to the native checkbox input. |
|
|
68
|
+
| …rest | `Omit<React.InputHTMLAttributes<HTMLInputElement>, "type" \| "size">` | — | no | Other native attributes forwarded to the hidden `input` (e.g. `name`, `value`, `required`, `readOnly`, `form`). `type` is always `checkbox`. |
|
|
69
|
+
|
|
70
|
+
### Checkbox.Label
|
|
71
|
+
|
|
72
|
+
| Prop | Type | Default | Required | Description |
|
|
73
|
+
|------|------|---------|----------|-------------|
|
|
74
|
+
| children | `React.ReactNode` | — | no | Label text beside the box; omit for a box-only control and set an accessible name on `Root`. |
|
|
75
|
+
| className | `string` | — | no | Class on the label row. |
|
|
76
|
+
| …rest | `Omit<React.HTMLAttributes<HTMLLabelElement>, "htmlFor" \| "size">` | — | no | Other label attributes; `htmlFor` is managed internally. |
|
|
77
|
+
|
|
78
|
+
### Checkbox.Hint
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Default | Required | Description |
|
|
81
|
+
|------|------|---------|----------|-------------|
|
|
82
|
+
| children | `React.ReactNode` | — | yes | Supplementary text below the label. |
|
|
83
|
+
| className | `string` | — | no | Additional class on the hint. |
|
|
84
|
+
| …rest | `Omit<React.HTMLAttributes<HTMLParagraphElement>, "id">` | — | no | Paragraph attributes; `id` is managed internally. |
|
|
85
|
+
|
|
86
|
+
### Checkbox.Error
|
|
87
|
+
|
|
88
|
+
| Prop | Type | Default | Required | Description |
|
|
89
|
+
|------|------|---------|----------|-------------|
|
|
90
|
+
| children | `React.ReactNode` | — | yes | Error message text. |
|
|
91
|
+
| className | `string` | — | no | Additional class on the message. |
|
|
92
|
+
| …rest | `Omit<React.HTMLAttributes<HTMLParagraphElement>, "id">` | — | no | Paragraph attributes; `id` is managed internally. |
|
|
93
|
+
|
|
94
|
+
## Related
|
|
95
|
+
|
|
96
|
+
- [Radio](../radio/COMPONENT.md) — one-of-many choice with the same validation variants.
|
|
97
|
+
- [Switch](../switch/COMPONENT.md) — binary setting with a different control pattern.
|
|
98
|
+
- [Label](../label/COMPONENT.md), [Hint](../hint/COMPONENT.md) — primitives used inside the checkbox; pair with [Input](../input/COMPONENT.md) in larger forms.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# CodeBlock
|
|
2
|
+
|
|
3
|
+
## About
|
|
4
|
+
|
|
5
|
+
`CodeBlock` is a static presentation component: it renders a TS or TSX source string with syntax highlighting and a light or dark token palette. The kit exposes a single part, `Root`, which outputs a `pre` whose inner `code` markup is produced by `highlightTsxHtml`.
|
|
6
|
+
|
|
7
|
+
- **When to use** — partner docs, marketing pages, or in-app help where you need a short snippet that matches the kit’s typography and theme.
|
|
8
|
+
- **When to use** — API reference cards, integration guides, or internal tools showing request bodies, configs, or generated output you control.
|
|
9
|
+
- **When to use** — pairing a snippet with surrounding copy (`Typography`, labels) where the block should stay non-interactive and read-only.
|
|
10
|
+
- **When not to use** — raw or untrusted user input as `code` (markup is injected via `dangerouslySetInnerHTML`).
|
|
11
|
+
- **When not to use** — languages other than TS/TSX or cases that need a full parser or line numbers, copy buttons, and tabs (add those in your app layer).
|
|
12
|
+
- **When not to use** — when you need a focusable, editable code field (use an input or a dedicated editor instead).
|
|
13
|
+
|
|
14
|
+
## Composition
|
|
15
|
+
|
|
16
|
+
- The public API is the `CodeBlock` object with one subpart: **`Root`**.
|
|
17
|
+
- **`Root`** renders a native **`pre`**. Highlighted content is injected as a single inner **`code`** element; do not pass `children` or `dangerouslySetInnerHTML` yourself — they are excluded from the props type.
|
|
18
|
+
- Pass the source as the **`code`** string prop. Optional **`colorScheme`** selects the highlighting palette (`data-theme` on `pre`).
|
|
19
|
+
|
|
20
|
+
### Minimal example
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { CodeBlock } from "prime-ui-kit";
|
|
24
|
+
|
|
25
|
+
export function Example() {
|
|
26
|
+
return <CodeBlock.Root code='export const n = 1;' />;
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Rules
|
|
31
|
+
|
|
32
|
+
- **`code`** is required. The implementation applies **`trimEnd()`** before highlighting; leading indentation in the string is preserved aside from trailing whitespace on the whole string.
|
|
33
|
+
- **`colorScheme`** defaults to **`"light"`**; use **`"dark"`** when the block sits on a dark surface so token colors stay readable.
|
|
34
|
+
- **Security:** inner HTML comes from **`highlightTsxHtml`**. Only pass **trusted** strings (constants, vetted CMS content, sanitized backend output).
|
|
35
|
+
- **Highlighting** uses a TS/TSX-oriented heuristic in the kit, not a full language grammar — rare syntax may not get the expected classes.
|
|
36
|
+
- **No built-in `size`:** font size and line height follow the parent; control rhythm with wrapper layout and typography tokens.
|
|
37
|
+
- **Accessibility:** treat the block as static prose context; add **`aria-label`**, **`aria-describedby`**, or nearby headings via standard **`pre`** attributes spread from **`…rest`** when screen readers need an explicit label.
|
|
38
|
+
- **Focus:** the component does not set **`tabIndex`**; make it focusable only if your UX requires it.
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### CodeBlock.Root
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Required | Description |
|
|
45
|
+
|------|------|---------|----------|-------------|
|
|
46
|
+
| `code` | `string` | — | Yes | TS/TSX source; trailing whitespace is trimmed with `trimEnd()` before highlighting. |
|
|
47
|
+
| `colorScheme` | `CodeBlockColorScheme` (`"light" \| "dark"`) | `"light"` | No | Token palette / `data-theme` on the root `pre`. |
|
|
48
|
+
| `className` | `string` | — | No | Additional class on the root `pre`. |
|
|
49
|
+
| `…rest` | `Omit<React.HTMLAttributes<HTMLPreElement>, "children" \| "dangerouslySetInnerHTML">` | — | No | Other native `pre` attributes (`id`, `style`, ARIA, `data-*`, event handlers, etc.). `children` and `dangerouslySetInnerHTML` are omitted. |
|
|
50
|
+
|
|
51
|
+
The package also exports **`CodeBlockColorScheme`** and **`CodeBlockRootProps`** for typing.
|
|
52
|
+
|
|
53
|
+
## Related
|
|
54
|
+
|
|
55
|
+
- [Typography](../typography/COMPONENT.md) — headings and body copy around snippets.
|
|
56
|
+
- [Button](../button/COMPONENT.md) — switching multiple samples from parent state.
|
|
57
|
+
- [Segmented control](../segmented-control/COMPONENT.md) — compact mode or sample switching in toolbars.
|
|
58
|
+
- [Kbd](../kbd/COMPONENT.md) — shortcut hints next to prose, without duplicating the code block’s role.
|