@capra/core 1.5.3 → 1.6.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/index.cjs +23 -23
- package/dist/index.d.cts +9 -9
- package/dist/index.d.mts +9 -9
- package/dist/index.mjs +23 -23
- package/dist/style.css +62 -32
- package/docs/conventions--docs.md +186 -0
- package/docs/core-alert--design.md +110 -0
- package/docs/core-alert--usage.md +13 -0
- package/docs/core-anchor--design.md +39 -0
- package/docs/core-anchor--usage.md +39 -0
- package/docs/core-autocompletefield--design.md +91 -0
- package/docs/core-autocompletefield--usage.md +18 -0
- package/docs/core-badge--design.md +70 -0
- package/docs/core-badge--usage.md +13 -0
- package/docs/core-breadcrumbs--design.md +65 -0
- package/docs/core-breadcrumbs--usage.md +16 -0
- package/docs/core-button--design.md +97 -0
- package/docs/core-button--usage.md +17 -0
- package/docs/core-buttonlink--design.md +7 -0
- package/docs/core-buttonlink--usage.md +24 -0
- package/docs/core-card--design.md +100 -0
- package/docs/core-card--usage.md +5 -0
- package/docs/core-checkbox--design.md +66 -0
- package/docs/core-checkbox--usage.md +34 -0
- package/docs/core-collapse--design.md +28 -0
- package/docs/core-collapse--usage.md +20 -0
- package/docs/core-datepickerfield--design.md +71 -0
- package/docs/core-datepickerfield--usage.md +57 -0
- package/docs/core-daterangepickerfield--design.md +76 -0
- package/docs/core-daterangepickerfield--usage.md +62 -0
- package/docs/core-divider--design.md +35 -0
- package/docs/core-divider--usage.md +8 -0
- package/docs/core-drawer--design.md +87 -0
- package/docs/core-drawer--usage.md +9 -0
- package/docs/core-emptystate--design.md +45 -0
- package/docs/core-emptystate--usage.md +13 -0
- package/docs/core-helpertext--design.md +30 -0
- package/docs/core-helpertext--usage.md +11 -0
- package/docs/core-iconbutton--design.md +87 -0
- package/docs/core-iconbutton--usage.md +15 -0
- package/docs/core-inputrow--design.md +85 -0
- package/docs/core-inputrow--usage.md +6 -0
- package/docs/core-label--design.md +27 -0
- package/docs/core-label--usage.md +17 -0
- package/docs/core-link--design.md +58 -0
- package/docs/core-link--usage.md +16 -0
- package/docs/core-listitem--design.md +70 -0
- package/docs/core-listitem--usage.md +6 -0
- package/docs/core-menu--design.md +106 -0
- package/docs/core-menu--usage.md +16 -0
- package/docs/core-modal--design.md +39 -0
- package/docs/core-modal--usage.md +11 -0
- package/docs/core-numberfield--design.md +12 -0
- package/docs/core-numberfield--usage.md +14 -0
- package/docs/core-pagination--design.md +30 -0
- package/docs/core-pagination--usage.md +13 -0
- package/docs/core-passwordfield--design.md +7 -0
- package/docs/core-passwordfield--usage.md +3 -0
- package/docs/core-pill--design.md +94 -0
- package/docs/core-pill--usage.md +10 -0
- package/docs/core-popover--design.md +25 -0
- package/docs/core-popover--usage.md +8 -0
- package/docs/core-radio--design.md +39 -0
- package/docs/core-radio--usage.md +8 -0
- package/docs/core-radiogroup--design.md +5 -0
- package/docs/core-radiogroup--usage.md +12 -0
- package/docs/core-radiotile--design.md +5 -0
- package/docs/core-radiotile--usage.md +10 -0
- package/docs/core-ribbon--design.md +39 -0
- package/docs/core-ribbon--usage.md +12 -0
- package/docs/core-skeleton--design.md +88 -0
- package/docs/core-skeleton--usage.md +13 -0
- package/docs/core-skeletongroup--design.md +50 -0
- package/docs/core-skeletongroup--usage.md +10 -0
- package/docs/core-spinner--design.md +99 -0
- package/docs/core-spinner--usage.md +11 -0
- package/docs/core-switch--design.md +145 -0
- package/docs/core-switch--usage.md +8 -0
- package/docs/core-tabnav--design.md +77 -0
- package/docs/core-tabnav--usage.md +63 -0
- package/docs/core-tag--design.md +21 -0
- package/docs/core-tag--usage.md +11 -0
- package/docs/core-text--design.md +32 -0
- package/docs/core-text--usage.md +10 -0
- package/docs/core-textarea--design.md +74 -0
- package/docs/core-textarea--usage.md +18 -0
- package/docs/core-textfield--design.md +81 -0
- package/docs/core-textfield--usage.md +12 -0
- package/docs/core-textinput--design.md +72 -0
- package/docs/core-textinput--usage.md +19 -0
- package/docs/core-toast--design.md +100 -0
- package/docs/core-toast--usage.md +11 -0
- package/docs/core-tooltip--design.md +61 -0
- package/docs/core-tooltip--usage.md +48 -0
- package/docs/core-topnav--design.md +75 -0
- package/docs/core-topnav--usage.md +6 -0
- package/docs/core-verticalnavigation--design.md +31 -0
- package/docs/core-verticalnavigation--usage.md +17 -0
- package/docs/core-visuallyhidden--design.md +87 -0
- package/docs/core-visuallyhidden--usage.md +35 -0
- package/docs/history-changelogs-capra-core--docs.md +49 -0
- package/docs/index.md +110 -0
- package/docs/using-capra--docs.md +39 -0
- package/package.json +5 -4
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Core/DateRangePickerField - Usage
|
|
2
|
+
|
|
3
|
+
| Prop | Type | Required | Default | Description |
|
|
4
|
+
| --- | --- | --- | --- | --- |
|
|
5
|
+
| `helperText` | `string` | No | `--` | Helper text below the field. Replaced by error message when status is error. Use for requirements, disclaimers. |
|
|
6
|
+
| `label` | `string` | No | `--` | Label for the field. Required for accessibility; use aria-label if another element acts as label. |
|
|
7
|
+
| `layout` | `'vertical' \| 'horizontal'` | No | `--` | Label and field layout: vertical (label above) or horizontal (label on leading side). Prefer vertical; use horizontal when space is limited. |
|
|
8
|
+
| `placeholder` | `unknown` | No | `--` | Placeholders for empty start and end, shown with a swap icon between them when the group is not focus-within. |
|
|
9
|
+
| `granularity` | `'day' \| 'second'` | No | `--` | Smallest date/time unit shown in the fields. Only `day` and `second` are supported. |
|
|
10
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
11
|
+
| `canClear` | `boolean` | No | `--` | When true, shows a clear control to the left of the calendar button while the field has a value. |
|
|
12
|
+
| `disabled` | `boolean` | No | `--` | Disables the field. |
|
|
13
|
+
| `id` | `string` | No | `--` | Optional id for the root; associates the label and field. |
|
|
14
|
+
| `readOnly` | `boolean` | No | `--` | Read-only field. |
|
|
15
|
+
| `required` | `boolean` | No | `--` | Required field. |
|
|
16
|
+
| `isInvalid` | `boolean` | No | `--` | Invalid value; `appearance="danger"` also forces an invalid state for display. |
|
|
17
|
+
|
|
18
|
+
## Props reference
|
|
19
|
+
|
|
20
|
+
### Field layout and presentation
|
|
21
|
+
|
|
22
|
+
| Prop | Type | Description |
|
|
23
|
+
| ------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
24
|
+
| `label` | `string` | Visible label text; pair with `required` or assistive naming when the visible label is not sufficient. |
|
|
25
|
+
| `helperText` | `string` | Descriptive or error text below the field (rendered in the description slot). |
|
|
26
|
+
| `layout` | `'vertical' \| 'horizontal'` | Label placement relative to the control. |
|
|
27
|
+
| `appearance` | `'default' \| 'danger' \| 'warning'` | Visual status; `danger` also marks the field invalid for accessibility. |
|
|
28
|
+
| `size` | `'sm' \| 'md'` | Height and density of the input shell. |
|
|
29
|
+
| `leadingSlot` | `ReactNode` | Optional content before the segmented inputs (same pattern as `TextInput`). |
|
|
30
|
+
| `placeholder` | `readonly [string, string]` | Start and end placeholders when both bounds are empty and the group is not focus-within. |
|
|
31
|
+
| `id` | `string` | Optional id for the root; associates the label and field. |
|
|
32
|
+
| `FORCE__className` | `string` | Escape hatch: extra class on the field shell; see `StylingOverrideProps` in source. |
|
|
33
|
+
| `disabled` | `boolean` | Disables the control. |
|
|
34
|
+
| `readOnly` | `boolean` | Read-only mode. |
|
|
35
|
+
| `required` | `boolean` | Marks the field required for forms and assistive technologies. |
|
|
36
|
+
| `isInvalid` | `boolean` | Marks the value invalid; combined with `appearance === 'danger'`. |
|
|
37
|
+
|
|
38
|
+
### Value, format, overlay, and change events
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Description |
|
|
41
|
+
| --------------------- | --------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
|
|
42
|
+
| `value` | `RangeValue<T> \| null` | Controlled range (`T` is a `DateValue` generic, defaulting to the library `DateValue`). |
|
|
43
|
+
| `defaultValue` | `RangeValue<T> \| null` | Initial range when uncontrolled. |
|
|
44
|
+
| `onChange` | `(value: RangeValue<MappedDateValue<T>> \| null) => void` | Fired when the committed range changes. |
|
|
45
|
+
| `granularity` | `'day' \| 'hour' \| 'minute' \| 'second'` | Smallest unit shown in the fields (default follows value type, e.g. day for plain dates). |
|
|
46
|
+
| `shouldCloseOnSelect` | `boolean \| () => boolean` | Whether the popover closes after a calendar interaction. |
|
|
47
|
+
|
|
48
|
+
`MappedDateValue<T>` preserves time and calendar types aligned with `T` (for example `CalendarDate` vs `CalendarDateTime`).
|
|
49
|
+
|
|
50
|
+
For selecting a new range entirely inside the calendar without the overlay closing between the first and second date,
|
|
51
|
+
set `shouldCloseOnSelect={false}` (as in the example stories).
|
|
52
|
+
|
|
53
|
+
Use `isInvalid` and `helperText` for invalid feedback in Capra layouts. Validation behavior is fixed to ARIA-associated messaging for this shell (not configurable).
|
|
54
|
+
|
|
55
|
+
### Props not supported or intentionally fixed
|
|
56
|
+
|
|
57
|
+
| Prop | Notes |
|
|
58
|
+
| ---------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
59
|
+
| `children` | Ignored; structure (label, inputs, calendar) is fixed. |
|
|
60
|
+
| `style` | Not part of the public styling contract; use design tokens and `FORCE__className` if needed. |
|
|
61
|
+
| `validationBehavior` | Not configurable; the implementation always uses ARIA-associated validation for this shell. |
|
|
62
|
+
| `description`, `errorMessage` (slot-style API) | Not part of the public props surface; use `helperText` and validation props instead. |
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Core/Divider - Design
|
|
2
|
+
|
|
3
|
+
Divider separates and groups content. Use horizontal dividers between sections; use vertical dividers between inline items. A horizontal divider can optionally display a label. Dividers are static and not keyboard focusable.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use Collapse to structure readable content, separate regions, or group related information. Pair it with shared spacing, typography, and surface rules. Do not stretch it into an interaction pattern that already has a dedicated component.
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### Label
|
|
12
|
+
|
|
13
|
+
A horizontal divider can be given a label to provide context to a grouping. When possible, avoid labeled dividers and use headings instead. When you do use a label, ensure it has the proper semantic level (e.g. pass an `<h2>` or `<h3>` as children) so it is announced as a heading by assistive technologies.
|
|
14
|
+
|
|
15
|
+
## Best Practices
|
|
16
|
+
|
|
17
|
+
Do:
|
|
18
|
+
|
|
19
|
+
* Do use Divider to separate semantically distinct groups.
|
|
20
|
+
* Do use a label when the divider introduces a new conceptual group.
|
|
21
|
+
|
|
22
|
+
Don't:
|
|
23
|
+
|
|
24
|
+
* Don't use Divider between every list item in a dense list.
|
|
25
|
+
* Don't use Divider as pure decoration.
|
|
26
|
+
|
|
27
|
+
## Accessibility
|
|
28
|
+
|
|
29
|
+
* Dividers are static and not keyboard focusable.
|
|
30
|
+
* Unlabeled horizontal dividers render as an `<hr>` (a thematic break between content).
|
|
31
|
+
* When a horizontal divider has a label, prefer a real heading element as children (for example, `Text` with `as="h2"` or `as="h3"`) when the label introduces a new section, so the label is announced with the correct level. When possible, avoid labeled dividers and use headings instead.
|
|
32
|
+
|
|
33
|
+
## Related components
|
|
34
|
+
|
|
35
|
+
* [Collapse](?path=/docs/core-collapse--design)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Core/Divider - Usage
|
|
2
|
+
|
|
3
|
+
Divider separates and groups content. Use horizontal dividers between sections; use vertical dividers between inline items. A horizontal divider can optionally display a label. Dividers are static and not keyboard focusable.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
8
|
+
| `type` | `string` | No | 'horizontal' | `--` |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Core/Drawer - Design
|
|
2
|
+
|
|
3
|
+
## Behavior
|
|
4
|
+
|
|
5
|
+
### Modality
|
|
6
|
+
|
|
7
|
+
A contextual sheet can be **modal** or **non-modal**.
|
|
8
|
+
|
|
9
|
+
**Modal** sheets use a scrim to block interaction with the main page.
|
|
10
|
+
|
|
11
|
+
**Non-modal** sheets allow simultaneous interaction with the sheet and main page surfaces.
|
|
12
|
+
Non-modal sheets are best used for experiences that require a persistent but dismissible sheet that benefits from
|
|
13
|
+
interacting with the main page, like viewing location details on a map.
|
|
14
|
+
|
|
15
|
+
### Navigation
|
|
16
|
+
|
|
17
|
+
Navigating within a context sheet should be avoided where possible. If navigating is necessary, keep it shallow –
|
|
18
|
+
no more than 1 level deep.
|
|
19
|
+
|
|
20
|
+
When presenting a secondary view in a context sheet, the primary view content is replaced. The secondary view is
|
|
21
|
+
dismissed by making a selection or pressing a backward navigation button.
|
|
22
|
+
|
|
23
|
+
### Dismissing
|
|
24
|
+
|
|
25
|
+
Context sheets are dismissed by:
|
|
26
|
+
|
|
27
|
+
1. Pressing the close button
|
|
28
|
+
2. Confirming or cancelling the drawer
|
|
29
|
+
3. Interacting with the scrim (when present)
|
|
30
|
+
4. Pressing the escape key when the general sheet container is focused
|
|
31
|
+
|
|
32
|
+
In code, wire footer actions and other dismiss paths to `onClose`. A scrim is shown when the drawer
|
|
33
|
+
is **modal** (`modal`).
|
|
34
|
+
|
|
35
|
+
## Screen size
|
|
36
|
+
|
|
37
|
+
### Small screens
|
|
38
|
+
|
|
39
|
+
On small screens, the vertical height of a context sheet defaults up to 50% of the screen height. Scrolling the
|
|
40
|
+
sheet first slides it to full height before the content area scrolls.
|
|
41
|
+
|
|
42
|
+
### Medium and large screens
|
|
43
|
+
|
|
44
|
+
On larger screens, drawers are fixed to the **trailing** edge of the screen. Content that extends beyond the
|
|
45
|
+
vertical bounds of the drawer scrolls. Do not scroll horizontally. The drawer header and footer are pinned above the
|
|
46
|
+
scrolled content. Drawers have a min-width of 400px and max-width of 80% of the parent viewport.
|
|
47
|
+
|
|
48
|
+
## Best practices
|
|
49
|
+
|
|
50
|
+
### Stacking
|
|
51
|
+
|
|
52
|
+
**Do**
|
|
53
|
+
|
|
54
|
+
Keep interactions within context sheets on the sheet surface. Use inline progressive disclosure to reveal
|
|
55
|
+
additional or optional content.
|
|
56
|
+
|
|
57
|
+
**Don't**
|
|
58
|
+
|
|
59
|
+
Launch other context sheets over a context sheet.
|
|
60
|
+
|
|
61
|
+
### In-sheet navigation
|
|
62
|
+
|
|
63
|
+
**Do**
|
|
64
|
+
|
|
65
|
+
Keep navigation to a minimum within context sheets. Keep the navigation stack shallow when necessary, no more than
|
|
66
|
+
1 level.
|
|
67
|
+
|
|
68
|
+
**Don't**
|
|
69
|
+
|
|
70
|
+
Add deep or multi-level navigation stacks inside a single context sheet; prefer replacing content or using shallow
|
|
71
|
+
steps instead.
|
|
72
|
+
|
|
73
|
+
## Accessibility
|
|
74
|
+
|
|
75
|
+
### Keyboard interaction
|
|
76
|
+
|
|
77
|
+
| Key | Function |
|
|
78
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
79
|
+
| `Tab` / `Shift+Tab` | In **modal** mode, focus stays within the drawer while open. In **non-modal** mode, focus can move freely between the sheet and the main page. |
|
|
80
|
+
| `Escape` | Closes the drawer whether focus is on the dialog surface or inside it (capture-phase listener). |
|
|
81
|
+
|
|
82
|
+
### Roles and properties
|
|
83
|
+
|
|
84
|
+
* The panel uses `role="dialog"` with `aria-labelledby` (title) or `aria-label` as needed. While open, `aria-modal` is `true` for modal drawers and `false` for non-modal drawers.
|
|
85
|
+
* **Modal** mode: focus is trapped; `usePreventScroll` locks page scrolling. **Non-modal** mode: no focus containment or scroll lock on the document.
|
|
86
|
+
* The close control exposes an accessible name (“Close drawer”).
|
|
87
|
+
* When you add `Breadcrumbs` in the title, the trail is an ordered list with an `aria-label` of “Breadcrumb” by default; the last crumb should represent the current page (typically without an `href`).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Core/Drawer - Usage
|
|
2
|
+
|
|
3
|
+
### Implementation
|
|
4
|
+
|
|
5
|
+
The drawer UI is rendered in a **portal** (default `document.body`), with `position: fixed` and `top`/`bottom` anchoring so the sheet fills the **layout viewport** (the browser window on a real site; the Storybook **preview iframe** in docs/canvas). In the **Story** canvas, a decorator stretches the preview document so the iframe can grow with the panel; that shell is **skipped in Docs** so embedded previews are not forced to full-viewport height. The open drawer still fills the iframe, not the inline story box—resize the preview panel if you need a taller canvas.
|
|
6
|
+
|
|
7
|
+
### Header
|
|
8
|
+
|
|
9
|
+
The header is the `title` slot: a string for a single heading, or a composition with `Drawer.Heading`, optional `Drawer.Description`, `Drawer.ExpandedTitleLayout`, and the shared `Breadcrumbs` components (matching the `Modal` pattern). The header stays pinned while the body scrolls.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Core/EmptyState - Design
|
|
2
|
+
|
|
3
|
+
The EmptyState component is used to display a message when there is no data to display. Illustrations are lazy-loaded and support light/dark themes via the theme prop.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Title
|
|
8
|
+
|
|
9
|
+
All empty states have a title. Titles provide a brief summary of the reason an empty state is shown.
|
|
10
|
+
|
|
11
|
+
### Description
|
|
12
|
+
|
|
13
|
+
All empty states have a description. Descriptions provide the details and instructions on next steps the user can take.
|
|
14
|
+
|
|
15
|
+
### Action (optional)
|
|
16
|
+
|
|
17
|
+
A call to action can be used to provide quick access to relevant next steps. Full page empty states use a primary button. Smaller empty states use a secondary button.
|
|
18
|
+
|
|
19
|
+
### Illustration
|
|
20
|
+
|
|
21
|
+
All empty states have an illustration. Pass an illustration slug (e.g. `EmptyFolder`, `PizzaBox`) via the `illustration` prop.
|
|
22
|
+
|
|
23
|
+
Use the `theme` prop (`light` or `dark`) to switch between light/dark variants when the illustration supports them. Illustrations are lazy-loaded for optimal bundle size.
|
|
24
|
+
|
|
25
|
+
## Content
|
|
26
|
+
|
|
27
|
+
### Title / explanation format
|
|
28
|
+
|
|
29
|
+
This format allows empty states to provide both a catchy main title and a more detailed explanation. The title should provide the broad action with the explanation providing additional detail.
|
|
30
|
+
|
|
31
|
+
Titles should be in sentence format with no ending punctuation. Descriptions should be in sentence format with ending punctuation.
|
|
32
|
+
|
|
33
|
+
### Call to action
|
|
34
|
+
|
|
35
|
+
A call to action enables users to easily move forward from an empty state. It can take the form of a link embedded within the description to send the user to another page, or a button to perform an action.
|
|
36
|
+
|
|
37
|
+
Full page empty states (`size="lg"`) should use a primary button, as the action is the primary next step for the user. Smaller empty states should use a secondary button if the action is already present elsewhere on the page.
|
|
38
|
+
|
|
39
|
+
### Description wrapping
|
|
40
|
+
|
|
41
|
+
Descriptions will wrap if the parent container is small enough, but strings should be kept short when possible.
|
|
42
|
+
|
|
43
|
+
### Graphs
|
|
44
|
+
|
|
45
|
+
When using graph tiles, an empty state should be smaller to match the size of the graph tile.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Core/EmptyState - Usage
|
|
2
|
+
|
|
3
|
+
The EmptyState component is used to display a message when there is no data to display. Illustrations are lazy-loaded and support light/dark themes via the theme prop.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `illustration` | `(typeof illustrationSlugs)[number]` | No | `--` | The illustration to display, identified by slug. Use theme to switch between light/dark variants when available. @default "EmptyFolder" |
|
|
8
|
+
| `theme` | `'light' \| 'dark'` | No | `--` | The theme for the illustration. Determines which variant to show when light/dark variants exist. @default "light" |
|
|
9
|
+
| `size` | `'md' \| 'lg'` | No | `--` | The size of the empty state. `lg` is for large components or the whole pages. @default "md" |
|
|
10
|
+
| `title` | `string` | Yes | `--` | The title to display in the empty state. |
|
|
11
|
+
| `description` | `string` | No | `--` | The description to display in the empty state. Please do not skip this property without a good reason. |
|
|
12
|
+
| `children` | `React.ReactNode` | No | `--` | Generic use for adding a button or other action elements below the description. |
|
|
13
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Core/HelperText - Design
|
|
2
|
+
|
|
3
|
+
Helper text for inputs.
|
|
4
|
+
|
|
5
|
+
:::warning
|
|
6
|
+
|
|
7
|
+
Prefer Capra field components—such as `TextField`, `NumberField`, `PasswordField`, `TextArea`, `DatePicker`, `DateRangePicker`, or `AutocompleteField`—which
|
|
8
|
+
include helper text in the standard field layout. Use standalone `HelperText` only when you are building a
|
|
9
|
+
custom field or a layout that those components do not cover.
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
## Accessibility
|
|
14
|
+
|
|
15
|
+
### Error and warning content
|
|
16
|
+
|
|
17
|
+
For `appearance="danger"`, the helper region uses `role="alert"` so critical validation
|
|
18
|
+
messages are exposed promptly to assistive technologies. Warning and default appearances do not use `alert`;
|
|
19
|
+
ensure critical errors use `danger` when this behavior is desired.
|
|
20
|
+
|
|
21
|
+
### Live regions
|
|
22
|
+
|
|
23
|
+
When `countText` is present, it is wrapped with `aria-live="polite"` so changes (for example
|
|
24
|
+
remaining characters) are announced without interrupting the user.
|
|
25
|
+
|
|
26
|
+
### Relationship to the field
|
|
27
|
+
|
|
28
|
+
For custom compositions, associate helper copy with the control using `aria-describedby` on the input
|
|
29
|
+
pointing at an `id` on the helper element, or use patterns documented on the field component you wrap.
|
|
30
|
+
Capra built-in fields handle these relationships when you pass their `helperText` props.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Core/HelperText - Usage
|
|
2
|
+
|
|
3
|
+
Helper text for inputs.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `appearance` | `(typeof appearances)[number]` | No | `--` | Appearance of the input.<br>@default 'default' |
|
|
8
|
+
| `children` | `string` | No | `--` | Main text. Use for hints, requirements, disclaimers, etc. |
|
|
9
|
+
| `countText` | `string` | No | `--` | Text to display on the right side of the helper text. Is marked as a live content area via `aria-live`. |
|
|
10
|
+
| `disabled` | `boolean` | No | `--` | Whether the input the helper text applies to is disabled. |
|
|
11
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Core/IconButton - Design
|
|
2
|
+
|
|
3
|
+
Interactive element displaying a single icon.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Icon
|
|
8
|
+
|
|
9
|
+
<p>
|
|
10
|
+
Icon buttons are used to quickly identify available actions.
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p>
|
|
14
|
+
Common actions, like save or search, can omit titles and use the icon alone. Avoid using an icon alone when the meaning is ambiguous, unclear, or unfamiliar.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<p>
|
|
18
|
+
View available icons in the Icon library.
|
|
19
|
+
</p>
|
|
20
|
+
|
|
21
|
+
### Size
|
|
22
|
+
|
|
23
|
+
<p>
|
|
24
|
+
Buttons are available in small, medium, and large sizes. Medium is the default size and is preferred in most situations.
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<p>
|
|
28
|
+
Small buttons are primarily used when buttons appear inline with over components, such as in a popover and to conserve space.
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
### Loading
|
|
32
|
+
|
|
33
|
+
<p>
|
|
34
|
+
Buttons can show a loading state for actions that take longer to respond.
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p>
|
|
38
|
+
The loading spinner is shown in the leading icon slot, replacing an icon if present. Button text should be updated to indicate the action currently taking place. Further interaction is disabled until the action is complete.
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
## Behavior
|
|
42
|
+
|
|
43
|
+
### Tooltips
|
|
44
|
+
|
|
45
|
+
<p>
|
|
46
|
+
Icon buttons reveal the label in a tooltip on hover or long-press.
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<img src="images/guidelines/iconbutton/behavior-tooltip.png" />
|
|
50
|
+
|
|
51
|
+
### Loading delay
|
|
52
|
+
|
|
53
|
+
<p>
|
|
54
|
+
Buttons can show a loading state for actions that take longer to respond.
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
<p>
|
|
58
|
+
The loading spinner is shown in place of the icon. Further interaction is disabled until the action is complete.
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
### State
|
|
62
|
+
|
|
63
|
+
<p>
|
|
64
|
+
Buttons use a color shift between palette indexes for interaction states. The available sates are enabled, hover, active, focused, disabled, and pending.
|
|
65
|
+
</p>
|
|
66
|
+
|
|
67
|
+
<img src="images/guidelines/iconbutton/behavior-state.png" />
|
|
68
|
+
|
|
69
|
+
## Accessibility
|
|
70
|
+
|
|
71
|
+
### Keyboard interaction
|
|
72
|
+
|
|
73
|
+
All buttons exist in the page’s natural tab sequence, reachable via TAB and SHIFT+TAB keys. Pressing SPACEBAR or ENTER activates the focused button.
|
|
74
|
+
|
|
75
|
+
### Labeling
|
|
76
|
+
|
|
77
|
+
<p>
|
|
78
|
+
For buttons with an icon and text, if the icon reinforces the text, do not add any description of the icon as it would be redundant.
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
<p>
|
|
82
|
+
If the icon adds important information that is not explained in the text, then the label of the button must begin with the text with any extra information about the icon following the text. This order supports users who control their device with speech.
|
|
83
|
+
</p>
|
|
84
|
+
|
|
85
|
+
<p>
|
|
86
|
+
Icon buttons without text must have an easily identifiable (for speech users) accessible label, such as “Download.”
|
|
87
|
+
</p>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Core/IconButton - Usage
|
|
2
|
+
|
|
3
|
+
Interactive element displaying a single icon.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `icon` | `SvgIcon` | Yes | `--` | Icon to display in the button. |
|
|
8
|
+
| `aria-label` | `string` | Yes | `--` | Accessibility label to apply to the button. |
|
|
9
|
+
| `variant` | `(typeof variants)[number]` | No | 'secondary' | Which button style to use. Defaults to `secondary`. |
|
|
10
|
+
| `appearance` | `(typeof appearances)[number]` | No | 'default' | Appearance to apply to the button. Defaults to `default`. |
|
|
11
|
+
| `size` | `(typeof sizes)[number]` | No | 'md' | Size of the button. Defaults to `md`. |
|
|
12
|
+
| `disabled` | `boolean` | No | false | Whether the button is disabled. |
|
|
13
|
+
| `pending` | `boolean` | No | false | Whether the button is in a pending state. |
|
|
14
|
+
| `onClick` | `React.ComponentProps<'button'>['onClick']` | No | `--` | Click handler for the button. |
|
|
15
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Core/InputRow - Design
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
`InputRow` is a horizontal container that visually merges one primary input with optional prefix and
|
|
6
|
+
suffix segments so the whole group reads as a single control. Use it for URLs, currency amounts, units, fixed
|
|
7
|
+
labels (for example `https://` or `.com`), and similar patterns where the value only makes
|
|
8
|
+
sense together with its neighbors.
|
|
9
|
+
|
|
10
|
+
## `InputRow`
|
|
11
|
+
|
|
12
|
+
### Role and labeling
|
|
13
|
+
|
|
14
|
+
The root is a `div` laid out as a flex row. When you pass `aria-label` or `aria-labelledby`, the row defaults to `role="group"` so assistive technologies can treat
|
|
15
|
+
the children as one related set. Give the row a short name that describes the combined value (for example
|
|
16
|
+
“Web address” or “Price”).
|
|
17
|
+
|
|
18
|
+
Order children left-to-right: leading segment, primary field, trailing segment. Capra field wrappers use `display: contents` when they are **direct** children of the row, so the inner input
|
|
19
|
+
participates in the flex layout and border-joining rules; keep fields and addons as immediate children of `InputRow`.
|
|
20
|
+
|
|
21
|
+
### Visual treatment
|
|
22
|
+
|
|
23
|
+
Only the outer corners of the group use the standard field radius; shared edges between segments stay square
|
|
24
|
+
so borders overlap cleanly instead of doubling. Adjacent borders are collapsed with a small negative margin;
|
|
25
|
+
the segment that contains focus is raised in the stacking order so its focus ring stays visible.
|
|
26
|
+
|
|
27
|
+
## `InputRow.Addon`
|
|
28
|
+
|
|
29
|
+
### Static segments
|
|
30
|
+
|
|
31
|
+
`InputRow.Addon` is for **non-editable** content: fixed text, symbols, or decorative
|
|
32
|
+
icons. String children are rendered with the typography `Text` component; pass arbitrary nodes for
|
|
33
|
+
icons or richer content.
|
|
34
|
+
|
|
35
|
+
Addons are flex-shrink-safe strips with a muted surface and field-aligned borders so they match `TextInput` height and baseline. Place one or more addons before and/or after the field; the
|
|
36
|
+
primary input should remain the flexible segment in the middle when you have both sides.
|
|
37
|
+
|
|
38
|
+
### Size
|
|
39
|
+
|
|
40
|
+
The `size` prop on `InputRow.Addon` (`md` by default, or `sm`)
|
|
41
|
+
controls minimum height and typography so the addon lines up with an adjacent `TextField` or `NumberField` using the same `size`.
|
|
42
|
+
|
|
43
|
+
## Composing with Capra `*Field` components
|
|
44
|
+
|
|
45
|
+
### Which fields to use
|
|
46
|
+
|
|
47
|
+
`TextField` and `NumberField` are the usual primary controls inside a row. Other Capra
|
|
48
|
+
field roots that expose `data-capra-field-root` (for example `AutocompleteField`, `DatePicker`, or `DateRangePicker`) use the same layout hook: the wrapper does not create
|
|
49
|
+
an extra flex box, so the inner control can share borders with addons like a plain `TextInput`.
|
|
50
|
+
|
|
51
|
+
Prefer one primary editable control per row. Pair it with `InputRow.Addon` for fixed text or icons,
|
|
52
|
+
or with another bordered control as a leading/trailing segment when the design calls for a separate control
|
|
53
|
+
(for example a unit or scheme picker), keeping that control a direct child so border overlap still applies.
|
|
54
|
+
|
|
55
|
+
### Labels, helper text, and slots
|
|
56
|
+
|
|
57
|
+
Do not pass `label`, `helperText`, or `layout` props on Capra field wrappers
|
|
58
|
+
inside an `InputRow`. Those patterns reserve vertical space for label and helper rows and break the
|
|
59
|
+
single horizontal group.
|
|
60
|
+
|
|
61
|
+
Put the visible label (if any) *outside* the row—for example a standalone `Label` or
|
|
62
|
+
surrounding copy tied with `aria-labelledby` on `InputRow`. For validation or hints,
|
|
63
|
+
show helper text below the whole row, not on the nested field.
|
|
64
|
+
|
|
65
|
+
Avoid `leadingSlot` and `trailingSlot` on `TextField` when the same concern is
|
|
66
|
+
already expressed with `InputRow.Addon`; slots are meant for compact adornments on the input itself,
|
|
67
|
+
not for full row segments.
|
|
68
|
+
|
|
69
|
+
### Accessible names
|
|
70
|
+
|
|
71
|
+
When `label` is omitted on nested fields, each focusable control still needs a name: use `aria-label` or `aria-labelledby` on `TextField`, `NumberField`, or
|
|
72
|
+
the inner input as documented for that component. The row-level `aria-label` names the group; each
|
|
73
|
+
control should have its own short name (“Domain”, “Amount”, “Unit”, and so on) where several tab stops exist.
|
|
74
|
+
|
|
75
|
+
## Accessibility
|
|
76
|
+
|
|
77
|
+
### Grouping
|
|
78
|
+
|
|
79
|
+
When the row combines multiple inputs or segments that share one label, put `aria-label` or `aria-labelledby` on `InputRow` and ensure each focusable control still has a distinct
|
|
80
|
+
accessible name where needed.
|
|
81
|
+
|
|
82
|
+
### Addons
|
|
83
|
+
|
|
84
|
+
Treat `InputRow.Addon` as presentational unless the text is essential; decorative icons should use `aria-hidden`. If addon text conveys meaning not duplicated elsewhere, leave it in the accessibility
|
|
85
|
+
tree.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Core/InputRow - Usage
|
|
2
|
+
|
|
3
|
+
| Prop | Type | Required | Default | Description |
|
|
4
|
+
| --- | --- | --- | --- | --- |
|
|
5
|
+
| `children` | `React.ReactNode` | No | `--` | `--` |
|
|
6
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Core/Label - Design
|
|
2
|
+
|
|
3
|
+
Label text and optional required indicator for form fields, aligned with Capra field layouts.
|
|
4
|
+
|
|
5
|
+
:::warning
|
|
6
|
+
|
|
7
|
+
Prefer Capra field components—such as `TextField`, `NumberField`, `PasswordField`, `TextArea`, `DatePicker`, `DateRangePicker`, or `AutocompleteField`—which
|
|
8
|
+
wire labels, inputs, and helper text together with consistent layout and accessibility. Use standalone `Label` only when you are composing a custom field or integrating with primitives that do not ship a built-in label.
|
|
9
|
+
|
|
10
|
+
:::
|
|
11
|
+
|
|
12
|
+
## Accessibility
|
|
13
|
+
|
|
14
|
+
### Association
|
|
15
|
+
|
|
16
|
+
<p>
|
|
17
|
+
Pair `Label` with its control using `htmlFor` on the label and a matching `id` on
|
|
18
|
+
the input (or equivalent association pattern for custom widgets). Every form control should have an accessible name;
|
|
19
|
+
a visible `Label` is one straightforward way to provide it.
|
|
20
|
+
</p>
|
|
21
|
+
|
|
22
|
+
### Required fields
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
The visual asterisk for <code>required</code> is marked <code>aria-hidden</code> so it is not double-announced; the
|
|
26
|
+
required state is also conveyed with visually hidden text for screen readers.
|
|
27
|
+
</p>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Core/Label - Usage
|
|
2
|
+
|
|
3
|
+
Label text and optional required indicator for form fields, aligned with Capra field layouts.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `children` | `string` | No | `--` | Text to display in the label. |
|
|
8
|
+
| `required` | `boolean` | No | `--` | Whether the field the label is labeling is required (shows asterisk after label). |
|
|
9
|
+
| `trailingSlot` | `React.ReactNode` | No | `--` | Content after the label text. |
|
|
10
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|
|
11
|
+
|
|
12
|
+
## React Aria
|
|
13
|
+
|
|
14
|
+
<p>
|
|
15
|
+
The component uses <code>useContextProps</code> with React Aria’s <code>LabelContext</code>, so when it sits inside
|
|
16
|
+
compatible React Aria structures, label props can be supplied by context as well as passed directly.
|
|
17
|
+
</p>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Core/Link - Design
|
|
2
|
+
|
|
3
|
+
Links are navigational elements that take users to a new page.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Text
|
|
8
|
+
|
|
9
|
+
The text representing the link should describe its destination.
|
|
10
|
+
|
|
11
|
+
### isExternal
|
|
12
|
+
|
|
13
|
+
External links display an icon at the trailing end of the link. They navigate to a page outside the product and open
|
|
14
|
+
in a new tab.
|
|
15
|
+
|
|
16
|
+
### Client-side Routing
|
|
17
|
+
|
|
18
|
+
Links support client-side routing out of the box when Capra's `RouterProvider` is used. See the
|
|
19
|
+
[Conventions](/docs/conventions--docs#client-side-routing) page for more details.
|
|
20
|
+
|
|
21
|
+
## Best Practices
|
|
22
|
+
|
|
23
|
+
**Do**
|
|
24
|
+
|
|
25
|
+
<p>
|
|
26
|
+
Do clearly indicate the destination of a link through its text.
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
**Don't**
|
|
30
|
+
|
|
31
|
+
<p>
|
|
32
|
+
Don't use vague instructions, such as “click here”, for links.
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
## Accessibility
|
|
36
|
+
|
|
37
|
+
### Keyboard interaction
|
|
38
|
+
|
|
39
|
+
All links exist in the page's natural tab sequence, reachable via TAB and SHIFT+TAB keys. Pressing ENTER activates
|
|
40
|
+
the focused link.
|
|
41
|
+
|
|
42
|
+
### External links
|
|
43
|
+
|
|
44
|
+
External links should announce themselves as opening in a new tab. For example: "Link text, opens in a new tab."
|
|
45
|
+
|
|
46
|
+
### Keyboard focus indicator
|
|
47
|
+
|
|
48
|
+
Links inherit the standard focus indicator standard to all focusable elements.
|
|
49
|
+
|
|
50
|
+
## Accessibility
|
|
51
|
+
|
|
52
|
+
* Meaningful link text: describe the destination, not "click here" or "read more".
|
|
53
|
+
* External links: announce the new-tab behavior in the link text or `aria-label` (e.g., "Opens in new tab").
|
|
54
|
+
|
|
55
|
+
## Related components
|
|
56
|
+
|
|
57
|
+
* [Button](?path=/docs/core-button--design)
|
|
58
|
+
* [Anchor](?path=/docs/core-anchor--design)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Core/Link - Usage
|
|
2
|
+
|
|
3
|
+
Links are navigational elements that take users to a new page.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `as` | `As` | No | `--` | The underlying element rendered by the component. Defaults to `a`. |
|
|
8
|
+
| `isExternal` | `boolean` | No | false | Whether the Link points to an external resource.<br><br>When `true` and `as="a"`, applies `target="_blank"` and `rel="noopener noreferrer"`.<br><br>Defaults to `false`. |
|
|
9
|
+
| `href` | `unknown` | No | `--` | A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). |
|
|
10
|
+
| `hrefLang` | `string` | No | `--` | Hints at the human language of the linked URL. See[MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang). |
|
|
11
|
+
| `target` | `HTMLAttributeAnchorTarget` | No | `--` | The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). |
|
|
12
|
+
| `rel` | `string` | No | `--` | The relationship between the linked resource and the current page. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel). |
|
|
13
|
+
| `download` | `boolean \| string` | No | `--` | Causes the browser to download the linked URL. A string may be provided to suggest a file name. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#download). |
|
|
14
|
+
| `referrerPolicy` | `HTMLAttributeReferrerPolicy` | No | `--` | How much of the referrer to send when following the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#referrerpolicy). |
|
|
15
|
+
| `routerOptions` | `unknown` | No | `--` | Options for the configured client side router. |
|
|
16
|
+
| `FORCE__className` | `string` | No | `--` | 🚨 This prop is meant to be an escape hatch. 🚨<br><br>If the desired style cannot be achieved using component props, use this as a last resort. The inner workings of Capra components are implementation details and this escape hatch gives one access to those implementation details. We cannot make any guarantees that styles will applied correctly across version updates. Please use it responsibly.<br><br>Add a CSS class to the component. |
|