@cdx-ui/components 0.2.3 → 0.2.5
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/AGENTS.md +24 -0
- package/README.md +2 -0
- package/coverage.svg +1 -1
- package/docs/components/accordion/content.md +538 -0
- package/docs/components/alert/content.md +203 -0
- package/docs/components/alert-dialog/content.md +319 -0
- package/docs/components/avatar/content.md +368 -0
- package/docs/components/avatar/design.md +202 -0
- package/docs/components/badge/content.md +225 -0
- package/docs/components/bottom-sheet/content.md +353 -0
- package/docs/components/bottom-sheet/design.md +249 -0
- package/docs/components/box/content.md +141 -0
- package/docs/components/breadcrumbs/content.md +169 -0
- package/docs/components/button/content.md +398 -0
- package/docs/components/button/design.md +258 -0
- package/docs/components/calendar/content.md +137 -0
- package/docs/components/card/content.md +283 -0
- package/docs/components/carousel/content.md +417 -0
- package/docs/components/checkbox/content.md +236 -0
- package/docs/components/checkbox/design.md +214 -0
- package/docs/components/chip/content.md +439 -0
- package/docs/components/chip/design.md +418 -0
- package/docs/components/color-area/content.md +84 -0
- package/docs/components/color-field/content.md +132 -0
- package/docs/components/color-picker/content.md +209 -0
- package/docs/components/color-slider/content.md +118 -0
- package/docs/components/color-swatch/content.md +62 -0
- package/docs/components/color-swatch-picker/content.md +124 -0
- package/docs/components/content.md +98 -0
- package/docs/components/currency-input/content.md +205 -0
- package/docs/components/data-grid/content.md +521 -0
- package/docs/components/date-field/content.md +147 -0
- package/docs/components/date-picker/content.md +360 -0
- package/docs/components/date-range-picker/content.md +301 -0
- package/docs/components/date-time-field/content.md +157 -0
- package/docs/components/date-time-list/content.md +105 -0
- package/docs/components/date-time-picker/content.md +272 -0
- package/docs/components/dialog/content.md +436 -0
- package/docs/components/dialog/design.md +192 -0
- package/docs/components/divider/content.md +112 -0
- package/docs/components/drawer/content.md +428 -0
- package/docs/components/field/content.md +277 -0
- package/docs/components/form/content.md +62 -0
- package/docs/components/full-screen-dialog/content.md +881 -0
- package/docs/components/heading/content.md +55 -0
- package/docs/components/icon/content.md +190 -0
- package/docs/components/icon-button/content.md +200 -0
- package/docs/components/icon-button/design.md +165 -0
- package/docs/components/image/content.md +104 -0
- package/docs/components/input/content.md +346 -0
- package/docs/components/input/design.md +389 -0
- package/docs/components/insurance-disclosure/content.md +103 -0
- package/docs/components/link/content.md +180 -0
- package/docs/components/link/design.md +160 -0
- package/docs/components/list-item/content.md +695 -0
- package/docs/components/menu/content.md +1254 -0
- package/docs/components/month-calendar/content.md +84 -0
- package/docs/components/month-picker/content.md +273 -0
- package/docs/components/otp-input/content.md +327 -0
- package/docs/components/progress-bar/content.md +87 -0
- package/docs/components/progress-circle/content.md +176 -0
- package/docs/components/progress-segmented/content.md +119 -0
- package/docs/components/quick-action-button/content.md +154 -0
- package/docs/components/quick-action-button/design.md +170 -0
- package/docs/components/radio/content.md +224 -0
- package/docs/components/range-calendar/content.md +123 -0
- package/docs/components/reorderable-list/content.md +311 -0
- package/docs/components/scoped-theme/content.md +47 -0
- package/docs/components/scroll-shadow/content.md +693 -0
- package/docs/components/select/content.md +473 -0
- package/docs/components/select/design.md +301 -0
- package/docs/components/skeleton/content.md +104 -0
- package/docs/components/slider/content.md +423 -0
- package/docs/components/stack/content.md +161 -0
- package/docs/components/switch/content.md +150 -0
- package/docs/components/switch/design.md +208 -0
- package/docs/components/table/content.md +548 -0
- package/docs/components/table-pagination/content.md +177 -0
- package/docs/components/tabs/content.md +297 -0
- package/docs/components/text/content.md +142 -0
- package/docs/components/textarea/content.md +222 -0
- package/docs/components/tile/content.md +702 -0
- package/docs/components/toast/content.md +456 -0
- package/docs/components/toggle-button/content.md +505 -0
- package/docs/components/tooltip/content.md +350 -0
- package/docs/components/virtualized-list/content.md +250 -0
- package/docs/foundations/content.md +9 -0
- package/docs/foundations/expressions/icons/content.md +19 -0
- package/docs/foundations/styles/tokens/all-tokens/content.md +192 -0
- package/docs/foundations/styles/tokens/what-are-tokens/content.md +33 -0
- package/docs/foundations/styles/tokens/what-are-tokens/design.md +33 -0
- package/docs/getting-started/content.md +4 -0
- package/docs/getting-started/designers/content.md +13 -0
- package/docs/getting-started/designers/design.md +13 -0
- package/docs/getting-started/developers/accessibility/content.md +31 -0
- package/docs/getting-started/developers/content.md +612 -0
- package/docs/getting-started/developers/styling/content.md +195 -0
- package/docs/llms.txt +195 -0
- package/docs/patterns/account-management/content.md +75 -0
- package/docs/patterns/authentication/content.md +50 -0
- package/docs/patterns/content.md +10 -0
- package/docs/patterns/dashboard/content.md +34 -0
- package/docs/patterns/empty-states/content.md +32 -0
- package/docs/patterns/forms/content.md +108 -0
- package/docs/patterns/onboarding/content.md +69 -0
- package/docs/patterns/payments/content.md +35 -0
- package/docs/patterns/settings/content.md +72 -0
- package/docs/resources/content.md +9 -0
- package/docs/resources/figma-libraries/content.md +42 -0
- package/docs/resources/release-notes/0.0.1-beta.118/content.md +27 -0
- package/docs/resources/release-notes/0.0.1-beta.122/content.md +21 -0
- package/docs/resources/release-notes/0.0.1-beta.124/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.126/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.127/content.md +14 -0
- package/docs/resources/release-notes/0.0.1-beta.128/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.129/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.130/content.md +18 -0
- package/docs/resources/release-notes/0.0.1-beta.133/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.134/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.136/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.137/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.138/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.139/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.140/content.md +26 -0
- package/docs/resources/release-notes/0.0.1-beta.141/content.md +63 -0
- package/docs/resources/release-notes/0.0.1-beta.142/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.143/content.md +12 -0
- package/docs/resources/release-notes/0.0.1-beta.144/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.145/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.147/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.149/content.md +10 -0
- package/docs/resources/release-notes/0.0.1-beta.150/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.152/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.154/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.156/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.158/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.159/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.160/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.161/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.163/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.164/content.md +9 -0
- package/docs/resources/release-notes/0.0.1-beta.166/content.md +17 -0
- package/docs/resources/release-notes/0.0.1-beta.167/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.168/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.169/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.171/content.md +16 -0
- package/docs/resources/release-notes/0.0.1-beta.172/content.md +24 -0
- package/docs/resources/release-notes/0.0.1-beta.173/content.md +15 -0
- package/docs/resources/release-notes/0.0.1-beta.174/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.176/content.md +32 -0
- package/docs/resources/release-notes/0.0.1-beta.179/content.md +11 -0
- package/docs/resources/release-notes/0.0.1-beta.182/content.md +13 -0
- package/docs/resources/release-notes/0.0.1-beta.185/content.md +7 -0
- package/docs/resources/release-notes/0.0.1-beta.187/content.md +27 -0
- package/docs/resources/release-notes/0.1.1/content.md +23 -0
- package/docs/resources/release-notes/0.1.2/content.md +7 -0
- package/docs/resources/release-notes/0.1.4/content.md +19 -0
- package/docs/resources/release-notes/0.1.5/content.md +7 -0
- package/docs/resources/release-notes/0.1.6/content.md +7 -0
- package/docs/resources/release-notes/0.2.0/content.md +31 -0
- package/docs/resources/release-notes/0.2.1/content.md +17 -0
- package/docs/resources/release-notes/0.2.2/content.md +11 -0
- package/docs/resources/release-notes/0.2.3/content.md +15 -0
- package/docs/resources/release-notes/0.2.4/content.md +17 -0
- package/docs/resources/release-notes/content.md +65 -0
- package/lib/commonjs/components/Box/Box.js +9 -1
- package/lib/commonjs/components/Box/Box.js.map +1 -1
- package/lib/commonjs/components/Breadcrumbs/index.js +28 -3
- package/lib/commonjs/components/Breadcrumbs/index.js.map +1 -1
- package/lib/commonjs/components/Breadcrumbs/styles.js +27 -0
- package/lib/commonjs/components/Breadcrumbs/styles.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/index.js +11 -26
- package/lib/commonjs/components/DateTimeList/index.js.map +1 -1
- package/lib/commonjs/components/DateTimeList/styles.js +2 -12
- package/lib/commonjs/components/DateTimeList/styles.js.map +1 -1
- package/lib/commonjs/components/ListItem/index.js.map +1 -1
- package/lib/commonjs/components/ListItem/styles.js +2 -1
- package/lib/commonjs/components/ListItem/styles.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +11 -5
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/gradient.js +29 -0
- package/lib/commonjs/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/index.js +171 -44
- package/lib/commonjs/components/ScrollShadow/index.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/styles.js +58 -14
- package/lib/commonjs/components/ScrollShadow/styles.js.map +1 -1
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js +63 -0
- package/lib/commonjs/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js +48 -8
- package/lib/commonjs/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/commonjs/components/Stack/HStack.js +6 -2
- package/lib/commonjs/components/Stack/HStack.js.map +1 -1
- package/lib/commonjs/components/Stack/VStack.js +6 -2
- package/lib/commonjs/components/Stack/VStack.js.map +1 -1
- package/lib/commonjs/components/Tabs/index.js +16 -23
- package/lib/commonjs/components/Tabs/index.js.map +1 -1
- package/lib/commonjs/components/Tabs/styles.js +1 -10
- package/lib/commonjs/components/Tabs/styles.js.map +1 -1
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/commonjs/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/commonjs/index.js +10 -10
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/components/Box/Box.js +9 -1
- package/lib/module/components/Box/Box.js.map +1 -1
- package/lib/module/components/Breadcrumbs/index.js +29 -4
- package/lib/module/components/Breadcrumbs/index.js.map +1 -1
- package/lib/module/components/Breadcrumbs/styles.js +26 -0
- package/lib/module/components/Breadcrumbs/styles.js.map +1 -1
- package/lib/module/components/DateTimeList/index.js +12 -27
- package/lib/module/components/DateTimeList/index.js.map +1 -1
- package/lib/module/components/DateTimeList/styles.js +1 -11
- package/lib/module/components/DateTimeList/styles.js.map +1 -1
- package/lib/module/components/ListItem/index.js.map +1 -1
- package/lib/module/components/ListItem/styles.js +2 -1
- package/lib/module/components/ListItem/styles.js.map +1 -1
- package/lib/module/components/Menu/index.js +11 -5
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/gradient.js +24 -0
- package/lib/module/components/ScrollShadow/gradient.js.map +1 -0
- package/lib/module/components/ScrollShadow/index.js +170 -48
- package/lib/module/components/ScrollShadow/index.js.map +1 -1
- package/lib/module/components/ScrollShadow/styles.js +57 -13
- package/lib/module/components/ScrollShadow/styles.js.map +1 -1
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js +57 -0
- package/lib/module/components/ScrollShadow/useComposedScrollHandler.js.map +1 -0
- package/lib/module/components/ScrollShadow/useScrollShadow.js +46 -8
- package/lib/module/components/ScrollShadow/useScrollShadow.js.map +1 -1
- package/lib/module/components/Stack/HStack.js +6 -2
- package/lib/module/components/Stack/HStack.js.map +1 -1
- package/lib/module/components/Stack/VStack.js +6 -2
- package/lib/module/components/Stack/VStack.js.map +1 -1
- package/lib/module/components/Tabs/index.js +17 -24
- package/lib/module/components/Tabs/index.js.map +1 -1
- package/lib/module/components/Tabs/styles.js +0 -9
- package/lib/module/components/Tabs/styles.js.map +1 -1
- package/lib/module/figma/ListItem.SectionHeader.figma.js +20 -5
- package/lib/module/figma/ListItem.SectionHeader.figma.js.map +1 -1
- package/lib/module/index.js +6 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/animation/hooks/usePopupDialogContentAnimation.d.ts +2 -2
- package/lib/typescript/animation/hooks/usePopupOverlayAnimation.d.ts +2 -2
- package/lib/typescript/components/Box/Box.d.ts +4 -0
- package/lib/typescript/components/Box/Box.d.ts.map +1 -1
- package/lib/typescript/components/Breadcrumbs/index.d.ts +3 -1
- package/lib/typescript/components/Breadcrumbs/index.d.ts.map +1 -1
- package/lib/typescript/components/Breadcrumbs/styles.d.ts +2 -0
- package/lib/typescript/components/Breadcrumbs/styles.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/index.d.ts.map +1 -1
- package/lib/typescript/components/DateTimeList/styles.d.ts +1 -4
- package/lib/typescript/components/DateTimeList/styles.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/index.d.ts +5 -4
- package/lib/typescript/components/ListItem/index.d.ts.map +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts +1 -1
- package/lib/typescript/components/ListItem/styles.d.ts.map +1 -1
- package/lib/typescript/components/Menu/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/gradient.d.ts +7 -0
- package/lib/typescript/components/ScrollShadow/gradient.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/index.d.ts +57 -15
- package/lib/typescript/components/ScrollShadow/index.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/styles.d.ts +8 -2
- package/lib/typescript/components/ScrollShadow/styles.d.ts.map +1 -1
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts +13 -0
- package/lib/typescript/components/ScrollShadow/useComposedScrollHandler.d.ts.map +1 -0
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts +15 -2
- package/lib/typescript/components/ScrollShadow/useScrollShadow.d.ts.map +1 -1
- package/lib/typescript/components/Stack/HStack.d.ts +3 -2
- package/lib/typescript/components/Stack/HStack.d.ts.map +1 -1
- package/lib/typescript/components/Stack/VStack.d.ts +3 -2
- package/lib/typescript/components/Stack/VStack.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/index.d.ts.map +1 -1
- package/lib/typescript/components/Tabs/styles.d.ts +0 -7
- package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
- package/lib/typescript/components/Toast/animation.d.ts +3 -3
- package/lib/typescript/components/Toast/animation.d.ts.map +1 -1
- package/lib/typescript/figma/ListItem.SectionHeader.figma.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +6 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +11 -9
- package/src/components/Box/Box.tsx +18 -4
- package/src/components/Breadcrumbs/index.tsx +28 -4
- package/src/components/Breadcrumbs/styles.ts +30 -0
- package/src/components/DateTimeList/index.tsx +13 -26
- package/src/components/DateTimeList/styles.ts +1 -10
- package/src/components/ListItem/index.tsx +5 -4
- package/src/components/ListItem/styles.ts +1 -0
- package/src/components/Menu/index.tsx +11 -8
- package/src/components/ScrollShadow/gradient.ts +48 -0
- package/src/components/ScrollShadow/index.tsx +300 -69
- package/src/components/ScrollShadow/styles.ts +45 -28
- package/src/components/ScrollShadow/useComposedScrollHandler.ts +58 -0
- package/src/components/ScrollShadow/useScrollShadow.ts +72 -10
- package/src/components/Stack/HStack.tsx +8 -4
- package/src/components/Stack/VStack.tsx +8 -4
- package/src/components/Tabs/index.tsx +25 -35
- package/src/components/Tabs/styles.ts +0 -9
- package/src/index.ts +8 -1
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
# Chip — Design (https://design.candescent.com/docs/components/chip)
|
|
2
|
+
|
|
3
|
+
## Usage
|
|
4
|
+
|
|
5
|
+
**Example**
|
|
6
|
+
|
|
7
|
+
**Common alternative names**: Tag, lozenge, label, category
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Anatomy
|
|
12
|
+
|
|
13
|
+
In its most basic form, a Chip is a short label inside a container. A leading icon and a delete button can also be added to the chip.
|
|
14
|
+
|
|
15
|
+
**Anatomy\_chip**
|
|
16
|
+
|
|
17
|
+
1. **Label**: Text that describes the chip’s meaning or action.
|
|
18
|
+
2. **Start Adornment (optional)**: An icon or avatar can be included before the label to add additional affordance a chip.
|
|
19
|
+
3. **Delete button (optional)**: A button that can be used to delete or remove the chip.
|
|
20
|
+
|
|
21
|
+
### Variant
|
|
22
|
+
|
|
23
|
+
Chips are available in 2 variants: **Solid** and **Outlined**.
|
|
24
|
+
|
|
25
|
+
- **Solid**
|
|
26
|
+
|
|
27
|
+
Solid background color. Higher emphasis than outlined variant.
|
|
28
|
+
- **Outline**
|
|
29
|
+
|
|
30
|
+
Solid outline color, no background color. Lower emphasis than filled variant.
|
|
31
|
+
|
|
32
|
+
### Color
|
|
33
|
+
|
|
34
|
+
Chips are versatile, and are available in a wide variety of colors that can be used to indicate different levels of importance or status.
|
|
35
|
+
|
|
36
|
+
- **color: default**
|
|
37
|
+
|
|
38
|
+
Neutral grey, most common, less visual prominence.
|
|
39
|
+
- **color: primary**
|
|
40
|
+
|
|
41
|
+
Utilizes the primary brand color palette.
|
|
42
|
+
- **color: danger**
|
|
43
|
+
|
|
44
|
+
Used for attributes or actions associated with the terms: error, danger, failure, negative, destructive
|
|
45
|
+
- **color: warning**
|
|
46
|
+
|
|
47
|
+
Used for attributes or actions associated with the terms: warning, caution, avoid
|
|
48
|
+
- **color: info**
|
|
49
|
+
|
|
50
|
+
Used for attributes or actions associated with the terms: informational, new
|
|
51
|
+
- **color: success**
|
|
52
|
+
|
|
53
|
+
Used for attributes or actions associated with the terms: success, successful, completion, positive
|
|
54
|
+
|
|
55
|
+
### Deletable
|
|
56
|
+
|
|
57
|
+
A delete button may be added to the end of a chip. Clicking this button should delete/remove/clear the chip.
|
|
58
|
+
|
|
59
|
+
- **Show Delete?: true**
|
|
60
|
+
|
|
61
|
+
An icon button with a cancel icon is displayed after the label (right side).
|
|
62
|
+
|
|
63
|
+
### Size
|
|
64
|
+
|
|
65
|
+
Chips are available in 3 sizes: **default, small** and **xsmall**. Size should be considered for visual balance and user focus; larger chips will draw greater attention.
|
|
66
|
+
|
|
67
|
+
- **size: default**
|
|
68
|
+
|
|
69
|
+
Default chips have a height of 32px.
|
|
70
|
+
- **size: small**
|
|
71
|
+
|
|
72
|
+
Small chips have a height of 20px.
|
|
73
|
+
- **size: xsmall**
|
|
74
|
+
|
|
75
|
+
Mini chips have a height of 16px. The label’s font size does not change.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
Usage
|
|
80
|
+
|
|
81
|
+
Chips help users enter information, make selections, filter content, or trigger actions. They’re best used to help users accomplish their current task faster and more easily.
|
|
82
|
+
|
|
83
|
+
### When to use
|
|
84
|
+
|
|
85
|
+
> [!TIP]
|
|
86
|
+
>
|
|
87
|
+
> **Visually categorize and label content**
|
|
88
|
+
>
|
|
89
|
+
> - ex: “Dairy”, “Tree nuts”, “Soy”, and other allergens attached to restaurant menu items
|
|
90
|
+
> - ex: “Not started”, “In progress”, and “Complete” on to-do list items
|
|
91
|
+
|
|
92
|
+
> [!TIP]
|
|
93
|
+
>
|
|
94
|
+
> **Dynamically filter and refine the contents of a page, table, dashboard, etc.**
|
|
95
|
+
>
|
|
96
|
+
> - ex: Quickly selecting one or more categories to filter a list by
|
|
97
|
+
> - ex: Open (and display the current value of) more advanced filter menus
|
|
98
|
+
|
|
99
|
+
> [!TIP]
|
|
100
|
+
>
|
|
101
|
+
> **Provide dynamically-generated suggestions to help narrow a user’s intent**
|
|
102
|
+
>
|
|
103
|
+
> - ex: Pre-populated responses in a chat window
|
|
104
|
+
> - ex: Suggested search queries
|
|
105
|
+
|
|
106
|
+
> [!TIP]
|
|
107
|
+
>
|
|
108
|
+
> **Show discrete pieces of user-entered or user-selected information**
|
|
109
|
+
>
|
|
110
|
+
> - ex: Selecting multiple options from a menu in a Select or Autocomplete field
|
|
111
|
+
> - ex: Showing valid contacts entered into the “To” field of a new email
|
|
112
|
+
> - ex: Showing active search terms in an Autocomplete search field
|
|
113
|
+
|
|
114
|
+
### When not to use
|
|
115
|
+
|
|
116
|
+
> [!CAUTION]
|
|
117
|
+
>
|
|
118
|
+
> **To take the place of a button or significant call to action**
|
|
119
|
+
>
|
|
120
|
+
> - ex: As the submit button button on a form
|
|
121
|
+
> - ex: As the affirmative or dismissive action in a dialog
|
|
122
|
+
|
|
123
|
+
### Chips are not buttons
|
|
124
|
+
|
|
125
|
+
Chips and buttons both prompt users to take actions and make selections. However, they have different use cases, and are not interchangeable.
|
|
126
|
+
|
|
127
|
+
Buttons should be used for significant calls to action, and represent linear steps that progress the user through the product. Chips should appear dynamically based on the user’s current context, and encourage action by offering optional, forking paths.
|
|
128
|
+
|
|
129
|
+
- **Do:** Use chips to present contextual, supplemental options
|
|
130
|
+
- **Don't:** Don’t replace major actions with chips. Actions that progress users the next or previous step should always be buttons.
|
|
131
|
+
|
|
132
|
+
### Types
|
|
133
|
+
|
|
134
|
+
Chips are an extremely versatile component. We’ve grouped them into categories based on their intended use, following the lead of the Material Guidelines. Each type has their own set of best practices and behaviors.
|
|
135
|
+
|
|
136
|
+
| **Chip type** | **Purpose** | **Created by** | **Behavior** |
|
|
137
|
+
| -------------- | ----------- | ------------------- | ---------------------------------------------------------------------------- |
|
|
138
|
+
| **Tag** | Categorize | Application | Visually categorize and label content |
|
|
139
|
+
| **Suggestion** | Information | Application | Provide dynamically-generated suggestions to help narrow a user’s intent |
|
|
140
|
+
| **Filter** | Filter | Application or User | Dynamically filter and refine the contents of a page, table, dashboard, etc. |
|
|
141
|
+
|
|
142
|
+
### Tag chips
|
|
143
|
+
|
|
144
|
+
Tag chips are used to assign relevant terms or categories to items in the application for easy retrieval and comprehension. They enhance organization and provide meaningful context to various elements within the application.
|
|
145
|
+
|
|
146
|
+
_usage\_tag\_01-ex_
|
|
147
|
+
|
|
148
|
+
When to use
|
|
149
|
+
|
|
150
|
+
> [!TIP]
|
|
151
|
+
>
|
|
152
|
+
> **To show multiple item categories**
|
|
153
|
+
>
|
|
154
|
+
> - ex: “Dairy”, “Tree nuts”, “Soy”, and other allergens attached to restaurant menu items
|
|
155
|
+
> - ex: “Utilities”, “Takeout”, “Subscription”, or other categories assigned to transactions
|
|
156
|
+
|
|
157
|
+
> [!TIP]
|
|
158
|
+
>
|
|
159
|
+
> **To provide status on an item**
|
|
160
|
+
>
|
|
161
|
+
> - ex: “Not started”, “In progress”, and “Complete” on to-do list items
|
|
162
|
+
> - ex: “Offline”, “Online”, and “On a call” on a teller status dashboard
|
|
163
|
+
|
|
164
|
+
When not to use
|
|
165
|
+
|
|
166
|
+
> [!CAUTION]
|
|
167
|
+
>
|
|
168
|
+
> **Numerical counts**
|
|
169
|
+
>
|
|
170
|
+
> - Use a Badge component instead
|
|
171
|
+
|
|
172
|
+
#### **Layout and placement**
|
|
173
|
+
|
|
174
|
+
Chips are most often used in multiples, so they can easily look cluttered. To avoid this, place multiple chips in a horizontal row. When needed, chips should either wrap to additional lines, or in fixed-height areas, use horizontal scrolling and a “peek” view of the next chip.
|
|
175
|
+
|
|
176
|
+
We recommend 8px of space between each chip, vertically and horizontally.
|
|
177
|
+
|
|
178
|
+
**Example**
|
|
179
|
+
|
|
180
|
+
#### Variants
|
|
181
|
+
|
|
182
|
+
Tag chips have the most flexibility when it comes to color. When choosing a color, keep in mind that each color carries inherent meaning to users, so align your choice to that meaning.
|
|
183
|
+
|
|
184
|
+
- **Default**: neutral grey
|
|
185
|
+
- **Primary**: varies based on customer brand
|
|
186
|
+
- **Danger**: error, danger, failure, negative, destructive
|
|
187
|
+
- **Warning**: warning, caution, avoid
|
|
188
|
+
- **Info**: informational, new
|
|
189
|
+
- **Success**: success, successful, completion, positive
|
|
190
|
+
|
|
191
|
+
In addition to color, tag chips often use an icon to reinforce the chip’s meaning. This is especially helpful for the chips using **severity colors** (error, warning, info, and success), as icons enable the user to understand the chip’s meaning at a quick glance.
|
|
192
|
+
|
|
193
|
+
- **Do:** Use icons in combination with color to help reinforce the chip’s meaning.
|
|
194
|
+
- **Don't:** Don’t use mismatched icons and colors with mismatched meanings. For example, the Warning color with the Info icon.
|
|
195
|
+
|
|
196
|
+
### **Filter chips**
|
|
197
|
+
|
|
198
|
+
Filter chips utilize keywords and tags to dynamically search through and refine content. They can serve as a good alternative to checkboxes and toggle buttons for selecting options.
|
|
199
|
+
|
|
200
|
+
_usage\_filter\_01-ex_
|
|
201
|
+
|
|
202
|
+
When to use
|
|
203
|
+
|
|
204
|
+
> [!TIP]
|
|
205
|
+
>
|
|
206
|
+
> **To filter content on the current page, table, dashboard, etc.**
|
|
207
|
+
>
|
|
208
|
+
> - ex: Quickly selecting one or more categories to filter a list by
|
|
209
|
+
> - ex: Open (and display the current value of) more advanced filter menus
|
|
210
|
+
|
|
211
|
+
When not to use
|
|
212
|
+
|
|
213
|
+
> [!CAUTION]
|
|
214
|
+
>
|
|
215
|
+
> **When the intent is to show new content on a page after clicking**
|
|
216
|
+
>
|
|
217
|
+
> - ex: Swapping to a different table or different data visualizations
|
|
218
|
+
> - Use Tabs instead
|
|
219
|
+
|
|
220
|
+
> [!CAUTION]
|
|
221
|
+
>
|
|
222
|
+
> **In a form where the intent is to select one option**
|
|
223
|
+
>
|
|
224
|
+
> - ex: Using a row of chips to select a shirt size
|
|
225
|
+
> - Use a Form Control or [Select](https://design.candescent.com/docs/components/select/content.md) instead
|
|
226
|
+
|
|
227
|
+
Layout and placement
|
|
228
|
+
|
|
229
|
+
Place filter chips in a horizontal row. Use horizontal scrolling and a “peek” view of the next chip if needed. We recommend 8px of space between each chip.
|
|
230
|
+
|
|
231
|
+
Additionally, filter chips should typically be placed above the content they are filtering. This helps the user understand what area the filter applies to.
|
|
232
|
+
|
|
233
|
+
_usage\_filter\_layout\_01-ex_
|
|
234
|
+
|
|
235
|
+
Variants
|
|
236
|
+
|
|
237
|
+
The Chip component does not have predefined variants for “unselected” and “selected”. For the unselected state, we recommend the **default** color and either the **solid** or **outlined** variant. For the selected state, we recommend the **action** color, the **solid** variant, and adding a Check icon.
|
|
238
|
+
|
|
239
|
+
- **Do:** Change the color AND the icon to show the selected state.
|
|
240
|
+
- **Don't:** Don’t rely on just color changes. At least 2 visual differences are required to meet accessibility guidelines.
|
|
241
|
+
|
|
242
|
+
### **Suggestion chips**
|
|
243
|
+
|
|
244
|
+
Suggestion chips are valuable aids in refining user intent, providing dynamically-generated options like response suggestions or search filters.
|
|
245
|
+
|
|
246
|
+
_usage\_suggestion\_01-ex_
|
|
247
|
+
|
|
248
|
+
When to use
|
|
249
|
+
|
|
250
|
+
> [!TIP]
|
|
251
|
+
>
|
|
252
|
+
> **To help users expedite the task at hand**
|
|
253
|
+
>
|
|
254
|
+
> - ex: Pre-populated responses in a chat window
|
|
255
|
+
> - ex: Suggested search queries
|
|
256
|
+
|
|
257
|
+
When not to use
|
|
258
|
+
|
|
259
|
+
> [!CAUTION]
|
|
260
|
+
>
|
|
261
|
+
> **Long sentences**
|
|
262
|
+
>
|
|
263
|
+
> - Use a word or short phrase only
|
|
264
|
+
|
|
265
|
+
Layout and placement
|
|
266
|
+
|
|
267
|
+
Suggestion chips should be placed in close proximity to where the user takes action – generally directly above or below.
|
|
268
|
+
|
|
269
|
+
_usage\_suggestion\_layout\_01-ex_
|
|
270
|
+
|
|
271
|
+
Variants
|
|
272
|
+
|
|
273
|
+
We recommend using neutral colors such as **default** or **primary**, for suggestion chips. Additionally, avoid using the small size for suggestion chips.
|
|
274
|
+
|
|
275
|
+
- **Don't:** Don’t use semantic colors or other non-neutral colors for suggestion chips.
|
|
276
|
+
- **Don't:** Don’t use the small size for suggestion chips, especially on mobile breakpoints.
|
|
277
|
+
|
|
278
|
+
---
|
|
279
|
+
|
|
280
|
+
## Behavior
|
|
281
|
+
|
|
282
|
+
### Static
|
|
283
|
+
|
|
284
|
+
By default, chips are static, and cannot be interacted with by the user. This allows chips to act as tags – visual labels that are used to categorize content. See the [Tag chips](https://design.candescent.com/docs/components/chip/content.md) section for details.
|
|
285
|
+
|
|
286
|
+
### Clickable
|
|
287
|
+
|
|
288
|
+
Chips can also be clickable. Clickable chips are interactive in a similar way to other button components.
|
|
289
|
+
|
|
290
|
+
- **Interaction State: resting (default)**
|
|
291
|
+
|
|
292
|
+
Default state. User is not interacting with the chip.
|
|
293
|
+
- **Interaction State: hover**
|
|
294
|
+
|
|
295
|
+
When the user’s cursor is hovering over the chip.
|
|
296
|
+
- **Interaction State: focus**
|
|
297
|
+
|
|
298
|
+
When a keyboard user is focused on the chip using tab navigation controls.
|
|
299
|
+
|
|
300
|
+
When the chip is focused, pressing Space or Enter should trigger the same action as a click. Pressing Esc will blur (unfocus) the chip.
|
|
301
|
+
|
|
302
|
+
Deletable
|
|
303
|
+
|
|
304
|
+
Chips can also be deletable. Deletable chips should display a delete icon in the `Chip.TrailingIcon` slot of the component. Clicking this icon should delete, remove, or clear the chip.
|
|
305
|
+
|
|
306
|
+
- **Interaction State: resting (default)**
|
|
307
|
+
|
|
308
|
+
Default state. User is not interacting with the chip.
|
|
309
|
+
- **Interaction State: hover**
|
|
310
|
+
|
|
311
|
+
When the user’s cursor is hovering over the delete button within the chip.
|
|
312
|
+
- **Interaction State: focus**
|
|
313
|
+
|
|
314
|
+
When a keyboard user is focused on the chip using tab navigation controls.
|
|
315
|
+
|
|
316
|
+
Even if the chip is not clickable, it should still be focusable in the tab order. When the chip is focused, pressing Backspace or Delete should trigger the same action as clicking the delete icon.
|
|
317
|
+
|
|
318
|
+
### Clickable and deletable
|
|
319
|
+
|
|
320
|
+
A chip can be both clickable and deletable.
|
|
321
|
+
|
|
322
|
+
- **Interaction State: resting (default)**
|
|
323
|
+
|
|
324
|
+
Default state. User is not interacting with the chip.
|
|
325
|
+
- **Interaction State: hover**
|
|
326
|
+
|
|
327
|
+
When the user’s cursor is hovering over the chip.
|
|
328
|
+
- **Interaction State: focus**
|
|
329
|
+
|
|
330
|
+
When a keyboard user is focused on the chip using tab navigation controls.
|
|
331
|
+
|
|
332
|
+
### Disabled
|
|
333
|
+
|
|
334
|
+
Chips can be disabled, which prevents the user from clicking on or interacting with the chip. Using disabled chips can cause accessibility issues so try and avoid them, as they often create more problems than they solve. Keep chips active and use clear error messaging to guide users whenever possible. Use disabled chips only in rare edge cases.
|
|
335
|
+
|
|
336
|
+
- **isDisabled: true**
|
|
337
|
+
|
|
338
|
+
The user cannot interact with the chip (or the delete button) in this state.
|
|
339
|
+
|
|
340
|
+
### Keyboard controls
|
|
341
|
+
|
|
342
|
+
Like other clickable and interactive components, users should be able to interact with chips using keyboard controls.
|
|
343
|
+
|
|
344
|
+
#### Moving focus
|
|
345
|
+
|
|
346
|
+
Chips that are clickable and/or deletable should be placed in the tab order. Users should be able to move between them using Tab and Shift + Tab.
|
|
347
|
+
|
|
348
|
+
_behavior\_menu\_01-ex_
|
|
349
|
+
|
|
350
|
+
#### **Clicking**
|
|
351
|
+
|
|
352
|
+
When the user is focused on a clickable chip, pressing Space or Enter should trigger the same action as a click.
|
|
353
|
+
|
|
354
|
+
_behavior\_menu\_02-ex_
|
|
355
|
+
|
|
356
|
+
#### **Deleting**
|
|
357
|
+
|
|
358
|
+
When the user is focused on a deletable chip (even if it is not clickable), pressing Backspace or Delete should trigger the same action as clicking the delete icon.
|
|
359
|
+
|
|
360
|
+
_behavior\_menu\_03-ex_
|
|
361
|
+
|
|
362
|
+
#### **Unfocusing**
|
|
363
|
+
|
|
364
|
+
When the user is focused on chip, pressing `Esc` will unfocus (or blur) the chip.
|
|
365
|
+
|
|
366
|
+
_behavior\_menu\_04-ex_
|
|
367
|
+
|
|
368
|
+
## Content
|
|
369
|
+
|
|
370
|
+
## Writing label text
|
|
371
|
+
|
|
372
|
+
The label text of a chip should help the user understanding the meaning of the chip at a quick glance. Since the width of the chip is determined by the length of the text, labels should be short and direct.
|
|
373
|
+
|
|
374
|
+
Use the following guidelines when writing button labels:
|
|
375
|
+
|
|
376
|
+
- Labels should be short, but their meaning should still be clear.
|
|
377
|
+
- Write labels in sentence case.
|
|
378
|
+
- Limit labels to short phrases, even in suggestion chips.
|
|
379
|
+
|
|
380
|
+
* **Do:** Use short, direct labels that help the user understand the purpose of the chip.
|
|
381
|
+
* **Don't:** Don’t wrap or truncate text within chips. Find a way to write a shorter label if there isn’t enough room.
|
|
382
|
+
|
|
383
|
+
## Choosing an adornment
|
|
384
|
+
|
|
385
|
+
Adornments can be useful for reinforcing the chip’s purpose, and can help the user scan the page more quickly. Make sure that the adornment has a clear **affordance** – the meaning of the icon or avatar should be easily understood, and reinforce the meaning conveyed by the chip’s label and color.
|
|
386
|
+
|
|
387
|
+
Our specific guidelines for adornments vary for each type of chip.
|
|
388
|
+
|
|
389
|
+
Tag chips
|
|
390
|
+
|
|
391
|
+
Adornments are commonly used in tag chips. Icons are especially useful for adding a useful symbol to categories, or reinforcing the meaning of a chip using a semantic color (error, warning, info, or success).
|
|
392
|
+
|
|
393
|
+
However, keep in mind that adornments should help the user scan the page more quickly, and not add unnecessary visual clutter.
|
|
394
|
+
|
|
395
|
+
- **Do:** If the label text describes the meaning of the chip (in this case, the trend direction), then the icon is just a recommended addition.
|
|
396
|
+
- **Do:** If the label text does not describe the meaning on its own, an icon is required to reinforce the color.
|
|
397
|
+
- **Don't:** Don’t convey the meaning of the chip just using color. This does not meet accessibility requirements.
|
|
398
|
+
|
|
399
|
+
### Suggestion chip
|
|
400
|
+
|
|
401
|
+
We do not recommend using adornments for suggestion chips. Keep the focus on the suggested keywords or phrases.
|
|
402
|
+
|
|
403
|
+
- **Do:** Keep suggestion chips clean and focused on text-only labels. Simple, clear wording helps users quickly scan options and understand what action to take without added visual noise.
|
|
404
|
+
- **Don't:** Avoid adding unnecessary icons to suggestion chips. Extra visuals can create clutter and distract from the label, making it harder for users to quickly understand and choose an option.
|
|
405
|
+
|
|
406
|
+
### Filter chip
|
|
407
|
+
|
|
408
|
+
Adornments can be used in filter chips, but make sure that they do not conflict with the active state’s checkmark icon.
|
|
409
|
+
|
|
410
|
+
- **Do:** If the filter chips use icons, change the icon to a checkmark when the chip is selected.
|
|
411
|
+
- **Don't:** If the filter chips use icons, just changing the color is not enough to meet accessibility requirements. Also, don’t add a checkmark icon next to the other icon.
|
|
412
|
+
|
|
413
|
+
### **Input chip**
|
|
414
|
+
|
|
415
|
+
Adornments are occasionally used in input chips. Avatars are especially useful for showing profile photos when selecting users or contacts. When using avatars in input chips, make sure that there is a fallback for users who do not have a profile photo.
|
|
416
|
+
|
|
417
|
+
- **Do:** Use avatars for profile photos. If a user does not have a photo, use their initials as a fallback.
|
|
418
|
+
- **Don't:** Don’t force the avatar to be a photo. There must be a fallback for users without a profile photo.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Color Area (https://design.candescent.com/docs/components/color-area)
|
|
2
|
+
|
|
3
|
+
Resources: [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/inputs-colorarea--default)
|
|
4
|
+
|
|
5
|
+
`ColorArea` selects saturation horizontally and brightness vertically.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ColorArea, parseColor } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from 'react';
|
|
15
|
+
import { ColorArea, parseColor, type Color } from '@cdx-ui/components';
|
|
16
|
+
|
|
17
|
+
function requiredColor(value: string): Color {
|
|
18
|
+
const color = parseColor(value);
|
|
19
|
+
if (!color) {
|
|
20
|
+
throw new Error(`Expected ${value} to parse`);
|
|
21
|
+
}
|
|
22
|
+
return color;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default function ColorAreaBasicDemo() {
|
|
26
|
+
const [value, setValue] = useState(requiredColor('#2F6FED'));
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<ColorArea value={value} onValueChange={setValue} accessibilityLabel="Brand color">
|
|
30
|
+
<ColorArea.Thumb />
|
|
31
|
+
</ColorArea>
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## API
|
|
37
|
+
|
|
38
|
+
### ColorArea
|
|
39
|
+
|
|
40
|
+
Owns standalone color state or reads the shared value when nested in `ColorPicker`.
|
|
41
|
+
|
|
42
|
+
| Prop | Type | Default | Description |
|
|
43
|
+
| --- | --- | --- | --- |
|
|
44
|
+
| `className?` | `string` | — | — |
|
|
45
|
+
| `children?` | `ReactNode` | — | — |
|
|
46
|
+
| `asChild?` | `boolean` | — | — |
|
|
47
|
+
| `value?` | `Color` | — | Current controlled color. |
|
|
48
|
+
| `defaultValue?` | `Color` | — | Initial color for uncontrolled usage. |
|
|
49
|
+
| `onValueChange?` | `((value: Color) => void)` | — | Called while either color channel changes. |
|
|
50
|
+
| `onValueChangeComplete?` | `((value: Color) => void)` | — | Called when a pointer, keyboard, or screen reader interaction completes. |
|
|
51
|
+
| `colorSpace?` | `'hsb'` | ``'hsb'`` | Color space represented by the area. |
|
|
52
|
+
| `xChannel?` | `'saturation'` | ``'saturation'`` | Horizontal channel. |
|
|
53
|
+
| `yChannel?` | `'brightness'` | ``'brightness'`` | Vertical channel. |
|
|
54
|
+
| `step?` | `number` | ``1`` | Arrow-key and screen-reader increment. |
|
|
55
|
+
| `pageStep?` | `number` | ``10`` | Shift-arrow and page-key increment. |
|
|
56
|
+
| `isRTL?` | `boolean` | — | Overrides the platform layout direction for horizontal interaction. |
|
|
57
|
+
| `isDisabled?` | `boolean` | ``false`` | Disables pointer, keyboard, and screen reader interaction. |
|
|
58
|
+
|
|
59
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
60
|
+
|
|
61
|
+
## Sub-components
|
|
62
|
+
|
|
63
|
+
### ColorArea.Thumb
|
|
64
|
+
|
|
65
|
+
Displays the current color and exposes the two-dimensional slider interaction.
|
|
66
|
+
|
|
67
|
+
| Prop | Type | Default | Description |
|
|
68
|
+
| --- | --- | --- | --- |
|
|
69
|
+
| `className?` | `string` | — | — |
|
|
70
|
+
| `children?` | `ReactNode` | — | — |
|
|
71
|
+
| `asChild?` | `boolean` | — | — |
|
|
72
|
+
|
|
73
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
74
|
+
|
|
75
|
+
## Anatomy
|
|
76
|
+
|
|
77
|
+
| `data-slot` | Element |
|
|
78
|
+
| ------------------ | ------------------------- |
|
|
79
|
+
| `color-area` | Gradient interaction area |
|
|
80
|
+
| `color-area-thumb` | Current color position |
|
|
81
|
+
|
|
82
|
+
## Accessibility
|
|
83
|
+
|
|
84
|
+
Give the area an accessible label. Keyboard users adjust saturation with horizontal arrows and brightness with vertical arrows; native screen readers expose each channel as an adjustable control.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Color Field (https://design.candescent.com/docs/components/color-field)
|
|
2
|
+
|
|
3
|
+
Resources: [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/inputs-colorfield--default)
|
|
4
|
+
|
|
5
|
+
`ColorField` parses full hex values or edits a single RGB or HSL channel.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { ColorField, ColorSwatch, Field, parseColor } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
Compose `Field` for the visible label and place an optional swatch in `ColorField.Slot`.
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { useState } from 'react';
|
|
17
|
+
import { ColorField, ColorSwatch, Field, parseColor, type Color } from '@cdx-ui/components';
|
|
18
|
+
|
|
19
|
+
function requiredColor(value: string): Color {
|
|
20
|
+
const color = parseColor(value);
|
|
21
|
+
if (!color) {
|
|
22
|
+
throw new Error(`Expected ${value} to parse`);
|
|
23
|
+
}
|
|
24
|
+
return color;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default function ColorFieldBasicDemo() {
|
|
28
|
+
const [value, setValue] = useState(requiredColor('#2F6FED'));
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Field name="brandColor" className="w-full max-w-xs">
|
|
32
|
+
<Field.Label>Brand color</Field.Label>
|
|
33
|
+
<ColorField value={value} onValueChange={setValue}>
|
|
34
|
+
<ColorField.Group>
|
|
35
|
+
<ColorField.Slot position="leading">
|
|
36
|
+
<ColorSwatch color={value} size="xs" />
|
|
37
|
+
</ColorField.Slot>
|
|
38
|
+
<ColorField.Input />
|
|
39
|
+
</ColorField.Group>
|
|
40
|
+
</ColorField>
|
|
41
|
+
</Field>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## API
|
|
47
|
+
|
|
48
|
+
### ColorField
|
|
49
|
+
|
|
50
|
+
Owns standalone text and color state or edits the shared value when nested in `ColorPicker`.
|
|
51
|
+
|
|
52
|
+
| Prop | Type | Default | Description |
|
|
53
|
+
| --- | --- | --- | --- |
|
|
54
|
+
| `className?` | `string` | — | — |
|
|
55
|
+
| `children?` | `ReactNode` | — | — |
|
|
56
|
+
| `variant?` | `'outline' \| null` | — | — |
|
|
57
|
+
| `size?` | `'default' \| 'small' \| null` | — | — |
|
|
58
|
+
| `value?` | `Color` | — | — |
|
|
59
|
+
| `defaultValue?` | `Color` | — | — |
|
|
60
|
+
| `onValueChange?` | `((value: Color) => void)` | — | — |
|
|
61
|
+
| `isDisabled?` | `boolean` | — | — |
|
|
62
|
+
| `isReadOnly?` | `boolean` | — | — |
|
|
63
|
+
| `isInvalid?` | `boolean` | — | — |
|
|
64
|
+
| `isRequired?` | `boolean` | — | — |
|
|
65
|
+
| `colorSpace?` | `'rgb' \| 'hsl'` | — | — |
|
|
66
|
+
| `channel?` | `'red' \| 'green' \| 'blue' \| 'hue' \| 'saturation' \| 'lightness'` | — | — |
|
|
67
|
+
| `asChild?` | `boolean` | — | — |
|
|
68
|
+
| `fullWidth?` | `boolean` | — | — |
|
|
69
|
+
|
|
70
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
71
|
+
|
|
72
|
+
## Sub-components
|
|
73
|
+
|
|
74
|
+
### ColorField.Group
|
|
75
|
+
|
|
76
|
+
Provides the styled input shell and optional slots.
|
|
77
|
+
|
|
78
|
+
| Prop | Type | Default | Description |
|
|
79
|
+
| --- | --- | --- | --- |
|
|
80
|
+
| `className?` | `string` | — | — |
|
|
81
|
+
| `children?` | `ReactNode` | — | — |
|
|
82
|
+
| `variant?` | `'outline' \| null` | — | — |
|
|
83
|
+
| `size?` | `'default' \| 'small' \| null` | — | — |
|
|
84
|
+
| `asChild?` | `boolean` | — | — |
|
|
85
|
+
| `fullWidth?` | `boolean` | — | — |
|
|
86
|
+
|
|
87
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
88
|
+
|
|
89
|
+
### ColorField.Input
|
|
90
|
+
|
|
91
|
+
The editable text input. Units such as `°` and `%` are part of channel text.
|
|
92
|
+
|
|
93
|
+
| Prop | Type | Default | Description |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `className?` | `string` | — | — |
|
|
96
|
+
| `children?` | `ReactNode` | — | — |
|
|
97
|
+
| `type?` | `'text' \| 'password' \| 'file'` | `'text'` | — |
|
|
98
|
+
| `disabled?` | `boolean` | — | — |
|
|
99
|
+
| `isDisabled?` | `boolean` | — | — |
|
|
100
|
+
| `isInvalid?` | `boolean` | — | — |
|
|
101
|
+
| `isReadOnly?` | `boolean` | — | — |
|
|
102
|
+
| `isRequired?` | `boolean` | — | — |
|
|
103
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default host. The primitive merges its wired behavior (focus/blur, ARIA props, refs) onto the child. When set, the `type="file"` web branch is bypassed. |
|
|
104
|
+
| `placeholderTextColorClassName?` | `string` | — | — |
|
|
105
|
+
|
|
106
|
+
Inherits all [`TextInputProps`](https://reactnative.dev/docs/textinput#props).
|
|
107
|
+
|
|
108
|
+
### ColorField.Slot
|
|
109
|
+
|
|
110
|
+
A leading or trailing layout slot for a swatch or other adornment.
|
|
111
|
+
|
|
112
|
+
| Prop | Type | Default | Description |
|
|
113
|
+
| --- | --- | --- | --- |
|
|
114
|
+
| `className?` | `string` | — | — |
|
|
115
|
+
| `children?` | `ReactNode` | — | — |
|
|
116
|
+
| `asChild?` | `boolean` | — | — |
|
|
117
|
+
| `position?` | `'leading' \| 'trailing'` | — | — |
|
|
118
|
+
|
|
119
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
120
|
+
|
|
121
|
+
## Anatomy
|
|
122
|
+
|
|
123
|
+
| `data-slot` | Element |
|
|
124
|
+
| ------------------- | -------------- |
|
|
125
|
+
| `color-field` | Root container |
|
|
126
|
+
| `color-field-group` | Input shell |
|
|
127
|
+
| `color-field-input` | Editable input |
|
|
128
|
+
| `color-field-slot` | Adornment slot |
|
|
129
|
+
|
|
130
|
+
## Accessibility
|
|
131
|
+
|
|
132
|
+
Compose `ColorField` inside `Field` to associate a visible label and validation message with the input. Invalid mid-edit text remains local and does not replace the current color.
|