@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,74 @@
|
|
|
1
|
+
# Core/TextArea - Design
|
|
2
|
+
|
|
3
|
+
TextArea component for multi-line text entry.
|
|
4
|
+
|
|
5
|
+
### Anatomy
|
|
6
|
+
|
|
7
|
+
The text area is a multi-line field. When `resizable` is true, a resize handle allows vertical resizing. Use with
|
|
8
|
+
`InputField` for labels, helper text, and validation messaging.
|
|
9
|
+
|
|
10
|
+
## Properties
|
|
11
|
+
|
|
12
|
+
### Value
|
|
13
|
+
|
|
14
|
+
The value is submitted with the form. The value replaces any placeholder text in the field after the first character
|
|
15
|
+
is entered.
|
|
16
|
+
|
|
17
|
+
### Placeholder text
|
|
18
|
+
|
|
19
|
+
Placeholder text is visible until a character is entered. Because the placeholder text disappears, putting
|
|
20
|
+
instructions or requirements as placeholder text is not accessible. Helper text is the preferred method to convey
|
|
21
|
+
this information.
|
|
22
|
+
|
|
23
|
+
### Resizable
|
|
24
|
+
|
|
25
|
+
When `resizable` is `true` (default) and `autoSize` is off, a resize handle is shown and the user can drag to change
|
|
26
|
+
height vertically. When `autoSize` is on, manual resizing is disabled. When `resizable` is `false`, the height is
|
|
27
|
+
fixed.
|
|
28
|
+
|
|
29
|
+
### Auto size
|
|
30
|
+
|
|
31
|
+
`autoSize` grows the height with content (Ant Design–style API). Pass `true` or `{ minRows?, maxRows? }`. When auto
|
|
32
|
+
size is on, manual resize is disabled. Height follows content; optional `maxRows` caps growth and enables vertical
|
|
33
|
+
scrolling for overflow.
|
|
34
|
+
|
|
35
|
+
### Status
|
|
36
|
+
|
|
37
|
+
`danger`: Used to indicate an error or invalid state.
|
|
38
|
+
|
|
39
|
+
`warning`: Used to indicate a warning.
|
|
40
|
+
|
|
41
|
+
Styling matches TextInput for consistent forms.
|
|
42
|
+
|
|
43
|
+
## Behavior
|
|
44
|
+
|
|
45
|
+
### Error messages
|
|
46
|
+
|
|
47
|
+
When validation fails, the field border uses the attention styling and helper text shows an error message. Error
|
|
48
|
+
messages should be concise and replace any previously visible helper text where appropriate.
|
|
49
|
+
|
|
50
|
+
### Disabled
|
|
51
|
+
|
|
52
|
+
Disabled fields cannot be modified and cannot receive focus. Values in a disabled field are not submitted as part of
|
|
53
|
+
the form.
|
|
54
|
+
|
|
55
|
+
### Read-only
|
|
56
|
+
|
|
57
|
+
Read-only fields cannot be modified. The value of a read-only field is submitted as part of the form.
|
|
58
|
+
|
|
59
|
+
## Accessibility
|
|
60
|
+
|
|
61
|
+
### Keyboard interaction
|
|
62
|
+
|
|
63
|
+
| Key | Function |
|
|
64
|
+
| ------------------- | -------------------------------------- |
|
|
65
|
+
| `Tab` / `Shift+Tab` | Moves focus into/out of the text area. |
|
|
66
|
+
| `Arrow keys` | Move the caret within the text. |
|
|
67
|
+
| `Enter` | Inserts a new line. |
|
|
68
|
+
|
|
69
|
+
### Labeling and validation
|
|
70
|
+
|
|
71
|
+
The component renders a semantic `textarea` element. Provide an accessible name with `aria-label` or
|
|
72
|
+
`aria-labelledby`, and associate helper or error text with `aria-describedby` when used inside `InputField` or your own
|
|
73
|
+
layout. The component sets `aria-invalid` when `appearance` is `danger`. Ensure focus indicators are visible (at least
|
|
74
|
+
2px, 3:1 contrast) and interactive targets meet at least 24×24 CSS pixels where applicable.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Core/TextArea - Usage
|
|
2
|
+
|
|
3
|
+
TextArea component for multi-line text entry.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `appearance` | `(typeof appearances)[number]` | No | `--` | Appearance of the text area.<br>@default 'default' |
|
|
8
|
+
| `resizable` | `boolean` | No | `--` | Whether the text area can be vertically resized by the user.<br>@default true |
|
|
9
|
+
| `autoSize` | `boolean \| { minRows?: number; maxRows?: number }` | No | `--` | Auto-growing height (Ant Design `Input.TextArea`–style).<br>`true` grows with content; use `{ minRows, maxRows }` to clamp height.<br>When enabled, manual vertical resize is disabled (`resize: none`). |
|
|
10
|
+
| `showCount` | `boolean` | No | `--` | When true, shows a character count. |
|
|
11
|
+
| `onChange` | `(value: string) => void` | No | `--` | Called with the new string value when the input changes. |
|
|
12
|
+
| `helperText` | `string` | No | `--` | Helper text below the field. Replaced by error message when status is error. Use for requirements, disclaimers. |
|
|
13
|
+
| `label` | `string` | No | `--` | Label for the field. Required for accessibility; use aria-label if another element acts as label. |
|
|
14
|
+
| `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. |
|
|
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
|
+
|
|
17
|
+
Use `InputField` with `input={TextArea}` for label above the field, helper text, character count, and validation
|
|
18
|
+
appearance. Use `layout="vertical"` (default) or `layout="horizontal"` on `InputField` to match TextInput layouts.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Core/TextField - Design
|
|
2
|
+
|
|
3
|
+
Single-line text field with optional label and helper text.
|
|
4
|
+
|
|
5
|
+
The following guidelines are common across text-based inputs ([Core Components — Inputs](https://www.figma.com/design/ejoPUMrdRDAlyc2vyDIWWe/Core-Components?node-id=21133-20423) in Figma).
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
### Label
|
|
10
|
+
|
|
11
|
+
A label is required for input fields and succinctly describes the field’s purpose. If another text element is acting
|
|
12
|
+
as the label—like a section title—ensure the proper ARIA relationships are linked.
|
|
13
|
+
|
|
14
|
+
### Value
|
|
15
|
+
|
|
16
|
+
The value is submitted with the form. The value replaces any placeholder text in the field after the first character
|
|
17
|
+
is entered.
|
|
18
|
+
|
|
19
|
+
### Placeholder text
|
|
20
|
+
|
|
21
|
+
Placeholder text is visible until a character is entered. Because the placeholder text disappears, putting
|
|
22
|
+
instructions or requirements as placeholder text is not accessible. Helper text is the preferred method to convey
|
|
23
|
+
this information.
|
|
24
|
+
|
|
25
|
+
### Helper text
|
|
26
|
+
|
|
27
|
+
Helper text is placed below the field and informs the user of any requirements, disclaimers, and errors. Helper text
|
|
28
|
+
is shown persistently but is replaced by error text when an error occurs.
|
|
29
|
+
|
|
30
|
+
### Layout
|
|
31
|
+
|
|
32
|
+
There are two layouts available for text fields: **vertical** and **horizontal**. With vertical labels, the content
|
|
33
|
+
will shift to keep the cursor in view as the user enters characters. When the field loses focus, the content will
|
|
34
|
+
scroll to the beginning. Focusing on the field again returns the user to the end of the content. Horizontal labels
|
|
35
|
+
appear on the leading side of the field, and should only be used when space is limited.
|
|
36
|
+
|
|
37
|
+
## Behavior
|
|
38
|
+
|
|
39
|
+
### Overflow
|
|
40
|
+
|
|
41
|
+
Values overflow past the trailing edge of the field. While focused, the content will shift to keep the cursor in
|
|
42
|
+
view as the user enters characters. When the field loses focus, the content will scroll to the beginning. Focusing
|
|
43
|
+
on the field again returns the user to the end of the content. Generally, text fields should avoid overflow. Use a
|
|
44
|
+
text area field for longer entries.
|
|
45
|
+
|
|
46
|
+
## Content
|
|
47
|
+
|
|
48
|
+
### Search and filter fields
|
|
49
|
+
|
|
50
|
+
Search and Filter fields allow a user to enter and clear query strings.
|
|
51
|
+
|
|
52
|
+
**Clear button:** The clear icon appears when a value is present in the text field. When cleared the icon disappears and
|
|
53
|
+
the text input keeps focus.
|
|
54
|
+
|
|
55
|
+
## Feedback
|
|
56
|
+
|
|
57
|
+
### Error messages
|
|
58
|
+
|
|
59
|
+
When a field fails validation, the field’s border displays the attention color. The helper text also displays an
|
|
60
|
+
error message to help the user successfully fulfill the field requirements. Error messages are concise and direct,
|
|
61
|
+
and replace any previously visible helper text. An error icon is prepended to the helper text to enhance
|
|
62
|
+
discoverability.
|
|
63
|
+
|
|
64
|
+
### Disabled
|
|
65
|
+
|
|
66
|
+
Disabled fields cannot be modified and cannot gain focus. Values in a disabled field are not submitted as part of
|
|
67
|
+
the form.
|
|
68
|
+
|
|
69
|
+
### Read-only
|
|
70
|
+
|
|
71
|
+
Read-only fields cannot be modified and cannot gain focus. The value of a read-only field is submitted as part of
|
|
72
|
+
the form.
|
|
73
|
+
|
|
74
|
+
## Accessibility
|
|
75
|
+
|
|
76
|
+
* **Label:** Provide a visible `label` or associate another element via `aria-labelledby` / `aria-label` so the control has an accessible name. Do not rely on placeholder alone for the name.
|
|
77
|
+
* **Instructions and requirements:** Prefer persistent `helperText` (or other visible, associated text) over placeholder for instructions; placeholder disappears and is easy to miss.
|
|
78
|
+
* **Errors:** Use `appearance="danger"` with error content in `helperText` so validation state is exposed (`aria-invalid`) and messaging replaces prior helper text.
|
|
79
|
+
* **Required:** Set `required` when the field is mandatory so required state is available to assistive technologies.
|
|
80
|
+
* **Disabled:** Disabled fields are not interactive; their values are not submitted with native form submission.
|
|
81
|
+
* **Read-only:** Read-only values are still submitted; the field is not editable. Native read-only inputs may remain focusable for selection and screen readers—align with your product pattern if focus should be limited.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Core/TextField - Usage
|
|
2
|
+
|
|
3
|
+
Single-line text field with optional label and helper text.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `onChange` | `(value: string) => void` | No | `--` | Called with the new string value when the input changes. |
|
|
8
|
+
| `showCount` | `boolean` | No | `--` | When true, shows a character count. |
|
|
9
|
+
| `value` | `string \| number \| undefined` | No | `--` | `--` |
|
|
10
|
+
| `helperText` | `string` | No | `--` | Helper text below the field. Replaced by error message when status is error. Use for requirements, disclaimers. |
|
|
11
|
+
| `label` | `string` | No | `--` | Label for the field. Required for accessibility; use aria-label if another element acts as label. |
|
|
12
|
+
| `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,72 @@
|
|
|
1
|
+
# Core/TextInput - Design
|
|
2
|
+
|
|
3
|
+
TextInput component for single-line text entry. Backwards compatible with Ant Design v5 Input.
|
|
4
|
+
|
|
5
|
+
## Anatomy
|
|
6
|
+
|
|
7
|
+
## Properties
|
|
8
|
+
|
|
9
|
+
### Value
|
|
10
|
+
|
|
11
|
+
The value is submitted with the form. The value replaces any placeholder text in the field after the first character
|
|
12
|
+
is entered.
|
|
13
|
+
|
|
14
|
+
### Placeholder text
|
|
15
|
+
|
|
16
|
+
Placeholder text is visible until a character is entered. Because the placeholder text disappears, putting
|
|
17
|
+
instructions or requirements as placeholder text is not accessible. Helper text is the preferred method to convey
|
|
18
|
+
this information.
|
|
19
|
+
|
|
20
|
+
### Size
|
|
21
|
+
|
|
22
|
+
<p>
|
|
23
|
+
`md`
|
|
24
|
+
|
|
25
|
+
: Standard size used across the majority of the UI.
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p>
|
|
29
|
+
`sm`
|
|
30
|
+
|
|
31
|
+
: Used when an input is in a supporting position, such as directly above a table for filtering.
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
### Status
|
|
35
|
+
|
|
36
|
+
`error`: Used to indicate that the input has an error.
|
|
37
|
+
|
|
38
|
+
`warning`: Used to indicate that the input has a warning.
|
|
39
|
+
|
|
40
|
+
## Behavior
|
|
41
|
+
|
|
42
|
+
### Overflow
|
|
43
|
+
|
|
44
|
+
Input values overflow past the trailing edge of the input container. While focused, the content will shift to keep
|
|
45
|
+
the cursor in view as the user enters characters. When the field loses focus, the content will scroll to the
|
|
46
|
+
beginning. Focusing on the field again returns the user to the end of the content. Generally, text fields should
|
|
47
|
+
avoid overflow. Use a Text area field for longer entries.
|
|
48
|
+
|
|
49
|
+
### Error messages
|
|
50
|
+
|
|
51
|
+
When a field fails validation, the input's border displays the attention color. The helper text also displays
|
|
52
|
+
an error message to help the user successfully fulfill the input requirements. Error messages are concise and
|
|
53
|
+
direct, and replace any previously visible helper text. An error icon is prepended to the helper text to enhance
|
|
54
|
+
discoverability.
|
|
55
|
+
|
|
56
|
+
### Disabled
|
|
57
|
+
|
|
58
|
+
Disabled fields can not be modified and can not gain focus. Values in a disabled field are not submitted as part of
|
|
59
|
+
the form.
|
|
60
|
+
|
|
61
|
+
### Read-only
|
|
62
|
+
|
|
63
|
+
Read-only fields can not be modified. The value of a read-only field is submitted as part of the form.
|
|
64
|
+
|
|
65
|
+
## Accessibility
|
|
66
|
+
|
|
67
|
+
### Keyboard interaction
|
|
68
|
+
|
|
69
|
+
| Key | Function |
|
|
70
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `Tab` / `Shift+Tab` | Moves focus into/out of the input field.<br />For inputs with embedded actions, move to the next/previous action |
|
|
72
|
+
| `Enter` / `Space` | For inputs with embedded actions, activates the currently focused action. |
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Core/TextInput - Usage
|
|
2
|
+
|
|
3
|
+
TextInput component for single-line text entry. Backwards compatible with Ant Design v5 Input.
|
|
4
|
+
|
|
5
|
+
:::warning[Internal only]
|
|
6
|
+
|
|
7
|
+
`TextInput` is not exported from the public `@capra/core` API. For single-line text entry in product code, use [`TextField`](?path=/docs/core-textfield--design).
|
|
8
|
+
|
|
9
|
+
:::
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Required | Default | Description |
|
|
12
|
+
| --- | --- | --- | --- | --- |
|
|
13
|
+
| `appearance` | `(typeof appearances)[number]` | No | `--` | Appearance of the input.<br>@default 'default' |
|
|
14
|
+
| `leadingSlot` | `React.ReactNode` | No | `--` | Content before the input (e.g. icon). |
|
|
15
|
+
| `size` | `(typeof sizes)[number]` | No | `--` | Size of the input.<br>@default 'md' |
|
|
16
|
+
| `trailingSlot` | `React.ReactNode` | No | `--` | Content after the input (e.g. icon or clear 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. |
|
|
18
|
+
|
|
19
|
+
Use `layout="vertical"` (default) for label above the field; use `layout="horizontal"` for label on the leading side when space is limited.
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# Core/Toast - Design
|
|
2
|
+
|
|
3
|
+
Renders a toast inline for documentation/preview. Not for use in production.
|
|
4
|
+
|
|
5
|
+
## Anatomy
|
|
6
|
+
|
|
7
|
+
### Status icon
|
|
8
|
+
|
|
9
|
+
<span>
|
|
10
|
+
Indicates the type of message (info, success, warning, error)
|
|
11
|
+
</span>
|
|
12
|
+
|
|
13
|
+
### Body
|
|
14
|
+
|
|
15
|
+
<span>
|
|
16
|
+
The message text informing the user what occurred
|
|
17
|
+
</span>
|
|
18
|
+
|
|
19
|
+
### Dismiss
|
|
20
|
+
|
|
21
|
+
<span>
|
|
22
|
+
Close button to manually dismiss the toast
|
|
23
|
+
</span>
|
|
24
|
+
|
|
25
|
+
### Actions
|
|
26
|
+
|
|
27
|
+
<span>
|
|
28
|
+
Optional action button relating to the notification (e.g. "Try again", "Undo")
|
|
29
|
+
</span>
|
|
30
|
+
|
|
31
|
+
## Properties
|
|
32
|
+
|
|
33
|
+
### Type
|
|
34
|
+
|
|
35
|
+
All toasts have a status of: information, attention, warning, success, and highlight. Choose the status depending on the type of message.
|
|
36
|
+
|
|
37
|
+
### Body
|
|
38
|
+
|
|
39
|
+
All toasts have body text, informing the user that something has occurred. The message should be as concise as possible, if a longer message is needed, consider an Alert Banner or Dialog.
|
|
40
|
+
|
|
41
|
+
### Actions
|
|
42
|
+
|
|
43
|
+
Toasts can have up to two action buttons, relating directly to the action taken that resulted in the notification. Examples include a link to a relevant list, or an action to try a failed submit.
|
|
44
|
+
|
|
45
|
+
## Behavior
|
|
46
|
+
|
|
47
|
+
### Timeout
|
|
48
|
+
|
|
49
|
+
Toasts automatically close 6 seconds after they have fully loaded. The timer is paused if focus is brought into the toast by the user.
|
|
50
|
+
|
|
51
|
+
### Placement
|
|
52
|
+
|
|
53
|
+
Toasts appear in the right corner of the application—either top-right (default) or bottom-right. Use the <code>position</code> option when calling the Toast API to choose placement.
|
|
54
|
+
|
|
55
|
+
### Width
|
|
56
|
+
|
|
57
|
+
Toasts have a flexible width that sizes to content, with a minimum of 360px and maximum of 480px.
|
|
58
|
+
|
|
59
|
+
### Overflow
|
|
60
|
+
|
|
61
|
+
Long messages wrap within the toast width (360-480px). Craft messages to take up no more than two lines.
|
|
62
|
+
|
|
63
|
+
## Best Practices
|
|
64
|
+
|
|
65
|
+
**Do**
|
|
66
|
+
|
|
67
|
+
<p>
|
|
68
|
+
Do use toasts for notifications that don't need to interrupt the user's workflow.
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
**Don't**
|
|
72
|
+
|
|
73
|
+
<p>
|
|
74
|
+
Don't use toasts for destructive, high-impact decisions that require the user's full attention.
|
|
75
|
+
</p>
|
|
76
|
+
|
|
77
|
+
## Accessibility
|
|
78
|
+
|
|
79
|
+
### Keyboard interaction
|
|
80
|
+
|
|
81
|
+
If a toast is non-actionable it is not in the page's tab sequence.
|
|
82
|
+
|
|
83
|
+
#### Actionable toasts
|
|
84
|
+
|
|
85
|
+
When a toast has interactive elements (dismiss button, action button), the tab order is:
|
|
86
|
+
|
|
87
|
+
1. Dismiss (close) button
|
|
88
|
+
2. Action button (if present)
|
|
89
|
+
|
|
90
|
+
### Live region
|
|
91
|
+
|
|
92
|
+
The entire contents of the toast must be announced as it appears on screen. Toasts use `role="status"` for info/success and `role="alert"` for warning/error, with `aria-live` set to `polite` or `assertive` accordingly.
|
|
93
|
+
|
|
94
|
+
### Reading order
|
|
95
|
+
|
|
96
|
+
In order to give all users adequate time to find and reach the action button, the toast element must be placed immediately after the user's current element.
|
|
97
|
+
|
|
98
|
+
### Time sensitive
|
|
99
|
+
|
|
100
|
+
Toasts must remain on screen long enough for users to read the message and access any action buttons. The default duration is 6 seconds; the timer pauses if focus is brought into the toast.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Core/Toast - Usage
|
|
2
|
+
|
|
3
|
+
Renders a toast inline for documentation/preview. Not for use in production.
|
|
4
|
+
|
|
5
|
+
| Prop | Type | Required | Default | Description |
|
|
6
|
+
| --- | --- | --- | --- | --- |
|
|
7
|
+
| `type` | `(typeof toastTypes)[number]` | Yes | `--` | `--` |
|
|
8
|
+
| `content` | `React.ReactNode` | Yes | `--` | `--` |
|
|
9
|
+
| `closable` | `boolean` | No | true | `--` |
|
|
10
|
+
| `action` | `ToastOptions['action']` | No | `--` | `--` |
|
|
11
|
+
| `actionSecondary` | `ToastOptions['actionSecondary']` | No | `--` | `--` |
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Core/Tooltip - Design
|
|
2
|
+
|
|
3
|
+
A component to display additional information when hovering or focusing on an interactive element.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Title
|
|
8
|
+
|
|
9
|
+
The text shown in the tooltip.
|
|
10
|
+
|
|
11
|
+
### Shortcut
|
|
12
|
+
|
|
13
|
+
The keyboard shortcut shown in the tooltip.
|
|
14
|
+
|
|
15
|
+
## Behavior
|
|
16
|
+
|
|
17
|
+
### Presentation
|
|
18
|
+
|
|
19
|
+
Tooltips appear after a 500ms delay when hovering a trigger element. Focusing a trigger element will show the
|
|
20
|
+
tooltip immediately.
|
|
21
|
+
|
|
22
|
+
### Dismissing
|
|
23
|
+
|
|
24
|
+
Tooltips disappear 500ms after the trigger element loses hover, immediately if focus is lost, or when another
|
|
25
|
+
element receives hover or focus that reveals a tooltip.
|
|
26
|
+
|
|
27
|
+
### Overflow
|
|
28
|
+
|
|
29
|
+
Tooltip titles should avoid wrapping where possible. When required, the title wraps to a new line when extending
|
|
30
|
+
beyond the width of the container.
|
|
31
|
+
|
|
32
|
+
### Placement
|
|
33
|
+
|
|
34
|
+
By default, tooltips appear below the trigger element. The tooltip will shift position if its placement places it
|
|
35
|
+
outside the viewport.
|
|
36
|
+
|
|
37
|
+
## Best Practices
|
|
38
|
+
|
|
39
|
+
**Do**
|
|
40
|
+
|
|
41
|
+
<p>
|
|
42
|
+
Do show only a single tooltip at a time.
|
|
43
|
+
</p>
|
|
44
|
+
|
|
45
|
+
**Don't**
|
|
46
|
+
|
|
47
|
+
<img style={{ width: '256px', marginInline: 'auto', display: 'block' }} src="tooltip-bestpractices-multiple-dont.png" />
|
|
48
|
+
|
|
49
|
+
<p>
|
|
50
|
+
Don't override tooltip behavior to show multiple at once.
|
|
51
|
+
</p>
|
|
52
|
+
|
|
53
|
+
## Accessibility
|
|
54
|
+
|
|
55
|
+
### Interaction
|
|
56
|
+
|
|
57
|
+
Tooltips are triggered on hover or focus, never on click. Tooltips do not contain interactive content.
|
|
58
|
+
|
|
59
|
+
### Custom Trigger
|
|
60
|
+
|
|
61
|
+
See the Usage page for more information on custom triggers.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Core/Tooltip - Usage
|
|
2
|
+
|
|
3
|
+
A component to display additional information when hovering or focusing on an interactive element.
|
|
4
|
+
|
|
5
|
+
## Custom Triggers
|
|
6
|
+
|
|
7
|
+
:::warning
|
|
8
|
+
|
|
9
|
+
**Custom triggers are an advanced feature and should be used with caution.** Tooltips should wrap interactive
|
|
10
|
+
elements. The defaults provided in Capra ensure an accessible experience. When using custom triggers, the dev assumes
|
|
11
|
+
responsibility for ensuring the tooltip trigger is accessible.
|
|
12
|
+
|
|
13
|
+
:::
|
|
14
|
+
|
|
15
|
+
By default, tooltips are triggered on for the `Button`, `IconButton`, `Link`, or `ButtonLink` components. For other elements, you can wrap them in a `CustomTooltipTrigger` to allow hover and focus to open the tooltip. The trigger still needs an appropriate ARIA role or semantic HTML element, and custom components should forward refs via `forwardRef` as well as spread props onto the underlying DOM node.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Tooltip, CustomTooltipTrigger } from '@capra/core';
|
|
19
|
+
|
|
20
|
+
function MyComponent() {
|
|
21
|
+
retur(
|
|
22
|
+
<Tooltip title="Tooltip content">
|
|
23
|
+
<CustomTooltipTrigger>
|
|
24
|
+
<span role="button" tabIndex={0} style={{ cursor: 'default', textDecoration: 'underline' }}>
|
|
25
|
+
Custom trigger (span)
|
|
26
|
+
</span>
|
|
27
|
+
</CustomTooltipTrigger>
|
|
28
|
+
</Tooltip>,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Important Notes**
|
|
34
|
+
|
|
35
|
+
* The trigger element must have an appropriate ARIA role or semantic HTML element.
|
|
36
|
+
* `CustomTooltipTrigger` only accepts a single child.
|
|
37
|
+
|
|
38
|
+
## Props
|
|
39
|
+
|
|
40
|
+
| Prop | Type | Required | Default | Description |
|
|
41
|
+
| --- | --- | --- | --- | --- |
|
|
42
|
+
| `children` | `React.ReactNode` | Yes | `--` | The visible trigger element. This can be a single element or a component tree, but there MUST be a focusable element (`Button`, `IconButton`, `Link`, or a custom trigger via `CustomTooltipTrigger`) in the tree. Nothing else will trigger the tooltip. |
|
|
43
|
+
| `title` | `string` | Yes | `--` | The content of the tooltip. |
|
|
44
|
+
| `shortcut` | `string` | No | `--` | Optional keyboard shortcut label shown next to the title (e.g. `⌘K`, `Ctrl+S`). |
|
|
45
|
+
| `placement` | `(typeof placements)[number]` | No | 'bottom' | The position of the tooltip relative to the trigger element.<br>@default 'bottom' |
|
|
46
|
+
| `isDisabled` | `boolean` | No | false | Whether the tooltip is disabled.<br>@default false |
|
|
47
|
+
| `getContainer` | `() => HTMLElement \| null` | No | `--` | The container to mount the tooltip in.<br>@default document.body<br><br>**Warning**: This is an unsafe feature and may cause accessibility, keyboard navigation, and other issues. Only use if you know what you are doing. |
|
|
48
|
+
| `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,75 @@
|
|
|
1
|
+
# Core/TopNav - Design
|
|
2
|
+
|
|
3
|
+
## Properties
|
|
4
|
+
|
|
5
|
+
### Logo
|
|
6
|
+
|
|
7
|
+
The logo is required for all top navigation bars. It should link to the home page or main dashboard of the application.
|
|
8
|
+
|
|
9
|
+
### Navigation items
|
|
10
|
+
|
|
11
|
+
Navigation items represent the main sections of the application. They should be concise and clearly labeled. Use `TopNav.Item` for each navigation link.
|
|
12
|
+
|
|
13
|
+
### Actions
|
|
14
|
+
|
|
15
|
+
Actions are optional elements placed on the right side of the navigation bar. Common actions include search, notifications, user profile, and settings. Use `TopNav.Actions` to group these elements.
|
|
16
|
+
|
|
17
|
+
## Best Practices
|
|
18
|
+
|
|
19
|
+
### Navigation clarity
|
|
20
|
+
|
|
21
|
+
**Do**
|
|
22
|
+
|
|
23
|
+
<img className="w-full" src="images/guidelines/topnav/bestpractices-clarity-do.png" alt="Clear navigation labels" />
|
|
24
|
+
|
|
25
|
+
<p>
|
|
26
|
+
Do use clear, descriptive labels for navigation items.
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
**Don't**
|
|
30
|
+
|
|
31
|
+
<img className="w-full" src="images/guidelines/topnav/bestpractices-clarity-dont.png" alt="Unclear navigation labels" />
|
|
32
|
+
|
|
33
|
+
<p>
|
|
34
|
+
Don't use vague or ambiguous labels that don't clearly indicate the destination.
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
### Action overload
|
|
38
|
+
|
|
39
|
+
**Do**
|
|
40
|
+
|
|
41
|
+
<img className="w-full" src="images/guidelines/topnav/bestpractices-actions-do.png" alt="Reasonable number of actions" />
|
|
42
|
+
|
|
43
|
+
<p>
|
|
44
|
+
Do limit the number of actions to the most essential ones.
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
**Don't**
|
|
48
|
+
|
|
49
|
+
<img className="w-full" src="images/guidelines/topnav/bestpractices-actions-dont.png" alt="Too many actions" />
|
|
50
|
+
|
|
51
|
+
<p>
|
|
52
|
+
Don't overcrowd the actions area with too many buttons or icons.
|
|
53
|
+
</p>
|
|
54
|
+
|
|
55
|
+
## Accessibility
|
|
56
|
+
|
|
57
|
+
### Landmark
|
|
58
|
+
|
|
59
|
+
The top navigation uses `role="banner"` to identify it as the site-wide header landmark. This helps screen reader users quickly navigate to the main application header.
|
|
60
|
+
|
|
61
|
+
### Banner
|
|
62
|
+
|
|
63
|
+
The `TopNav` component is wrapped in a `<header>` element with `role="banner"`, which is the appropriate semantic HTML for site-wide navigation headers.
|
|
64
|
+
|
|
65
|
+
### Keyboard interaction
|
|
66
|
+
|
|
67
|
+
| Key | Function |
|
|
68
|
+
| ----------------- | -------------------------------------------------------------------------------- |
|
|
69
|
+
| `Tab` | Moves focus through interactive elements in the navigation bar in logical order. |
|
|
70
|
+
| `Enter` / `Space` | Activates focused links or buttons. |
|
|
71
|
+
| `Escape` | Closes any open dropdowns or menus within the navigation. |
|
|
72
|
+
|
|
73
|
+
### Targets
|
|
74
|
+
|
|
75
|
+
All interactive elements in the top navigation meet the minimum 24×24 CSS pixel target size requirement for WCAG 2.2 Level AA compliance.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Core/TopNav - Usage
|
|
2
|
+
|
|
3
|
+
| Prop | Type | Required | Default | Description |
|
|
4
|
+
| --- | --- | --- | --- | --- |
|
|
5
|
+
| `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. |
|
|
6
|
+
| `children` | `React.ReactNode` | No | `--` | `--` |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Core/VerticalNavigation - Design
|
|
2
|
+
|
|
3
|
+
Vertical navigation shell with controlled and uncontrolled collapse support. Provides shared context for items, collapse toggle, and footer sections.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### Layout
|
|
8
|
+
|
|
9
|
+
VerticalNavigation consists of a list of items and an optional footer. It is typically placed on the left side of the screen.
|
|
10
|
+
It supports a collapsed state to save space.
|
|
11
|
+
|
|
12
|
+
### Items
|
|
13
|
+
|
|
14
|
+
Navigation items can have icons and labels. Sub-items are indented and do not have icons.
|
|
15
|
+
Items can be links (using `href`) or buttons (using `onClick`).
|
|
16
|
+
|
|
17
|
+
## Accessibility
|
|
18
|
+
|
|
19
|
+
### Keyboard interaction
|
|
20
|
+
|
|
21
|
+
| Key | Function |
|
|
22
|
+
| ------------------- | ---------------------------------------------------------------------------- |
|
|
23
|
+
| `Tab` / `Shift-Tab` | Moves focus through the interactive items (links, buttons, collapse toggle). |
|
|
24
|
+
| `Enter` / `Space` | Activates the focused item (follows link or triggers action). |
|
|
25
|
+
|
|
26
|
+
### WAI-ARIA Roles, States, and Properties
|
|
27
|
+
|
|
28
|
+
* The navigation container has `role="navigation"` (implicit for `<nav>`).
|
|
29
|
+
* The `aria-label` provides a descriptive name for the navigation region (default: "Cribl product navigation").
|
|
30
|
+
* The collapse toggle has `aria-expanded` reflecting the collapsed state.
|
|
31
|
+
* Active items use `aria-current="page"` to indicate the current page.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Core/VerticalNavigation - Usage
|
|
2
|
+
|
|
3
|
+
Vertical navigation shell with controlled and uncontrolled collapse support. Provides shared context for items, collapse toggle, and footer sections.
|
|
4
|
+
|
|
5
|
+
### VerticalNavigation
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Required | Default | Description |
|
|
8
|
+
| --- | --- | --- | --- | --- |
|
|
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
|
+
| `collapsed` | `boolean` | No | `--` | Controlled collapsed state. |
|
|
11
|
+
| `onCollapseChange` | `(collapsed: boolean) => void` | No | `--` | Callback fired when the collapsed state changes. |
|
|
12
|
+
| `defaultCollapsed` | `boolean` | No | false | Default collapsed state for uncontrolled mode.<br>@default false |
|
|
13
|
+
| `aria-label` | `string` | No | 'Cribl product navigation' | `--` |
|
|
14
|
+
|
|
15
|
+
### Examples
|
|
16
|
+
|
|
17
|
+
Various product navigation configurations.
|