@capra/core 1.5.2 → 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 +27 -24
- package/dist/index.mjs +27 -24
- 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 +7 -6
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Core/Card - Design
|
|
2
|
+
|
|
3
|
+
The base component for the card.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use a Card to group related content—title, optional description, body, actions, and footer—into one scannable unit, often in grids or lists of similar items.
|
|
8
|
+
|
|
9
|
+
Treat the card as a container: put links and buttons inside slots rather than making the whole surface ambiguous.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Title
|
|
14
|
+
|
|
15
|
+
<p>
|
|
16
|
+
All cards must have a title identifying their content purpose. Use sentence case.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p>
|
|
20
|
+
Card titles are wrapped by an `h2` by default, but can change based on their hierarchy within the page. Be sure to
|
|
21
|
+
note the heading level in your design file. The header's visual presentation remains the same regardless of
|
|
22
|
+
heading level.
|
|
23
|
+
</p>
|
|
24
|
+
|
|
25
|
+
### Description
|
|
26
|
+
|
|
27
|
+
<p>
|
|
28
|
+
Optional. The description gives additional context to the contexts of the card. Descriptions should be brief,
|
|
29
|
+
taking up no more than a single line.
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
### Actions
|
|
33
|
+
|
|
34
|
+
<p>
|
|
35
|
+
Contextual actions act on the main content area but keep the user's workflow within the card. Common examples
|
|
36
|
+
would be controls that act upon data visualizations, such as a View Switcher and range selections.
|
|
37
|
+
</p>
|
|
38
|
+
|
|
39
|
+
<p>
|
|
40
|
+
Supporting, non-interactive, data can also be displayed in this space.
|
|
41
|
+
</p>
|
|
42
|
+
|
|
43
|
+
### Content
|
|
44
|
+
|
|
45
|
+
<p>
|
|
46
|
+
The primary content of the card. This is generally "one thing", though that could be a complex element such as a
|
|
47
|
+
graph or form.
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
### Footer
|
|
51
|
+
|
|
52
|
+
<p>
|
|
53
|
+
Place actions or supplementary information to the primary content in the card's footer.
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
<p>
|
|
57
|
+
Actions placed here (e.g., a submit button for a form) take the user's workflow out of the card. There should be
|
|
58
|
+
an explicit indication of completion within the context of the card when the action is taken.
|
|
59
|
+
</p>
|
|
60
|
+
|
|
61
|
+
## Layout and spacing
|
|
62
|
+
|
|
63
|
+
* Padding: `spacing.xl` on all sides (standard), `spacing.lg` for compact cards.
|
|
64
|
+
* Title and description: `spacing.sm` gap between them.
|
|
65
|
+
* Title/description block and content: `spacing.lg` gap.
|
|
66
|
+
* Border: `shape.border.default`, `shape.radius.xl`.
|
|
67
|
+
* Background: `color.background.panel.solid`.
|
|
68
|
+
|
|
69
|
+
## Behavior
|
|
70
|
+
|
|
71
|
+
* Cards are static containers by default.
|
|
72
|
+
* If the entire card is interactive (e.g., a selectable card), use `role="button"` with keyboard support. Prefer [RadioTile](?path=/docs/core-radiotile--design) for selection scenarios.
|
|
73
|
+
|
|
74
|
+
## Content
|
|
75
|
+
|
|
76
|
+
* Title: sentence case, noun phrase.
|
|
77
|
+
* Description: optional; one short line, sentence case with punctuation if needed.
|
|
78
|
+
* Action labels: verb-first, title case.
|
|
79
|
+
|
|
80
|
+
## Best Practices
|
|
81
|
+
|
|
82
|
+
Do:
|
|
83
|
+
|
|
84
|
+
* Do include a title in every card.
|
|
85
|
+
* Do use the footer slot for secondary metadata (timestamps, status).
|
|
86
|
+
|
|
87
|
+
Don't:
|
|
88
|
+
|
|
89
|
+
* Don't make the entire card surface the only navigation affordance — put a [Link](?path=/docs/core-link--design) or [Button](?path=/docs/core-button--design) inside the content.
|
|
90
|
+
* Don't use Card for tabular data — use a table.
|
|
91
|
+
|
|
92
|
+
## Accessibility
|
|
93
|
+
|
|
94
|
+
* Card titles are typically wrapped at an `h2` by default; choose the heading level (`h2`–`h6`) to match the page outline. Note the intended level in design specs—the visual style stays the same across levels.
|
|
95
|
+
* If the card is a landmark region, wrap with `<section aria-labelledby>`.
|
|
96
|
+
|
|
97
|
+
## Related components
|
|
98
|
+
|
|
99
|
+
* [RadioTile](?path=/docs/core-radiotile--design) — For selectable card options.
|
|
100
|
+
* [Modal](?path=/docs/core-modal--design) — For focused overlay containers.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Core/Checkbox - Design
|
|
2
|
+
|
|
3
|
+
Checkbox component for capturing boolean user input. Supports controlled and uncontrolled modes with proper accessibility.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use a Checkbox when people can turn several options on or off independently within a group, and those choices apply when the form is submitted (or in another explicit save step).
|
|
8
|
+
|
|
9
|
+
Use a visible group heading and stack options so each label stays associated with its control. Use `indeterminate` on a parent checkbox when a tree or grouped list is partially selected.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Label
|
|
14
|
+
|
|
15
|
+
A label is required for all checkboxes. They should be short and represent a value or yes/no decision. Ensure
|
|
16
|
+
`aria-label` or `aria-labelledby` is used if the checkbox label is not immediately associated with the control.
|
|
17
|
+
|
|
18
|
+
### Checked
|
|
19
|
+
|
|
20
|
+
A checkbox can be unchecked, checked, or in an indeterminate state
|
|
21
|
+
|
|
22
|
+
### Disabled
|
|
23
|
+
|
|
24
|
+
A checkbox can be disabled in any state if there is a prerequisite to enable the selection.
|
|
25
|
+
|
|
26
|
+
## Content
|
|
27
|
+
|
|
28
|
+
* Sentence case labels.
|
|
29
|
+
* Describe the option, not the action (e.g., "Send email notifications", not "Enable email").
|
|
30
|
+
|
|
31
|
+
## Behaviour
|
|
32
|
+
|
|
33
|
+
### Single choice
|
|
34
|
+
|
|
35
|
+
A single discrete checkbox can be used for yes/no decisions within a form.
|
|
36
|
+
|
|
37
|
+
### Overflow
|
|
38
|
+
|
|
39
|
+
Labels will wrap if they are wider than the parent container. The checkbox remains aligned to the top of the text
|
|
40
|
+
box.
|
|
41
|
+
|
|
42
|
+
## Best Practices
|
|
43
|
+
|
|
44
|
+
Do:
|
|
45
|
+
|
|
46
|
+
* Do use checkboxes for multi-select form options.
|
|
47
|
+
* Do use `indeterminate` for parent checkboxes in tree structures.
|
|
48
|
+
* Do provide a group heading for checkbox groups.
|
|
49
|
+
|
|
50
|
+
Don't:
|
|
51
|
+
|
|
52
|
+
* Don't use Checkbox for settings that apply immediately without submit — use Switch.
|
|
53
|
+
* Don't use Checkbox for mutually exclusive options — use RadioGroup.
|
|
54
|
+
* Don't use a lone Checkbox as a single on/off setting that applies immediately — use Switch.
|
|
55
|
+
|
|
56
|
+
## Accessibility
|
|
57
|
+
|
|
58
|
+
* `role="checkbox"`, `aria-checked` (including "mixed" for indeterminate).
|
|
59
|
+
* Associate label using `<label for>` or wrapping `<label>`.
|
|
60
|
+
* Checkbox group must have a group heading using `role="group"` with `aria-labelledby`.
|
|
61
|
+
* Keyboard: Tab / Shift+Tab moves focus; Space or Enter toggles state when the checkbox is focused.
|
|
62
|
+
|
|
63
|
+
## Related components
|
|
64
|
+
|
|
65
|
+
* [Switch](?path=/docs/core-switch--design) — For immediate binary settings.
|
|
66
|
+
* [RadioGroup](?path=/docs/core-radiogroup--design) — For mutually exclusive selections.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Core/Checkbox - Usage
|
|
2
|
+
|
|
3
|
+
Checkbox component for capturing boolean user input. Supports controlled and uncontrolled modes with proper accessibility.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `indeterminate` | `boolean` | No | `--` | Whether the checkbox is in an indeterminate state. |
|
|
8
|
+
| `checked` | `boolean` | No | `--` | Controlled checked state. Use with onChange for controlled component. |
|
|
9
|
+
| `defaultChecked` | `boolean` | No | `--` | Default checked state for uncontrolled component. |
|
|
10
|
+
| `children` | `string \| React.ReactNode` | No | `--` | The label for the checkbox. |
|
|
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. |
|
|
12
|
+
|
|
13
|
+
## Integration Notes
|
|
14
|
+
|
|
15
|
+
### Ant Design Form Compatibility
|
|
16
|
+
|
|
17
|
+
When using Checkbox inside an Ant Design `<Form>` component, the focus ring may appear incorrectly due to Ant Design's global CSS:
|
|
18
|
+
|
|
19
|
+
```css
|
|
20
|
+
.ant-form input[type='checkbox']:focus {
|
|
21
|
+
outline-offset: -2px;
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Capra's Checkbox includes `!important` on its focus styles to override this, but if you encounter issues, add a local override where you're using this component:
|
|
26
|
+
|
|
27
|
+
```css
|
|
28
|
+
.checkbox {
|
|
29
|
+
input[type='checkbox']:focus,
|
|
30
|
+
input[type='checkbox']:focus-visible {
|
|
31
|
+
outline-offset: 2px !important;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Core/Collapse - Design
|
|
2
|
+
|
|
3
|
+
A collapsible disclosure section with an expandable header and panel. Pass **`title`** for the header label, optional **`headerTrailingContentSlot`** for trailing actions (switches, buttons), and the panel body via **`children`**.
|
|
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 action pattern that already has a dedicated component.
|
|
8
|
+
|
|
9
|
+
## Best Practices
|
|
10
|
+
|
|
11
|
+
* Do use Collapse to support hierarchy, grouping, and readable scanning.
|
|
12
|
+
* Don't turn Collapse into an action container when a dedicated interactive pattern exists.
|
|
13
|
+
|
|
14
|
+
## Accessibility
|
|
15
|
+
|
|
16
|
+
### Keyboard interaction
|
|
17
|
+
|
|
18
|
+
| Key | Function |
|
|
19
|
+
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
20
|
+
| `Tab`, `Shift-Tab` | When contents are collapsed, focus moves to the next or previous collapse header. When contents are expanded, focus moves to the next or previous focusable element within the expanded content. |
|
|
21
|
+
| `Enter`, `Space` | When focus is on the accordion header, toggles the expanded/collapsed state. |
|
|
22
|
+
|
|
23
|
+
* When receiving focus through the keyboard, the focus outline appears around the title of the collapse header.
|
|
24
|
+
|
|
25
|
+
## Related components
|
|
26
|
+
|
|
27
|
+
* [Card](?path=/docs/core-card--design)
|
|
28
|
+
* [Divider](?path=/docs/core-divider--design)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Core/Collapse - Usage
|
|
2
|
+
|
|
3
|
+
A collapsible disclosure section with an expandable header and panel. Pass **`title`** for the header label, optional **`headerTrailingContentSlot`** for trailing actions (switches, buttons), and the panel body via **`children`**.
|
|
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
|
+
| `title` | `string` | Yes | `--` | Plain string title rendered in the disclosure heading. |
|
|
9
|
+
| `headerTrailingContentSlot` | `React.ReactNode` | No | `--` | Trailing header region for actions (switches, buttons, etc.). |
|
|
10
|
+
| `children` | `React.ReactNode` | Yes | `--` | Content of the disclosure panel. |
|
|
11
|
+
|
|
12
|
+
### `Collapse` root API
|
|
13
|
+
|
|
14
|
+
Pass **`title`** (plain string) for the header label, optional **`headerTrailingContentSlot`** for trailing actions
|
|
15
|
+
(switches, buttons), and the panel body via **`children`**.
|
|
16
|
+
|
|
17
|
+
The root forwards these `Disclosure` props from `react-aria-components`:
|
|
18
|
+
**`id`** (use when a parent **`DisclosureGroup`** controls expansion),
|
|
19
|
+
**`defaultExpanded`**, **`isExpanded`**, **`onExpandedChange`**, and **`isDisabled`**. Use **`FORCE__className`** on the
|
|
20
|
+
root as the style escape hatch.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Core/DatePickerField - Design
|
|
2
|
+
|
|
3
|
+
## Anatomy
|
|
4
|
+
|
|
5
|
+
The date picker combines a segmented date input with a calendar in a popover. Values use types from
|
|
6
|
+
[`@internationalized/date`](https://react-spectrum.adobe.com/internationalized/date/) (for example `CalendarDate`).
|
|
7
|
+
The visible format follows the user’s locale.
|
|
8
|
+
|
|
9
|
+
## Properties
|
|
10
|
+
|
|
11
|
+
### Label
|
|
12
|
+
|
|
13
|
+
Provide a visible `label` so the control has a clear accessible name. If another element acts as the label, wire the
|
|
14
|
+
relationship with `aria-labelledby` or `aria-label` instead.
|
|
15
|
+
|
|
16
|
+
### Value
|
|
17
|
+
|
|
18
|
+
Use `value` with `onChange` for a controlled value, or `defaultValue` for an uncontrolled initial value. The handler
|
|
19
|
+
receives `null` when the field is cleared.
|
|
20
|
+
|
|
21
|
+
### Placeholder
|
|
22
|
+
|
|
23
|
+
`placeholder` shows a single string when the field is empty and not focused. Prefer `helperText` for requirements or
|
|
24
|
+
instructions that must stay visible.
|
|
25
|
+
|
|
26
|
+
### Helper text
|
|
27
|
+
|
|
28
|
+
Helper text sits below the field for requirements, hints, or errors. Pair `appearance="danger"` with error copy so
|
|
29
|
+
the invalid state is clear visually and to assistive technologies.
|
|
30
|
+
|
|
31
|
+
### Layout
|
|
32
|
+
|
|
33
|
+
`layout` can be **vertical** (label above) or **horizontal** (label on the leading side). Prefer vertical; use
|
|
34
|
+
horizontal when horizontal space is tight.
|
|
35
|
+
|
|
36
|
+
## Feedback
|
|
37
|
+
|
|
38
|
+
### Appearance
|
|
39
|
+
|
|
40
|
+
`appearance` supports **default**, **danger** (invalid / error), and **warning**. Danger also drives the invalid
|
|
41
|
+
state for accessibility in addition to any explicit `isInvalid` flag.
|
|
42
|
+
|
|
43
|
+
### Disabled
|
|
44
|
+
|
|
45
|
+
Disabled fields cannot be edited and do not receive focus. Values are not submitted with native form submission.
|
|
46
|
+
|
|
47
|
+
### Read-only
|
|
48
|
+
|
|
49
|
+
Read-only fields cannot be edited; the value stays visible for reading and assistive technologies.
|
|
50
|
+
|
|
51
|
+
## Accessibility
|
|
52
|
+
|
|
53
|
+
### Keyboard and pointer behavior
|
|
54
|
+
|
|
55
|
+
* **Tab** moves focus into the segmented field or calendar trigger; **Shift+Tab** moves out.
|
|
56
|
+
* Arrow keys adjust focused segments; calendar grid follows standard date grid keyboard patterns when the popover is open.
|
|
57
|
+
* **Space** / **Enter** on the calendar button opens the popover where supported by the platform pattern.
|
|
58
|
+
|
|
59
|
+
### Labeling and instructions
|
|
60
|
+
|
|
61
|
+
Provide a visible `label` or an accessible name via `aria-label` / `aria-labelledby`. Do not rely on `placeholder` alone
|
|
62
|
+
for the accessible name. Prefer persistent `helperText` for requirements; placeholder disappears when the user types.
|
|
63
|
+
|
|
64
|
+
### Validation and state
|
|
65
|
+
|
|
66
|
+
Use `appearance="danger"` with error content in `helperText` for a consistent error treatment. Set `required` when the
|
|
67
|
+
field is mandatory. Disabled fields are not interactive and are excluded from native submission; read-only fields keep
|
|
68
|
+
their values visible but are not editable.
|
|
69
|
+
|
|
70
|
+
Ensure focus indicators remain visible (at least 2px, 3:1 contrast) and interactive targets meet at least 24×24 CSS
|
|
71
|
+
pixels where applicable.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Core/DatePickerField - 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
|
+
| `granularity` | `'day' \| 'second'` | No | `--` | Smallest date/time unit shown in the field. Only `day` and `second` are supported. |
|
|
9
|
+
| `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. |
|
|
10
|
+
| `canClear` | `boolean` | No | `--` | When true, shows a clear control to the left of the calendar button while the field has a value. |
|
|
11
|
+
| `disabled` | `boolean` | No | `--` | Disables the field. |
|
|
12
|
+
| `id` | `string` | No | `--` | Optional id for the root; associates the label and field. |
|
|
13
|
+
| `readOnly` | `boolean` | No | `--` | Read-only field. |
|
|
14
|
+
| `required` | `boolean` | No | `--` | Required field. |
|
|
15
|
+
| `isInvalid` | `boolean` | No | `--` | Invalid value; `appearance="danger"` also forces an invalid state for display. |
|
|
16
|
+
|
|
17
|
+
## Props reference
|
|
18
|
+
|
|
19
|
+
### Field layout and presentation
|
|
20
|
+
|
|
21
|
+
| Prop | Type | Description |
|
|
22
|
+
| ------------------ | ------------------------------------ | ------------------------------------------------------------------------------------------------------ |
|
|
23
|
+
| `label` | `string` | Visible label text; pair with `required` or assistive naming when the visible label is not sufficient. |
|
|
24
|
+
| `helperText` | `string` | Descriptive or error text below the field (rendered in the description slot). |
|
|
25
|
+
| `layout` | `'vertical' \| 'horizontal'` | Label placement relative to the control. |
|
|
26
|
+
| `appearance` | `'default' \| 'danger' \| 'warning'` | Visual status; `danger` also marks the field invalid for accessibility. |
|
|
27
|
+
| `size` | `'sm' \| 'md'` | Height and density of the input shell. |
|
|
28
|
+
| `leadingSlot` | `ReactNode` | Optional content before the segmented input (same pattern as `TextInput`). |
|
|
29
|
+
| `placeholder` | `string` | String placeholder when empty and not focus-within. |
|
|
30
|
+
| `id` | `string` | Optional id for the root; associates the label and field. |
|
|
31
|
+
| `FORCE__className` | `string` | Escape hatch: extra class on the field shell; see `StylingOverrideProps` in source. |
|
|
32
|
+
| `disabled` | `boolean` | Disables the control. |
|
|
33
|
+
| `readOnly` | `boolean` | Read-only mode. |
|
|
34
|
+
| `required` | `boolean` | Marks the field required for forms and assistive technologies. |
|
|
35
|
+
| `isInvalid` | `boolean` | Marks the value invalid; combined with `appearance === 'danger'`. |
|
|
36
|
+
|
|
37
|
+
### Value, format, and change events
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Description |
|
|
40
|
+
| -------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
41
|
+
| `value` | `T \| null` | Controlled value (`T` is a `DateValue` generic, defaulting to the library `DateValue`). |
|
|
42
|
+
| `defaultValue` | `T \| null` | Initial value when uncontrolled. |
|
|
43
|
+
| `onChange` | `(value: MappedDateValue<T> \| null) => void` | Fired when the committed value changes. |
|
|
44
|
+
| `granularity` | `'day' \| 'hour' \| 'minute' \| 'second'` | Smallest unit shown in the field (default follows value type, e.g. day for plain dates). |
|
|
45
|
+
|
|
46
|
+
`MappedDateValue<T>` preserves time and calendar types aligned with `T` (for example `CalendarDate` vs `CalendarDateTime`).
|
|
47
|
+
|
|
48
|
+
Use `isInvalid` and `helperText` for invalid feedback in Capra layouts. Validation behavior is fixed to ARIA-associated messaging for this shell (not configurable).
|
|
49
|
+
|
|
50
|
+
### Props not supported or intentionally fixed
|
|
51
|
+
|
|
52
|
+
| Prop | Notes |
|
|
53
|
+
| ---------------------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
54
|
+
| `children` | Ignored; structure (label, input, calendar) is fixed. |
|
|
55
|
+
| `style` | Not part of the public styling contract; use design tokens and `FORCE__className` if needed. |
|
|
56
|
+
| `validationBehavior` | Not configurable; the implementation always uses ARIA-associated validation for this shell. |
|
|
57
|
+
| `description`, `errorMessage` (slot-style API) | Not part of the public props surface; use `helperText` and validation props instead. |
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Core/DateRangePickerField - Design
|
|
2
|
+
|
|
3
|
+
## Anatomy
|
|
4
|
+
|
|
5
|
+
The date range picker combines two segmented date inputs (start and end) with a range calendar in a popover. Values use
|
|
6
|
+
[`RangeValue`](https://react-spectrum.adobe.com/react-aria/DateRangePicker.html) over types from
|
|
7
|
+
[`@internationalized/date`](https://react-spectrum.adobe.com/internationalized/date/) (for example `CalendarDate`). The
|
|
8
|
+
visible format follows the user’s locale.
|
|
9
|
+
|
|
10
|
+
## Properties
|
|
11
|
+
|
|
12
|
+
### Label
|
|
13
|
+
|
|
14
|
+
Provide a visible `label` so the control has a clear accessible name. If another element acts as the label, wire the
|
|
15
|
+
relationship with `aria-labelledby` or `aria-label` instead.
|
|
16
|
+
|
|
17
|
+
### Value
|
|
18
|
+
|
|
19
|
+
Use `value` with `onChange` for a controlled range, or `defaultValue` for an uncontrolled initial range. The handler
|
|
20
|
+
receives `null` when the field is cleared. Each bound is a `DateValue` consistent with your generic (for example
|
|
21
|
+
both `CalendarDate`).
|
|
22
|
+
|
|
23
|
+
### Placeholder
|
|
24
|
+
|
|
25
|
+
`placeholder` is a pair of strings (`[start, end]`) shown when neither bound is set and the inputs are not
|
|
26
|
+
focus-within, with a swap icon between them. Prefer `helperText` for requirements or instructions that must stay
|
|
27
|
+
visible.
|
|
28
|
+
|
|
29
|
+
### Helper text
|
|
30
|
+
|
|
31
|
+
Helper text sits below the field for requirements, hints, or errors. Pair `appearance="danger"` with error copy so
|
|
32
|
+
the invalid state is clear visually and to assistive technologies.
|
|
33
|
+
|
|
34
|
+
### Layout
|
|
35
|
+
|
|
36
|
+
`layout` can be **vertical** (label above) or **horizontal** (label on the leading side). Prefer vertical; use
|
|
37
|
+
horizontal when horizontal space is tight.
|
|
38
|
+
|
|
39
|
+
## Feedback
|
|
40
|
+
|
|
41
|
+
### Appearance
|
|
42
|
+
|
|
43
|
+
`appearance` supports **default**, **danger** (invalid / error), and **warning**. Danger also drives the invalid
|
|
44
|
+
state for accessibility in addition to any explicit `isInvalid` flag.
|
|
45
|
+
|
|
46
|
+
### Disabled
|
|
47
|
+
|
|
48
|
+
Disabled fields cannot be edited and do not receive focus. Values are not submitted with native form submission.
|
|
49
|
+
|
|
50
|
+
### Read-only
|
|
51
|
+
|
|
52
|
+
Read-only fields cannot be edited; the range stays visible for reading and assistive technologies.
|
|
53
|
+
|
|
54
|
+
## Accessibility
|
|
55
|
+
|
|
56
|
+
### Keyboard and pointer behavior
|
|
57
|
+
|
|
58
|
+
* **Tab** moves focus into the segmented fields or calendar trigger; **Shift+Tab** moves out.
|
|
59
|
+
* Arrow keys adjust focused segments; the range calendar grid follows standard date grid and range selection patterns when
|
|
60
|
+
the popover is open.
|
|
61
|
+
* **Space** / **Enter** on the calendar button opens the popover where supported by the platform pattern.
|
|
62
|
+
|
|
63
|
+
### Labeling and instructions
|
|
64
|
+
|
|
65
|
+
Provide a visible `label` or an accessible name via `aria-label` / `aria-labelledby`. Do not rely on `placeholder` alone
|
|
66
|
+
for the accessible name. Prefer persistent `helperText` for requirements; the string placeholder hides when the user
|
|
67
|
+
focuses or enters either bound.
|
|
68
|
+
|
|
69
|
+
### Validation and state
|
|
70
|
+
|
|
71
|
+
Use `appearance="danger"` with error content in `helperText` for a consistent error treatment. Set `required` when both
|
|
72
|
+
bounds are mandatory. Disabled fields are not interactive and are excluded from native submission; read-only fields keep
|
|
73
|
+
their values visible but are not editable.
|
|
74
|
+
|
|
75
|
+
Ensure focus indicators remain visible (at least 2px, 3:1 contrast) and interactive targets meet at least 24×24 CSS
|
|
76
|
+
pixels where applicable.
|
|
@@ -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' | `--` |
|