@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,203 @@
|
|
|
1
|
+
# Alert (https://design.candescent.com/docs/components/alert)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--React-Native-Components?node-id=6665-19536), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/feedback-alert--default)
|
|
4
|
+
|
|
5
|
+
A compound component with sub-components for the icon, title, description, and trailing actions. Renders into the document flow at the consumer's mount point; not an overlay.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Alert } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Alert } from '@cdx-ui/components';
|
|
15
|
+
|
|
16
|
+
export default function AlertBasicDemo() {
|
|
17
|
+
return (
|
|
18
|
+
<Alert>
|
|
19
|
+
<Alert.Icon />
|
|
20
|
+
<Alert.Title>Scheduled maintenance</Alert.Title>
|
|
21
|
+
<Alert.Description>
|
|
22
|
+
The app will be briefly unavailable on Saturday between 2–4 AM.
|
|
23
|
+
</Alert.Description>
|
|
24
|
+
</Alert>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Severities
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { Alert, Box } from '@cdx-ui/components';
|
|
33
|
+
|
|
34
|
+
export default function AlertSeveritiesDemo() {
|
|
35
|
+
return (
|
|
36
|
+
<Box className="gap-3">
|
|
37
|
+
<Alert severity="danger">
|
|
38
|
+
<Alert.Icon />
|
|
39
|
+
<Alert.Title>Danger</Alert.Title>
|
|
40
|
+
<Alert.Description>
|
|
41
|
+
Your account has been locked due to multiple failed sign-in attempts.
|
|
42
|
+
</Alert.Description>
|
|
43
|
+
</Alert>
|
|
44
|
+
<Alert severity="warning">
|
|
45
|
+
<Alert.Icon />
|
|
46
|
+
<Alert.Title>Warning</Alert.Title>
|
|
47
|
+
<Alert.Description>Your identity verification expires in 3 days.</Alert.Description>
|
|
48
|
+
</Alert>
|
|
49
|
+
<Alert severity="success">
|
|
50
|
+
<Alert.Icon />
|
|
51
|
+
<Alert.Title>Success</Alert.Title>
|
|
52
|
+
<Alert.Description>Your direct deposit of $1,200.00 has been received.</Alert.Description>
|
|
53
|
+
</Alert>
|
|
54
|
+
<Alert severity="info">
|
|
55
|
+
<Alert.Icon />
|
|
56
|
+
<Alert.Title>Info</Alert.Title>
|
|
57
|
+
<Alert.Description>
|
|
58
|
+
Scheduled maintenance is planned for this Sunday at midnight.
|
|
59
|
+
</Alert.Description>
|
|
60
|
+
</Alert>
|
|
61
|
+
</Box>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Description only
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
import { Alert } from '@cdx-ui/components';
|
|
70
|
+
|
|
71
|
+
export default function AlertDescriptionOnlyDemo() {
|
|
72
|
+
return (
|
|
73
|
+
<Alert severity="success">
|
|
74
|
+
<Alert.Icon />
|
|
75
|
+
<Alert.Description>Your profile has been updated.</Alert.Description>
|
|
76
|
+
</Alert>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## With actions
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import { Alert, Button, IconButton } from '@cdx-ui/components';
|
|
85
|
+
import { Close } from '@cdx-ui/icons';
|
|
86
|
+
|
|
87
|
+
export default function AlertWithActionsDemo() {
|
|
88
|
+
return (
|
|
89
|
+
<Alert severity="danger">
|
|
90
|
+
<Alert.Icon />
|
|
91
|
+
<Alert.Title>Payment failed</Alert.Title>
|
|
92
|
+
<Alert.Description>We could not charge your card ending in 4242.</Alert.Description>
|
|
93
|
+
<Alert.Actions>
|
|
94
|
+
<Button variant="ghost" size="small">
|
|
95
|
+
<Button.Label>Retry</Button.Label>
|
|
96
|
+
</Button>
|
|
97
|
+
<IconButton variant="ghost" size="small" as={Close} accessibilityLabel="Dismiss" />
|
|
98
|
+
</Alert.Actions>
|
|
99
|
+
</Alert>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Text wrapping
|
|
105
|
+
|
|
106
|
+
```tsx
|
|
107
|
+
import { Alert, Box, Button, IconButton } from '@cdx-ui/components';
|
|
108
|
+
import { Close } from '@cdx-ui/icons';
|
|
109
|
+
|
|
110
|
+
export default function AlertTextWrappingDemo() {
|
|
111
|
+
return (
|
|
112
|
+
<Box className="max-w-xs">
|
|
113
|
+
<Alert severity="danger">
|
|
114
|
+
<Alert.Icon />
|
|
115
|
+
<Alert.Title>An unexpected error occurred during the payment processing flow</Alert.Title>
|
|
116
|
+
<Alert.Description>
|
|
117
|
+
We were unable to complete your transaction because the payment gateway returned an error
|
|
118
|
+
code. Please review your payment details and try again, or contact support if the issue
|
|
119
|
+
persists.
|
|
120
|
+
</Alert.Description>
|
|
121
|
+
<Alert.Actions>
|
|
122
|
+
<Button variant="ghost" size="small">
|
|
123
|
+
<Button.Label>Retry</Button.Label>
|
|
124
|
+
</Button>
|
|
125
|
+
<IconButton variant="ghost" size="small" as={Close} accessibilityLabel="Dismiss" />
|
|
126
|
+
</Alert.Actions>
|
|
127
|
+
</Alert>
|
|
128
|
+
</Box>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## API
|
|
134
|
+
|
|
135
|
+
### Alert
|
|
136
|
+
|
|
137
|
+
| Prop | Type | Default | Description |
|
|
138
|
+
| --- | --- | --- | --- |
|
|
139
|
+
| `className?` | `string` | — | — |
|
|
140
|
+
| `children?` | `React.ReactNode` | — | Sub-components (`Alert.Icon`, `Alert.Title`, `Alert.Description`, `Alert.Actions`) must be rendered as **direct** children — wrapping them in HOCs or `memo()` will break the automatic layout splitting. |
|
|
141
|
+
| `severity?` | `'danger' \| 'warning' \| 'success' \| 'info'` | `'info'` | Severity level that controls background colour, icon, and live-region urgency. |
|
|
142
|
+
| `asChild?` | `boolean` | — | Replace the root element with the consumer's child element via `Slot`. When `true`, children are rendered as-is (no automatic icon/text/actions layout splitting). Severity context is still provided so sub-components receive the correct styles. |
|
|
143
|
+
|
|
144
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
145
|
+
|
|
146
|
+
| Attribute | danger / warning | success / info |
|
|
147
|
+
| ------------------------- | ---------------- | -------------- |
|
|
148
|
+
| `role` | `alert` | `status` |
|
|
149
|
+
| `accessibilityLiveRegion` | `assertive` | `polite` |
|
|
150
|
+
|
|
151
|
+
## Sub-components
|
|
152
|
+
|
|
153
|
+
### Alert.Icon
|
|
154
|
+
|
|
155
|
+
Severity glyph. Auto-renders the appropriate icon for the current severity; override with the `as` prop.
|
|
156
|
+
|
|
157
|
+
| Prop | Type | Default | Description |
|
|
158
|
+
| --- | --- | --- | --- |
|
|
159
|
+
| `className?` | `string` | — | Utility classes for size (`size-*`) and placement, merged after the defaults. |
|
|
160
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
161
|
+
| `filled?` | `boolean` | — | When `true`, renders the filled variant of the icon (if available). Defaults to `false` (outlined). |
|
|
162
|
+
| `size?` | `string \| number` | — | Width and height of the icon, in pixels or any SVG length. The bare icon renders at 24 when omitted. |
|
|
163
|
+
| `data-testid?` | `string` | — | Test identifier forwarded to the rendered SVG. |
|
|
164
|
+
| `as?` | `ForgeIcon` | — | Override the auto-rendered severity icon. Omit to use the default icon for the current severity (EmergencyHome, Warning, CheckCircle, or Info). Not required when `asChild` is set. |
|
|
165
|
+
| `asChild?` | `boolean` | — | — |
|
|
166
|
+
|
|
167
|
+
Inherits all `ForgeIconProps` (react-native-svg `SvgProps` plus `filled` and `size`).
|
|
168
|
+
|
|
169
|
+
### Alert.Title
|
|
170
|
+
|
|
171
|
+
Bold headline text rendered in the severity colour.
|
|
172
|
+
|
|
173
|
+
| Prop | Type | Default | Description |
|
|
174
|
+
| --- | --- | --- | --- |
|
|
175
|
+
| `className?` | `string` | — | — |
|
|
176
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
177
|
+
| `asChild?` | `boolean` | — | — |
|
|
178
|
+
|
|
179
|
+
Inherits all [`TextProps`](https://reactnative.dev/docs/text#props).
|
|
180
|
+
|
|
181
|
+
### Alert.Description
|
|
182
|
+
|
|
183
|
+
Body text rendered in the severity colour.
|
|
184
|
+
|
|
185
|
+
| Prop | Type | Default | Description |
|
|
186
|
+
| --- | --- | --- | --- |
|
|
187
|
+
| `className?` | `string` | — | — |
|
|
188
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
189
|
+
| `asChild?` | `boolean` | — | — |
|
|
190
|
+
|
|
191
|
+
Inherits all [`TextProps`](https://reactnative.dev/docs/text#props).
|
|
192
|
+
|
|
193
|
+
### Alert.Actions
|
|
194
|
+
|
|
195
|
+
Trailing action slot. Auto-injects `color={severity}` on direct `Button`/`IconButton` children unless the consumer already provides a `color` prop.
|
|
196
|
+
|
|
197
|
+
| Prop | Type | Default | Description |
|
|
198
|
+
| --- | --- | --- | --- |
|
|
199
|
+
| `className?` | `string` | — | — |
|
|
200
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
201
|
+
| `asChild?` | `boolean` | — | Replace the wrapper element with the consumer's child via `Slot`. **Note:** when `true`, automatic `color={severity}` injection on direct `Button`/`IconButton` children is bypassed — the consumer must set `color` explicitly. |
|
|
202
|
+
|
|
203
|
+
Inherits all [`ViewProps`](https://reactnative.dev/docs/view#props).
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# Alert Dialog (https://design.candescent.com/docs/components/alert-dialog)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--Components?node-id=4428-496), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/overlays-alertdialog--default)
|
|
4
|
+
|
|
5
|
+
A specialized Dialog with non-dismissible defaults, an `alertdialog` role, and dedicated action and cancel buttons.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { AlertDialog, Button } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
> [!NOTE]
|
|
12
|
+
>
|
|
13
|
+
> **Portal host**
|
|
14
|
+
>
|
|
15
|
+
> `ForgeDesignProvider` mounts the shared portal host automatically. If you do not use the provider,
|
|
16
|
+
> mount one `PortalHost` from `@cdx-ui/primitives` near your app root. On web, to keep the alert
|
|
17
|
+
> dialog inside an embedded surface such as a device preview, wrap that surface in `PortalProvider`
|
|
18
|
+
> and give its `PortalHost` a `container` element inside it; the fixed overlay stays inside only
|
|
19
|
+
> when an ancestor of the container sets a `transform`.
|
|
20
|
+
|
|
21
|
+
## Basic
|
|
22
|
+
|
|
23
|
+
Use an Alert Dialog when the user must confirm or cancel an important operation before continuing.
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { useState } from 'react';
|
|
27
|
+
import { AlertDialog, Button } from '@cdx-ui/components';
|
|
28
|
+
|
|
29
|
+
export default function AlertDialogBasicDemo() {
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<AlertDialog isOpen={open} onOpenChange={setOpen}>
|
|
34
|
+
<AlertDialog.Trigger asChild>
|
|
35
|
+
<Button>
|
|
36
|
+
<Button.Label>Submit wire transfer</Button.Label>
|
|
37
|
+
</Button>
|
|
38
|
+
</AlertDialog.Trigger>
|
|
39
|
+
<AlertDialog.Popup>
|
|
40
|
+
<AlertDialog.Header>
|
|
41
|
+
<AlertDialog.Title>Submit wire transfer?</AlertDialog.Title>
|
|
42
|
+
<AlertDialog.Description>
|
|
43
|
+
This transfer will be sent for processing immediately.
|
|
44
|
+
</AlertDialog.Description>
|
|
45
|
+
</AlertDialog.Header>
|
|
46
|
+
<AlertDialog.Content>
|
|
47
|
+
<AlertDialog.Text>
|
|
48
|
+
Send $2,500.00 from Business Checking to Acme Supplies ending in 0184.
|
|
49
|
+
</AlertDialog.Text>
|
|
50
|
+
</AlertDialog.Content>
|
|
51
|
+
<AlertDialog.Footer>
|
|
52
|
+
<AlertDialog.Cancel>Review again</AlertDialog.Cancel>
|
|
53
|
+
<AlertDialog.Action onPress={() => setOpen(false)}>Submit transfer</AlertDialog.Action>
|
|
54
|
+
</AlertDialog.Footer>
|
|
55
|
+
</AlertDialog.Popup>
|
|
56
|
+
</AlertDialog>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Destructive action
|
|
62
|
+
|
|
63
|
+
Pair a danger title with a danger action when the decision has an irreversible consequence.
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { useState } from 'react';
|
|
67
|
+
import { AlertDialog, Button } from '@cdx-ui/components';
|
|
68
|
+
|
|
69
|
+
export default function AlertDialogDestructiveDemo() {
|
|
70
|
+
const [open, setOpen] = useState(false);
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<AlertDialog isOpen={open} onOpenChange={setOpen}>
|
|
74
|
+
<AlertDialog.Trigger asChild>
|
|
75
|
+
<Button color="danger">
|
|
76
|
+
<Button.Label>Close savings account</Button.Label>
|
|
77
|
+
</Button>
|
|
78
|
+
</AlertDialog.Trigger>
|
|
79
|
+
<AlertDialog.Popup>
|
|
80
|
+
<AlertDialog.Header>
|
|
81
|
+
<AlertDialog.Title severity="danger">Close this savings account?</AlertDialog.Title>
|
|
82
|
+
<AlertDialog.Description>
|
|
83
|
+
This action cannot be undone after the request is processed.
|
|
84
|
+
</AlertDialog.Description>
|
|
85
|
+
</AlertDialog.Header>
|
|
86
|
+
<AlertDialog.Content>
|
|
87
|
+
<AlertDialog.Text>
|
|
88
|
+
The remaining $186.42 balance will be transferred to Everyday Checking, and future
|
|
89
|
+
deposits to this account will be returned.
|
|
90
|
+
</AlertDialog.Text>
|
|
91
|
+
</AlertDialog.Content>
|
|
92
|
+
<AlertDialog.Footer>
|
|
93
|
+
<AlertDialog.Cancel>Keep account</AlertDialog.Cancel>
|
|
94
|
+
<AlertDialog.Action color="danger" onPress={() => setOpen(false)}>
|
|
95
|
+
Close account
|
|
96
|
+
</AlertDialog.Action>
|
|
97
|
+
</AlertDialog.Footer>
|
|
98
|
+
</AlertDialog.Popup>
|
|
99
|
+
</AlertDialog>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Error recovery
|
|
105
|
+
|
|
106
|
+
An Alert Dialog can interrupt a failed workflow with clear recovery and dismissal actions.
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { useState } from 'react';
|
|
110
|
+
import { AlertDialog, Button } from '@cdx-ui/components';
|
|
111
|
+
|
|
112
|
+
export default function AlertDialogErrorRecoveryDemo() {
|
|
113
|
+
const [open, setOpen] = useState(false);
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<AlertDialog isOpen={open} onOpenChange={setOpen}>
|
|
117
|
+
<AlertDialog.Trigger asChild>
|
|
118
|
+
<Button variant="outline" color="danger">
|
|
119
|
+
<Button.Label>Simulate transfer error</Button.Label>
|
|
120
|
+
</Button>
|
|
121
|
+
</AlertDialog.Trigger>
|
|
122
|
+
<AlertDialog.Popup>
|
|
123
|
+
<AlertDialog.Header>
|
|
124
|
+
<AlertDialog.Title severity="danger">Transfer could not be completed</AlertDialog.Title>
|
|
125
|
+
<AlertDialog.Description>No money has left your account.</AlertDialog.Description>
|
|
126
|
+
</AlertDialog.Header>
|
|
127
|
+
<AlertDialog.Content>
|
|
128
|
+
<AlertDialog.Text>
|
|
129
|
+
We could not connect to the receiving bank. Check your connection and try again.
|
|
130
|
+
</AlertDialog.Text>
|
|
131
|
+
</AlertDialog.Content>
|
|
132
|
+
<AlertDialog.Footer>
|
|
133
|
+
<AlertDialog.Cancel>Not now</AlertDialog.Cancel>
|
|
134
|
+
<AlertDialog.Action onPress={() => setOpen(false)}>Try again</AlertDialog.Action>
|
|
135
|
+
</AlertDialog.Footer>
|
|
136
|
+
</AlertDialog.Popup>
|
|
137
|
+
</AlertDialog>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Session timeout
|
|
143
|
+
|
|
144
|
+
Non-dismissible defaults make Alert Dialog appropriate for security decisions that require an explicit response.
|
|
145
|
+
|
|
146
|
+
```tsx
|
|
147
|
+
import { useEffect, useState } from 'react';
|
|
148
|
+
import { AlertDialog, Button, Text } from '@cdx-ui/components';
|
|
149
|
+
|
|
150
|
+
const TIMEOUT_SECONDS = 30;
|
|
151
|
+
|
|
152
|
+
export default function AlertDialogSessionTimeoutDemo() {
|
|
153
|
+
const [open, setOpen] = useState(false);
|
|
154
|
+
const [remaining, setRemaining] = useState(TIMEOUT_SECONDS);
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (!open) {
|
|
158
|
+
setRemaining(TIMEOUT_SECONDS);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const interval = setInterval(() => {
|
|
163
|
+
setRemaining((current) => {
|
|
164
|
+
if (current <= 1) {
|
|
165
|
+
setOpen(false);
|
|
166
|
+
return TIMEOUT_SECONDS;
|
|
167
|
+
}
|
|
168
|
+
return current - 1;
|
|
169
|
+
});
|
|
170
|
+
}, 1000);
|
|
171
|
+
|
|
172
|
+
return () => clearInterval(interval);
|
|
173
|
+
}, [open]);
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<AlertDialog isOpen={open} onOpenChange={setOpen} size="sm">
|
|
177
|
+
<AlertDialog.Trigger asChild>
|
|
178
|
+
<Button variant="outline" color="warning">
|
|
179
|
+
<Button.Label>Simulate session timeout</Button.Label>
|
|
180
|
+
</Button>
|
|
181
|
+
</AlertDialog.Trigger>
|
|
182
|
+
<AlertDialog.Popup>
|
|
183
|
+
<AlertDialog.Header>
|
|
184
|
+
<AlertDialog.Title severity="warning">You will be signed out soon</AlertDialog.Title>
|
|
185
|
+
<AlertDialog.Description>
|
|
186
|
+
For your security, inactive banking sessions expire automatically.
|
|
187
|
+
</AlertDialog.Description>
|
|
188
|
+
</AlertDialog.Header>
|
|
189
|
+
<AlertDialog.Content>
|
|
190
|
+
{/* Interim: `tabular-nums` stops the digits shifting each second. Text has no numeric-figures option yet. */}
|
|
191
|
+
<Text size="xl" weight="semibold" color="warning" className="text-center tabular-nums">
|
|
192
|
+
0:{String(remaining).padStart(2, '0')}
|
|
193
|
+
</Text>
|
|
194
|
+
</AlertDialog.Content>
|
|
195
|
+
<AlertDialog.Footer>
|
|
196
|
+
<AlertDialog.Cancel>Sign out now</AlertDialog.Cancel>
|
|
197
|
+
<AlertDialog.Action onPress={() => setOpen(false)}>Continue session</AlertDialog.Action>
|
|
198
|
+
</AlertDialog.Footer>
|
|
199
|
+
</AlertDialog.Popup>
|
|
200
|
+
</AlertDialog>
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## API
|
|
206
|
+
|
|
207
|
+
### AlertDialog
|
|
208
|
+
|
|
209
|
+
Extends `Dialog` with defaults that require the user to choose an action.
|
|
210
|
+
|
|
211
|
+
| Prop | Type | Default | Description |
|
|
212
|
+
| --- | --- | --- | --- |
|
|
213
|
+
| `className?` | `string` | — | — |
|
|
214
|
+
| `children` | `React.ReactNode` | — | — |
|
|
215
|
+
| `role?` | `'dialog' \| 'alertdialog'` | — | — |
|
|
216
|
+
| `size?` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full' \| null` | — | — |
|
|
217
|
+
| `animation?` | `'disable-all'` | — | Pass `'disable-all'` to turn off enter/exit and swipe animations for the popup and overlay. |
|
|
218
|
+
| `isOpen?` | `boolean` | — | Controlled open state. Use `defaultOpen` for the uncontrolled variant. |
|
|
219
|
+
| `onOpenChange?` | `((open: boolean) => void)` | — | — |
|
|
220
|
+
| `defaultOpen?` | `boolean` | — | — |
|
|
221
|
+
| `closeOnBackdropPress?` | `boolean` | — | — |
|
|
222
|
+
| `closeOnEscKey?` | `boolean` | `true` | Close when Escape is pressed. Web only. When `false`, an open dialog still consumes Escape while topmost, so overlays beneath it stay open. Android's hardware back button dismisses independently of this prop. |
|
|
223
|
+
| `fullBleed?` | `boolean` | `false` | Removes horizontal padding from `Dialog.Content`. |
|
|
224
|
+
|
|
225
|
+
Inherits all [`Dialog` props](https://design.candescent.com/docs/components/dialog/content.md), with these different defaults:
|
|
226
|
+
|
|
227
|
+
| Prop | Alert Dialog default | Dialog default |
|
|
228
|
+
| ---------------------- | -------------------- | -------------- |
|
|
229
|
+
| `role` | `'alertdialog'` | `'dialog'` |
|
|
230
|
+
| `closeOnBackdropPress` | `false` | `true` |
|
|
231
|
+
| `closeOnEscKey` | `false` | `true` |
|
|
232
|
+
|
|
233
|
+
### AlertDialog.Popup
|
|
234
|
+
|
|
235
|
+
Extends `Dialog.Popup` and disables swipe-to-dismiss by default.
|
|
236
|
+
|
|
237
|
+
| Prop | Type | Default | Description |
|
|
238
|
+
| --- | --- | --- | --- |
|
|
239
|
+
| `className?` | `string` | — | — |
|
|
240
|
+
| `children?` | `React.ReactNode` | — | — |
|
|
241
|
+
| `forceMount?` | `boolean` | `false` | Keep the popup mounted while the dialog is closed. |
|
|
242
|
+
| `avoidKeyboard?` | `boolean` | — | Whether the content shifts up to clear the on-screen keyboard (native only). No-op on web. Defaults to `true`. |
|
|
243
|
+
| `keyboardVerticalOffset?` | `number` | — | Distance (in px) between the keyboard and the content when keyboard avoidance is active. Forwarded to the underlying keyboard-avoiding layer on native. Defaults to `0`. |
|
|
244
|
+
| `size?` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full' \| null` | — | — |
|
|
245
|
+
| `disableFullWindowOverlay?` | `boolean` | `false` | On iOS, render in a plain `View` instead of `FullWindowOverlay`. Re-enables the element inspector, but the popup no longer layers above native modals. |
|
|
246
|
+
| `isSwipeable?` | `boolean` | `true` | Allow swipe-down to dismiss. Native only; no effect on web. |
|
|
247
|
+
| `zIndex?` | `number` | — | Stacking order for the portal overlay layer (backdrop + popup panel). Defaults to {@link MODAL_OVERLAY_Z_INDEX} (10000). |
|
|
248
|
+
|
|
249
|
+
Inherits all [`Dialog.Popup` props](https://design.candescent.com/docs/components/dialog/content.md#dialog-popup). `isSwipeable` defaults to `false`.
|
|
250
|
+
|
|
251
|
+
## Actions
|
|
252
|
+
|
|
253
|
+
### AlertDialog.Action
|
|
254
|
+
|
|
255
|
+
Primary confirmation action. Renders a solid Button and **does not close automatically**; close the dialog from `onPress` after the operation succeeds.
|
|
256
|
+
|
|
257
|
+
| Prop | Type | Default | Description |
|
|
258
|
+
| --- | --- | --- | --- |
|
|
259
|
+
| `className?` | `string` | — | Additional Uniwind/Tailwind classes, merged after the button's own styles. |
|
|
260
|
+
| `children?` | `React.ReactNode` | — | Button content — typically `Button.Label`, `Button.Icon`, and/or `Button.Spinner`. |
|
|
261
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default `Pressable` host — merges Button's props onto the child instead of wrapping it (e.g. `<Button asChild><Link /></Button>`). |
|
|
262
|
+
| `color?` | `'action' \| 'danger' \| 'warning' \| 'success' \| 'info'` | `'action'` | Color theme applied to the button surface and content. |
|
|
263
|
+
| `size?` | `'default' \| 'small'` | `'default'` | Height and horizontal padding scale. |
|
|
264
|
+
| `fullWidth?` | `boolean` | `false` | Stretch the button to fill the width of its container. |
|
|
265
|
+
| `isDisabled?` | `boolean` | — | If true, the button will be disabled. |
|
|
266
|
+
|
|
267
|
+
Inherits all [`PressableProps`](https://reactnative.dev/docs/pressable#props) and Forge Button props except `variant`. `color` defaults to `"action"`.
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
<AlertDialog.Action color="danger" onPress={() => setOpen(false)}>
|
|
271
|
+
Close account
|
|
272
|
+
</AlertDialog.Action>
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### AlertDialog.Cancel
|
|
276
|
+
|
|
277
|
+
Secondary action. Renders a ghost Button and automatically closes the Alert Dialog after running the supplied `onPress` handler.
|
|
278
|
+
|
|
279
|
+
| Prop | Type | Default | Description |
|
|
280
|
+
| --- | --- | --- | --- |
|
|
281
|
+
| `className?` | `string` | — | Additional Uniwind/Tailwind classes, merged after the button's own styles. |
|
|
282
|
+
| `children?` | `React.ReactNode` | — | Button content — typically `Button.Label`, `Button.Icon`, and/or `Button.Spinner`. |
|
|
283
|
+
| `asChild?` | `boolean` | — | Render the consumer's child element in place of the default `Pressable` host — merges Button's props onto the child instead of wrapping it (e.g. `<Button asChild><Link /></Button>`). |
|
|
284
|
+
| `color?` | `'action' \| 'danger' \| 'warning' \| 'success' \| 'info'` | `'action'` | Color theme applied to the button surface and content. |
|
|
285
|
+
| `size?` | `'default' \| 'small'` | `'default'` | Height and horizontal padding scale. |
|
|
286
|
+
| `fullWidth?` | `boolean` | `false` | Stretch the button to fill the width of its container. |
|
|
287
|
+
| `isDisabled?` | `boolean` | — | If true, the button will be disabled. |
|
|
288
|
+
|
|
289
|
+
Inherits all [`PressableProps`](https://reactnative.dev/docs/pressable#props) and Forge Button props except `variant`.
|
|
290
|
+
|
|
291
|
+
## Inherited sub-components
|
|
292
|
+
|
|
293
|
+
Alert Dialog re-exports these Dialog sub-components with the same API:
|
|
294
|
+
|
|
295
|
+
- `AlertDialog.Trigger`
|
|
296
|
+
- `AlertDialog.Header`
|
|
297
|
+
- `AlertDialog.Title`
|
|
298
|
+
- `AlertDialog.Description`
|
|
299
|
+
- `AlertDialog.Content`
|
|
300
|
+
- `AlertDialog.Text`
|
|
301
|
+
- `AlertDialog.Footer`
|
|
302
|
+
- `AlertDialog.Close`
|
|
303
|
+
|
|
304
|
+
See the [`Dialog` API](https://design.candescent.com/docs/components/dialog/content.md) for their props. Avoid `AlertDialog.Close` in confirmation flows because it introduces a third dismissal path without an explicit decision.
|
|
305
|
+
|
|
306
|
+
## Accessibility
|
|
307
|
+
|
|
308
|
+
- The popup receives `role="alertdialog"`, `aria-modal`, `aria-labelledby`, and `aria-describedby`.
|
|
309
|
+
- Focus moves into the popup, remains trapped while open, and returns to the trigger after close.
|
|
310
|
+
- Backdrop presses, Escape, and native swipe gestures do not dismiss the Alert Dialog by default. Escape is still consumed while the Alert Dialog is topmost, so a dialog or sheet beneath it stays open.
|
|
311
|
+
- Every Alert Dialog should provide both a clear action and a safe cancel choice unless the workflow has no reversible alternative.
|
|
312
|
+
|
|
313
|
+
## When to use
|
|
314
|
+
|
|
315
|
+
| Use Dialog when… | Use Alert Dialog when… |
|
|
316
|
+
| ------------------------------------------------ | -------------------------------------------------- |
|
|
317
|
+
| Presenting forms, information, or settings | Confirming a destructive or important decision |
|
|
318
|
+
| Dismissal without a decision is acceptable | The user must explicitly confirm or cancel |
|
|
319
|
+
| Backdrop, Escape, or swipe dismissal is expected | Incidental dismissal could cause confusion or risk |
|