@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,110 @@
|
|
|
1
|
+
# Core/Alert - Design
|
|
2
|
+
|
|
3
|
+
Alerts are used to communicate important information to the user.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use an Alert to surface contextual feedback in the page: the outcome of an action (success or failure), a condition that needs attention before the user continues, or information that should stay visible while they keep working in the same view.
|
|
8
|
+
|
|
9
|
+
Keep alerts scoped to the page or region they refer to. Prefer one alert per region so the message stays easy to scan; when several conditions apply at once, combine them into a single alert when it makes sense.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Appearances
|
|
14
|
+
|
|
15
|
+
### Info
|
|
16
|
+
|
|
17
|
+
General information like recommend actions to accelerate a user's workflow, helpful information, or tips.
|
|
18
|
+
|
|
19
|
+
### Error
|
|
20
|
+
|
|
21
|
+
Problems that must be resolved before the user can complete a task, such as an error on a form.
|
|
22
|
+
|
|
23
|
+
### Warning
|
|
24
|
+
|
|
25
|
+
Notify users of cautionary/temporary information affecting the user's workflow, but does not block a user from
|
|
26
|
+
completing the action or workflow.
|
|
27
|
+
|
|
28
|
+
### Success
|
|
29
|
+
|
|
30
|
+
Brings special attention to the user that an action has been completed, or a status has been updated.
|
|
31
|
+
|
|
32
|
+
### Layout
|
|
33
|
+
|
|
34
|
+
### Section
|
|
35
|
+
|
|
36
|
+
Section notifications communicate the status of a section to the user.
|
|
37
|
+
|
|
38
|
+
### Inline
|
|
39
|
+
|
|
40
|
+
Inline notifications are low-priority messages about a single element, like a tile or row item.
|
|
41
|
+
|
|
42
|
+
### Additional properties
|
|
43
|
+
|
|
44
|
+
### Title
|
|
45
|
+
|
|
46
|
+
A title is recommended, but optional. Use a title to quickly summarize the purpose of the notification. Keep titles
|
|
47
|
+
short, no more than 60 characters, and avoid repeating the body text.
|
|
48
|
+
|
|
49
|
+
### Body
|
|
50
|
+
|
|
51
|
+
The body text is required for all notifications. If the notification is actionable, the text should inform the user
|
|
52
|
+
of the next step.
|
|
53
|
+
|
|
54
|
+
### Action
|
|
55
|
+
|
|
56
|
+
Actionable notifications are recommended to help the user resolve the issue.
|
|
57
|
+
|
|
58
|
+
### Dismiss
|
|
59
|
+
|
|
60
|
+
Alert banners can include a dismiss button that removes the notice from the page layout. Error banners can not be
|
|
61
|
+
dismissed.
|
|
62
|
+
|
|
63
|
+
## Layout and spacing
|
|
64
|
+
|
|
65
|
+
* Alerts span the full width of their container.
|
|
66
|
+
|
|
67
|
+
## Behavior
|
|
68
|
+
|
|
69
|
+
* Alerts are static by default; they do not auto-dismiss.
|
|
70
|
+
* If the user triggers an action that resolves the alert condition, remove the alert programmatically.
|
|
71
|
+
* When an alert is injected into the DOM, announce it to screen readers via `aria-live`.
|
|
72
|
+
|
|
73
|
+
## Content
|
|
74
|
+
|
|
75
|
+
* Title: sentence case, no trailing punctuation, max 60 characters.
|
|
76
|
+
* Body: one to two sentences. State the problem and the resolution path. Use punctuation.
|
|
77
|
+
* Action label: verb-first, 1-3 words (e.g., "Retry", "View details").
|
|
78
|
+
* Avoid technical jargon in user-facing alert text.
|
|
79
|
+
|
|
80
|
+
## Best Practices
|
|
81
|
+
|
|
82
|
+
Do:
|
|
83
|
+
|
|
84
|
+
* Do use `appearance="danger"` for blocking error states.
|
|
85
|
+
* Do provide an action when the user has a clear path to resolution.
|
|
86
|
+
|
|
87
|
+
Don't:
|
|
88
|
+
|
|
89
|
+
* Don't use Alert for transient, auto-dismissing notifications — use Toast.
|
|
90
|
+
* Don't use Alert for individual form field validation errors — use the field's error state.
|
|
91
|
+
* Don't use Alert when the message isn't tied to the current page or task context.
|
|
92
|
+
* Don't stack Alerts in the same region.
|
|
93
|
+
* Don't make `appearance="danger"` Alerts dismissable — the component prevents this automatically.
|
|
94
|
+
|
|
95
|
+
## Accessibility
|
|
96
|
+
|
|
97
|
+
* Use `role="alert"` for errors and warnings so they are announced immediately by screen readers.
|
|
98
|
+
* Use `role="status"` for informational and success alerts, which are announced at a lower priority.
|
|
99
|
+
* Don't rely solely on color to convey alert type — the icon and/or title must distinguish the appearance.
|
|
100
|
+
* Ensure the dismiss button has an accessible label (e.g., `aria-label="Dismiss alert"`).
|
|
101
|
+
|
|
102
|
+
### Keyboard interaction
|
|
103
|
+
|
|
104
|
+
* Alerts exist in the page's natural tab sequence, their actions reachable via `tab` and `shift`+`tab` keys.
|
|
105
|
+
|
|
106
|
+
## Related components
|
|
107
|
+
|
|
108
|
+
* [Toast](?path=/docs/core-toast--design) — For non-blocking, auto-dismissing notifications.
|
|
109
|
+
* [Pill](?path=/docs/core-pill--design) — For inline semantic status indicators without body copy.
|
|
110
|
+
* [Modal](?path=/docs/core-modal--design) — When the error or warning requires an immediate blocking decision.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Core/Alert - Usage
|
|
2
|
+
|
|
3
|
+
Alerts are used to communicate important information to the user.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `layout` | `(typeof layouts)[number]` | No | 'section' | The layout of the alert.<br><br>@default 'section'<br><br><ul><br> <li>'section' - The alert is displayed in a full width container.</li><br> <li>'compact' - @deprecated Use 'section' instead. Will be removed in a future version.</li><br> <li>'inline' - Inline notifications are low-priority messages about a single element, like a tile or row item.</li><br></ul> |
|
|
8
|
+
| `appearance` | `(typeof appearances)[number]` | No | 'info' | The appearance of the alert.<br><br>@default 'info'<br><br><ul><br> <li>'info' - Informational alerts provide general information or an important property.</li><br> <li>'warning' - Warning alerts notify users of cautionary information.</li><br> <li>'danger' - Danger alerts indicate problems that must be resolved.</li><br> <li>'success' - Success alerts confirm an action has been completed.</li><br></ul> |
|
|
9
|
+
| `title` | `string` | No | `--` | The title of the alert. This is optional. |
|
|
10
|
+
| `children` | `React.ReactNode` | Yes | `--` | The description of the alert. This is required.<br><br>@required |
|
|
11
|
+
| `action` | `{ label: string; onClick: (e: React.MouseEvent<HTMLButtonElement>) => void; } \| React.ReactElement` | No | `--` | The configuration of the action button. The object must contain a label displayed on the button and an onClick callback function. This is optional.<br><br>When the object is not provided, the alert will not render the action button. |
|
|
12
|
+
| `onDismiss` | `true \| (() => void)` | No | `--` | Optional function to call when the user dismisses the alert.<br><br>If this is not provided, the alert will not render the dismiss button.<br><br>Alerts with `appearance="danger"` cannot be dismissed and will not render the dismiss button.<br><br>**Integration note:** while the `Alert` will handle its own dismissal, this is non-persistent.<br>Persistent dismissal should be handled by the parent component. |
|
|
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,39 @@
|
|
|
1
|
+
# Core/Anchor - Design
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
Anchors are used to navigate users to a different section within the current page.
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
### Label
|
|
10
|
+
|
|
11
|
+
Labels should be concise and descriptive, m Use title case (e.g., "Dashboard", "Settings"). Labels should ideally be
|
|
12
|
+
less than 12 characters, with a maximum of 32 characters.atching the destination heading.
|
|
13
|
+
|
|
14
|
+
## Best Practices
|
|
15
|
+
|
|
16
|
+
Do:
|
|
17
|
+
|
|
18
|
+
* Do match the label to the section heading the anchor points to.
|
|
19
|
+
* Do use the active state for the current page in a navigation region.
|
|
20
|
+
* Do use the disabled state when navigation is temporarily unavailable.
|
|
21
|
+
|
|
22
|
+
Don't:
|
|
23
|
+
|
|
24
|
+
* Don't mark more than one anchor as active in the same navigation context.
|
|
25
|
+
* Don't hide anchors instead of disabling them when a destination exists but is unavailable.
|
|
26
|
+
* Don't use confuse Anchor with Tab.
|
|
27
|
+
|
|
28
|
+
## Accessibility
|
|
29
|
+
|
|
30
|
+
### Keyboard interaction
|
|
31
|
+
|
|
32
|
+
| Key | Function |
|
|
33
|
+
| ------- | --------------------------------------------------------------------- |
|
|
34
|
+
| `Tab` | Moves focus to the anchor when navigating through focusable elements. |
|
|
35
|
+
| `Enter` | Activates the anchor when focused. |
|
|
36
|
+
|
|
37
|
+
### ARIA attributes
|
|
38
|
+
|
|
39
|
+
* `aria-current="page"`: Applied when the anchor is active, indicating the current page in navigation.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Core/Anchor - Usage
|
|
2
|
+
|
|
3
|
+
| Prop | Type | Required | Default | Description |
|
|
4
|
+
| --- | --- | --- | --- | --- |
|
|
5
|
+
| `children` | `React.ReactNode` | Yes | `--` | The label text to display in the anchor. Anchor labels should be one or two words, using title case (Tab Label). Labels should be less than 12 characters, with a maximum of 32 characters. |
|
|
6
|
+
| `href` | `string` | No | `--` | The href attribute of the anchor. |
|
|
7
|
+
| `isActive` | `boolean` | No | `--` | Whether the anchor is active. |
|
|
8
|
+
| `isDisabled` | `boolean` | No | `--` | Whether the anchor is disabled. |
|
|
9
|
+
| `as` | `As` | No | `--` | The underlying element rendered by the anchor. Defaults to `a`. |
|
|
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
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```tsx
|
|
15
|
+
import { Anchor } from '@cribl/capra-core';
|
|
16
|
+
|
|
17
|
+
// Basic usage
|
|
18
|
+
<Anchor href="/dashboard">Dashboard</Anchor>
|
|
19
|
+
|
|
20
|
+
// Active state
|
|
21
|
+
<Anchor href="/settings" isActive>Settings</Anchor>
|
|
22
|
+
|
|
23
|
+
// Disabled state
|
|
24
|
+
<Anchor href="/admin" isDisabled>Admin</Anchor>
|
|
25
|
+
|
|
26
|
+
// Polymorphic - render as button
|
|
27
|
+
<Anchor as="button" onClick={handleClick}>Action</Anchor>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Polymorphic Component
|
|
31
|
+
|
|
32
|
+
The Anchor component supports the `as` prop, allowing it to be rendered as different HTML elements or custom components. This is particularly useful when integrating with routing libraries like React Router.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { Link } from 'react-router-dom';
|
|
36
|
+
|
|
37
|
+
// Using with React Router
|
|
38
|
+
<Anchor as={Link} to="/dashboard">Dashboard</Anchor>
|
|
39
|
+
```
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Core/AutocompleteField - Design
|
|
2
|
+
|
|
3
|
+
AutocompleteField combines a text field with a suggestions list. Consumers can supply static `AutocompleteField.Item` children or an `items` collection with an optional default item renderer. The field allows custom values that are not in the list.
|
|
4
|
+
|
|
5
|
+
## Anatomy
|
|
6
|
+
|
|
7
|
+
1. **Text input** — Entry is through a standard text input. The field keeps focus while the list is open so typing and keyboard
|
|
8
|
+
navigation stay in one place.
|
|
9
|
+
2. **ListBox** — Filtered results appear in a ListBox under the field.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Label
|
|
14
|
+
|
|
15
|
+
A label is required for input fields and succinctly describes the field’s purpose. If another text element is acting
|
|
16
|
+
as the label, like a section title, ensure the proper aria relationships are linked.
|
|
17
|
+
|
|
18
|
+
### Placeholder text
|
|
19
|
+
|
|
20
|
+
<p>
|
|
21
|
+
Placeholder text is visible until a character is entered.
|
|
22
|
+
</p>
|
|
23
|
+
|
|
24
|
+
<p>
|
|
25
|
+
Because the placeholder text disappears, putting instructions or requirements as placeholder text is not
|
|
26
|
+
accessible. Helper text is the preferred method to convey this information.
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
### Helper text
|
|
30
|
+
|
|
31
|
+
Helper text is placed below the field and informs the user of any requirements, disclaimers, and errors. Helper text
|
|
32
|
+
is shown persistently but is replaced by error text when an error occurs.
|
|
33
|
+
|
|
34
|
+
### Layout
|
|
35
|
+
|
|
36
|
+
There are two layouts available for text fields, vertical and horizontal. Vertical labels are the preferred layout,
|
|
37
|
+
appearing above the field. Horizontal labels appear on the leading side of the field, and should only be used when
|
|
38
|
+
space is limited.
|
|
39
|
+
|
|
40
|
+
## Layout and spacing
|
|
41
|
+
|
|
42
|
+
* Input renders identically to [TextField](?path=/docs/core-textfield--design).
|
|
43
|
+
* Suggestions are presented using a ListBox.
|
|
44
|
+
|
|
45
|
+
## Behavior
|
|
46
|
+
|
|
47
|
+
### Autocomplete vs. Select
|
|
48
|
+
|
|
49
|
+
<p>
|
|
50
|
+
**Autocomplete** is an input box with text hints that users can type freely into. Hints are presented and refined
|
|
51
|
+
ina selection list as the user types. Freeform entry is allowed.
|
|
52
|
+
</p>
|
|
53
|
+
|
|
54
|
+
<p>
|
|
55
|
+
**Select**
|
|
56
|
+
|
|
57
|
+
allows selecting options only among a given set of choices.
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
### Filtering
|
|
61
|
+
|
|
62
|
+
As the user types into the text field options are filtered based on the value.
|
|
63
|
+
|
|
64
|
+
## Best Practices
|
|
65
|
+
|
|
66
|
+
Do:
|
|
67
|
+
|
|
68
|
+
* Do show a "no results" message when the filter returns nothing.
|
|
69
|
+
* Do support keyboard-only navigation of suggestions.
|
|
70
|
+
|
|
71
|
+
Don't:
|
|
72
|
+
|
|
73
|
+
* Don't use AutocompleteField for small mutually exclusive sets (about seven or fewer visible options) — use [RadioGroup](?path=/docs/core-radiogroup--design) or Select.
|
|
74
|
+
* Don't use AutocompleteField for plain freeform text with no list validation — use [TextField](?path=/docs/core-textfield--design).
|
|
75
|
+
* Don't require picking from the list while still allowing arbitrary text without explaining that behavior.
|
|
76
|
+
|
|
77
|
+
## Accessibility
|
|
78
|
+
|
|
79
|
+
* `role="combobox"` on the input, `aria-expanded` reflects list open state.
|
|
80
|
+
* `aria-controls` references the suggestion list `id`.
|
|
81
|
+
* `aria-activedescendant` references the currently focused suggestion.
|
|
82
|
+
* Suggestion list: `role="listbox"`, each suggestion: `role="option"`.
|
|
83
|
+
|
|
84
|
+
### Keyboard interaction
|
|
85
|
+
|
|
86
|
+
* Keyboard interactions follow Select and ListBox.
|
|
87
|
+
|
|
88
|
+
## Related components
|
|
89
|
+
|
|
90
|
+
* [TextField](?path=/docs/core-textfield--design) — For freeform text without suggestions.
|
|
91
|
+
* [RadioGroup](?path=/docs/core-radiogroup--design) — For small mutually exclusive option sets.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Core/AutocompleteField - Usage
|
|
2
|
+
|
|
3
|
+
AutocompleteField combines a text field with a suggestions list. Consumers can supply static `AutocompleteField.Item` children or an `items` collection with an optional default item renderer. The field allows custom values that are not in the list.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `canClear` | `boolean` | No | `--` | Whether to show a clear button for the input. |
|
|
8
|
+
| `children` | `React.ReactNode \| (( values: T & { defaultChildren: React.ReactNode \| undefined; }, ) => React.ReactNode)` | No | `--` | The children to render in the dropdown. |
|
|
9
|
+
| `itemFilter` | `(textValue: string, inputValue: string) => boolean` | No | `--` | A function that filters the items based on the input value. |
|
|
10
|
+
| `onChange` | `(value: string) => void` | No | `--` | A callback function that is called when the input value changes. |
|
|
11
|
+
| `onOpenChange` | `(isOpen: boolean) => void` | No | `--` | A callback function that is called when the dropdown is opened or closed. |
|
|
12
|
+
| `items` | `AutocompleteItem[]` | No | `--` | The items to display in the dropdown. |
|
|
13
|
+
| `value` | `AutocompleteItem['value']` | No | `--` | The value of the input. |
|
|
14
|
+
| `shouldAutoSizeDropdown` | `boolean` | No | `--` | Whether to automatically size the dropdown to the width of the input. Defaults to `true` |
|
|
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. |
|
|
16
|
+
| `helperText` | `string` | No | `--` | Helper text below the field. Replaced by error message when status is error. Use for requirements, disclaimers. |
|
|
17
|
+
| `label` | `string` | No | `--` | Label for the field. Required for accessibility; use aria-label if another element acts as label. |
|
|
18
|
+
| `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. |
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Core/Badge - Design
|
|
2
|
+
|
|
3
|
+
Badges display an indicator/counter on an associated component.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Label
|
|
8
|
+
|
|
9
|
+
A label is required to indicate the number of notifications.
|
|
10
|
+
|
|
11
|
+
### Size
|
|
12
|
+
|
|
13
|
+
Badges come in 3 sizes to support ones, tens, and values above 100.
|
|
14
|
+
|
|
15
|
+
### Dot
|
|
16
|
+
|
|
17
|
+
Use a dot to show notifications without a count.
|
|
18
|
+
|
|
19
|
+
### Appearance
|
|
20
|
+
|
|
21
|
+
Badges can be colored based on their status. The `attention` appearance is the general purpose color used for numbered badges and does not necessarily communicate severity.
|
|
22
|
+
|
|
23
|
+
Using color as the only means to communicate status should be avoided (WCAG SC 1.4.1: Use of Color, Level A). Badges that communicate status must be accompanied by supplementary information that clearly communicates the status.
|
|
24
|
+
|
|
25
|
+
## Behavior
|
|
26
|
+
|
|
27
|
+
### Corner attachment
|
|
28
|
+
|
|
29
|
+
Badges are placed in the top-right of the parent component to avoid obscuring the parent content.
|
|
30
|
+
|
|
31
|
+
### Inline
|
|
32
|
+
|
|
33
|
+
When used with text labels, badges are placed on the trailing side and vertically aligned to the text's line height.
|
|
34
|
+
|
|
35
|
+
## Content
|
|
36
|
+
|
|
37
|
+
### Maximum
|
|
38
|
+
|
|
39
|
+
The maximum number shown in 99. When there are more than 99 notifications a "+" is appended to the label.
|
|
40
|
+
|
|
41
|
+
## Best Practices
|
|
42
|
+
|
|
43
|
+
Do:
|
|
44
|
+
|
|
45
|
+
* Do cap displayed values at 99 with a "99+" label.
|
|
46
|
+
* Do use the dot variant for simple presence indicators.
|
|
47
|
+
* Do include count context in the parent's accessible label.
|
|
48
|
+
|
|
49
|
+
Don't:
|
|
50
|
+
|
|
51
|
+
* Don't use Badge for semantic status text — use Pill.
|
|
52
|
+
* Don't use Badge for labels or tags — use Tag.
|
|
53
|
+
* Don't place Badge on non-interactive decorative elements.
|
|
54
|
+
* Don't use Badge colors as the only method to communicate status.
|
|
55
|
+
|
|
56
|
+
## Accessibility
|
|
57
|
+
|
|
58
|
+
* The badge is a nested static element; it is announced as part of its parent.
|
|
59
|
+
* The parent element's accessible label should include the count context (e.g., "Notifications, 5 unread").
|
|
60
|
+
* Use `aria-live="polite"` on the parent for dynamic badge updates.
|
|
61
|
+
|
|
62
|
+
## Content
|
|
63
|
+
|
|
64
|
+
* Numeric only.
|
|
65
|
+
* Max displayed value: 99; use "99+" for larger counts.
|
|
66
|
+
|
|
67
|
+
## Related components
|
|
68
|
+
|
|
69
|
+
* [Pill](?path=/docs/core-pill--design) — For semantic status labels.
|
|
70
|
+
* [Tag](?path=/docs/core-tag--design) — For removable text chips.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Core/Badge - Usage
|
|
2
|
+
|
|
3
|
+
Badges display an indicator/counter on an associated component.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `variant` | `'counter' \| 'dot'` | No | `--` | The variant of the badge. 'counter' displays a count, 'dot' displays only a dot.<br>@default 'counter' |
|
|
8
|
+
| `appearance` | `'danger' \| 'info' \| 'success' \| 'warning'` | No | 'danger' | Controls the Badge color.<br>@default 'danger' |
|
|
9
|
+
| `count` | `number` | No | 0 | The number to display in the badge. Default is 0. |
|
|
10
|
+
| `showZero` | `boolean` | No | false | Whether to display the badge when the count is zero. Default is false. |
|
|
11
|
+
| `overflowCount` | `number` | No | 99 | The number to display in the badge when the count is greater than the overflow count. Default is 99. |
|
|
12
|
+
| `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. |
|
|
13
|
+
| `aria-live` | `React.AriaAttributes['aria-live']` | No | `--` | `--` |
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Core/Breadcrumbs - Design
|
|
2
|
+
|
|
3
|
+
Renders a breadcrumb trail with built-in support for collection behavior, keyboard support, and current-page semantics. Wrap items with {@link Breadcrumb}. The last item should represent the current page (typically without an `href`).
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use Breadcrumbs on views that sit deeper than the home or root level so people see where they are in the hierarchy and can jump to ancestors.
|
|
8
|
+
|
|
9
|
+
Place them above the page title, keep labels aligned with each destination's title, and render every segment except the current page as a link.
|
|
10
|
+
|
|
11
|
+
## Layout and spacing
|
|
12
|
+
|
|
13
|
+
* Place above the page heading.
|
|
14
|
+
|
|
15
|
+
## Behavior
|
|
16
|
+
|
|
17
|
+
* Current page item is not a link (no click interaction).
|
|
18
|
+
|
|
19
|
+
## Content
|
|
20
|
+
|
|
21
|
+
* Use the same label as the page heading for each item.
|
|
22
|
+
* Title case.
|
|
23
|
+
* Keep each label concise (1-3 words).
|
|
24
|
+
|
|
25
|
+
## Best Practices
|
|
26
|
+
|
|
27
|
+
Do:
|
|
28
|
+
|
|
29
|
+
* Do make all items except the last one clickable links.
|
|
30
|
+
* Do mark the current page with `aria-current="page"`.
|
|
31
|
+
|
|
32
|
+
Don't:
|
|
33
|
+
|
|
34
|
+
* Don't show breadcrumbs on top-level pages — there is no trail to show.
|
|
35
|
+
* Don't use breadcrumbs when the IA is flat and would produce a single segment.
|
|
36
|
+
* Don't use custom separator text that is read by screen readers.
|
|
37
|
+
|
|
38
|
+
## Accessibility
|
|
39
|
+
|
|
40
|
+
* Wrap in a `<nav aria-label="breadcrumb">` element.
|
|
41
|
+
* Current page item uses `aria-current="page"`.
|
|
42
|
+
* Separator characters are `aria-hidden="true"`.
|
|
43
|
+
|
|
44
|
+
### Keyboard interaction
|
|
45
|
+
|
|
46
|
+
| Key | Function |
|
|
47
|
+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
48
|
+
| `Tab` | Move focus forward along the breadcrumb trail. |
|
|
49
|
+
| `Shift + Tab` | Move focus back along the breadcrumb trail. |
|
|
50
|
+
| `Enter` | Activates the currently focused link. If a dropdown crumb has focus, opens the menu and gives focus to the currently selected option. If a menu item has focus, activates the item and closes the menu. |
|
|
51
|
+
| `Space` | If a dropdown crumb has focus, opens the menu and gives focus to the currently selected option. |
|
|
52
|
+
| `Down Arrow` | If a dropdown crumb has focus, opens the menu and gives focus to the currently selected option. If a menu item has focus, moves focus to the next item. |
|
|
53
|
+
| `Up Arrow` | If a menu item has focus, moves focus to the previous item. |
|
|
54
|
+
| `Esc` | If a dropdown crumb is open, closes the menu and returns focus to the trigger. |
|
|
55
|
+
|
|
56
|
+
* If a dropdown crumb is open: the `tab` and `shift`+`tab` keys do not navigate.
|
|
57
|
+
|
|
58
|
+
### Labeling
|
|
59
|
+
|
|
60
|
+
* Breadcrumbs represent a hierarchy and need to announce themselves accordingly. Using `aria-label`, a crumb should identify itself and its parents.
|
|
61
|
+
* Use `aria-current=”page”` to indicate the last page in the breadcrumb order.
|
|
62
|
+
|
|
63
|
+
## Related components
|
|
64
|
+
|
|
65
|
+
* [TabNav](?path=/docs/core-tabnav--design) — For in-page section navigation.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Core/Breadcrumbs - Usage
|
|
2
|
+
|
|
3
|
+
Renders a breadcrumb trail with built-in support for collection behavior, keyboard support, and current-page semantics. Wrap items with {@link Breadcrumb}. The last item should represent the current page (typically without an `href`).
|
|
4
|
+
|
|
5
|
+
:::warning[Partially implemented]
|
|
6
|
+
|
|
7
|
+
The `Breadcrumbs` component is partially implemented and does not yet support dropdowns as items.
|
|
8
|
+
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Required | Default | Description |
|
|
12
|
+
| --- | --- | --- | --- | --- |
|
|
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. |
|
|
14
|
+
| `aria-label` | `string` | No | 'Breadcrumb' | Accessible name for the breadcrumb navigation landmark.<br>Defaults to `"Breadcrumb"`. |
|
|
15
|
+
| `size` | `string` | No | 'md' | `--` |
|
|
16
|
+
| `shouldEmpasizeCurrent` | `boolean` | No | true | `--` |
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Core/Button - Design
|
|
2
|
+
|
|
3
|
+
Primary interactive element displaying text and supporting leading and trailing icons.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use a Button when someone needs to submit a form, confirm an action, or move a workflow forward, and the action warrants a dedicated, labeled control.
|
|
8
|
+
|
|
9
|
+
Use at most one primary (`variant="primary"`) button per view or modal for the main outcome. Pair it with a secondary (`variant="secondary"`) button for cancel or alternate paths. Use `appearance="danger"` with primary or secondary for destructive or irreversible actions.
|
|
10
|
+
|
|
11
|
+
## Properties
|
|
12
|
+
|
|
13
|
+
### Variant
|
|
14
|
+
|
|
15
|
+
| Variant | Usage |
|
|
16
|
+
| ----------- | --------------------------------------------------------------------- |
|
|
17
|
+
| `primary` | Highest visual weight. Use once per view for the main action. |
|
|
18
|
+
| `secondary` | Pairs with a primary button for cancel or alternative paths. |
|
|
19
|
+
| `tertiary` | Lowest visual weight. Use for supplementary or de-emphasized actions. |
|
|
20
|
+
|
|
21
|
+
### Label
|
|
22
|
+
|
|
23
|
+
Labels should use a verb + noun structure to describe what the button will do when pressed.
|
|
24
|
+
|
|
25
|
+
### Icon
|
|
26
|
+
|
|
27
|
+
Buttons have two icon slots; a leading and a trailing icon. Use the leading icons to visually reinforce their meaning and draw attention.
|
|
28
|
+
|
|
29
|
+
Trailing icons are used for disclosure and additional behavior indications.
|
|
30
|
+
|
|
31
|
+
### Size
|
|
32
|
+
|
|
33
|
+
Buttons come is three different sizes. Medium is the default and preferred size for most situations.
|
|
34
|
+
|
|
35
|
+
Small size is used when a button is inline with another element, such as a table or popover.
|
|
36
|
+
|
|
37
|
+
### Appearance
|
|
38
|
+
|
|
39
|
+
| Appearance | Default | Usage |
|
|
40
|
+
| ---------- | ------- | ----------------------------------------------------------- |
|
|
41
|
+
| `default` | ✓ | Standard interactive actions. |
|
|
42
|
+
| `neutral` | | Lower-prominence secondary actions within a filled surface. |
|
|
43
|
+
| `danger` | | Destructive or irreversible actions (delete, revoke). |
|
|
44
|
+
|
|
45
|
+
### Size
|
|
46
|
+
|
|
47
|
+
| Size | Default | Usage |
|
|
48
|
+
| ---- | ------- | --------------------------------------------------- |
|
|
49
|
+
| `sm` | | Compact toolbars, table row actions, dense layouts. |
|
|
50
|
+
| `md` | ✓ | Standard form actions, modal footers. |
|
|
51
|
+
| `lg` | | Call-to-action in empty states, hero sections. |
|
|
52
|
+
| `xl` | | Marketing or onboarding hero sections. |
|
|
53
|
+
|
|
54
|
+
## Content
|
|
55
|
+
|
|
56
|
+
* Use verb-first labels: "Save changes", "Add item", "Delete record".
|
|
57
|
+
* Title case for all button labels.
|
|
58
|
+
* Keep labels to 1-3 words when possible. Never exceed 5 words.
|
|
59
|
+
* Use "Add" not "New" (e.g., "Add source", not "New source").
|
|
60
|
+
* Avoid vague labels like "OK" or "Submit" — be specific about the action.
|
|
61
|
+
|
|
62
|
+
## Behavior
|
|
63
|
+
|
|
64
|
+
* Activated with mouse click, Enter key, or Space key.
|
|
65
|
+
* Pending state (`pending` prop): replaces the leading icon or prepends a spinner while an async action is in progress; preserve button width to avoid layout shift.
|
|
66
|
+
* Disabled state: buttons with `disabled` prop are non-interactive and non-focusable; use `aria-disabled` if the button should remain focusable (e.g., with a tooltip explaining why it's disabled).
|
|
67
|
+
|
|
68
|
+
## Best Practices
|
|
69
|
+
|
|
70
|
+
Do:
|
|
71
|
+
|
|
72
|
+
* Do use a single `variant="primary"` button per view.
|
|
73
|
+
* Do pair primary with secondary for confirm/cancel patterns.
|
|
74
|
+
* Do use `appearance="danger"` for destructive actions.
|
|
75
|
+
* Do use verb-first, title-case labels.
|
|
76
|
+
|
|
77
|
+
Don't:
|
|
78
|
+
|
|
79
|
+
* Don't use a Button for navigation to another page — use [Link](?path=/docs/core-link--design) or [Anchor](?path=/docs/core-anchor--design).
|
|
80
|
+
* Don't use a Button for text-only inline navigation — use [Link](?path=/docs/core-link--design).
|
|
81
|
+
* Don't use a Button for icon-only actions — use [IconButton](?path=/docs/core-iconbutton--design).
|
|
82
|
+
* Don't use two primary buttons side by side.
|
|
83
|
+
* Don't truncate button labels.
|
|
84
|
+
* Don't disable a button without explaining why (use `aria-disabled` with a tooltip).
|
|
85
|
+
|
|
86
|
+
## Accessibility
|
|
87
|
+
|
|
88
|
+
* Always provide a visible text label; if the design requires a short label, add `aria-label` for context.
|
|
89
|
+
* For icon-only use cases, use [IconButton](?path=/docs/core-iconbutton--design) instead (which enforces an accessible label).
|
|
90
|
+
* Tab / Shift+Tab to focus. Enter or Space to activate.
|
|
91
|
+
* The pending state must be communicated to assistive technology (e.g., `aria-label="Saving..."` when `pending` is true).
|
|
92
|
+
|
|
93
|
+
## Related components
|
|
94
|
+
|
|
95
|
+
* [IconButton](?path=/docs/core-iconbutton--design) — For icon-only actions.
|
|
96
|
+
* [Link](?path=/docs/core-link--design) — For inline text navigation.
|
|
97
|
+
* [Modal](?path=/docs/core-modal--design) — Buttons typically appear in modal footers for confirm/cancel patterns.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Core/Button - Usage
|
|
2
|
+
|
|
3
|
+
Primary interactive element displaying text and supporting leading and trailing icons.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `children` | `string` | Yes | `--` | The `label` for the button. |
|
|
8
|
+
| `variant` | `(typeof variants)[number]` | No | 'secondary' | Which button style to use. Defaults to `secondary`. |
|
|
9
|
+
| `appearance` | `(typeof appearances)[number]` | No | 'default' | Appearance to apply to the button. Defaults to `default`. |
|
|
10
|
+
| `size` | `(typeof sizes)[number]` | No | 'md' | Size of the button. Defaults to `md`. |
|
|
11
|
+
| `disabled` | `boolean` | No | false | Whether the button is disabled. |
|
|
12
|
+
| `pending` | `boolean` | No | false | Whether the button is in a pending state. |
|
|
13
|
+
| `leadingIcon` | `SvgIcon` | No | `--` | Icon to display before the button text. |
|
|
14
|
+
| `trailingIcon` | `SvgIcon` | No | `--` | Icon to display after the button text. |
|
|
15
|
+
| `block` | `boolean` | No | `--` | Whether to display the button as a block-level (full-width) component. Defaults to `false`. |
|
|
16
|
+
| `onClick` | `React.ComponentProps<'button'>['onClick']` | No | `--` | Click handler for the button. |
|
|
17
|
+
| `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,7 @@
|
|
|
1
|
+
# Core/ButtonLink - Design
|
|
2
|
+
|
|
3
|
+
Primary interactive element displaying text and supporting leading and trailing icons.
|
|
4
|
+
|
|
5
|
+
`ButtonLink` follows the design guidelines for [`Button`](?path=/docs/core-button--design) and uses [`Link`](?path=/docs/core-link--design) interally. Use it when you need a link styled as a button.
|
|
6
|
+
|
|
7
|
+
See those pages for more details on the properties and usage of `ButtonLink`.
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Core/ButtonLink - Usage
|
|
2
|
+
|
|
3
|
+
Primary interactive element displaying text and supporting leading and trailing icons.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `children` | `string` | Yes | `--` | The `label` for the link. |
|
|
8
|
+
| `variant` | `(typeof variants)[number]` | No | 'secondary' | Which visual style to use. Defaults to `secondary`. |
|
|
9
|
+
| `appearance` | `(typeof appearances)[number]` | No | 'default' | Appearance to apply to the link. Defaults to `default`. |
|
|
10
|
+
| `size` | `(typeof sizes)[number]` | No | 'md' | Size of the link. Defaults to `md`. |
|
|
11
|
+
| `disabled` | `boolean` | No | false | Whether the link is disabled. |
|
|
12
|
+
| `pending` | `boolean` | No | false | Whether the link is in a pending state. |
|
|
13
|
+
| `leadingIcon` | `SvgIcon` | No | `--` | Icon to display before the link text. |
|
|
14
|
+
| `trailingIcon` | `SvgIcon` | No | `--` | Icon to display after the link text. |
|
|
15
|
+
| `block` | `boolean` | No | `--` | Whether to display the link as a block-level (full-width) component. Defaults to `false`. |
|
|
16
|
+
| `as` | `As` | No | `--` | The underlying element rendered by the component. Defaults to `a`. |
|
|
17
|
+
| `href` | `unknown` | No | `--` | A URL to link to. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#href). |
|
|
18
|
+
| `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). |
|
|
19
|
+
| `target` | `HTMLAttributeAnchorTarget` | No | `--` | The target window for the link. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#target). |
|
|
20
|
+
| `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). |
|
|
21
|
+
| `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). |
|
|
22
|
+
| `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). |
|
|
23
|
+
| `routerOptions` | `unknown` | No | `--` | Options for the configured client side router. |
|
|
24
|
+
| `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. |
|