@cdx-ui/components 0.2.3 → 0.2.4
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 +235 -0
- package/docs/components/bottom-sheet/content.md +351 -0
- package/docs/components/bottom-sheet/design.md +249 -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 +416 -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 +86 -0
- package/docs/components/color-field/content.md +134 -0
- package/docs/components/color-picker/content.md +208 -0
- package/docs/components/color-slider/content.md +120 -0
- package/docs/components/color-swatch/content.md +64 -0
- package/docs/components/color-swatch-picker/content.md +126 -0
- package/docs/components/content.md +97 -0
- package/docs/components/currency-input/content.md +205 -0
- package/docs/components/data-grid/content.md +522 -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 +436 -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 +281 -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 +1247 -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 +309 -0
- package/docs/components/scoped-theme/content.md +47 -0
- package/docs/components/scroll-shadow/content.md +686 -0
- package/docs/components/select/content.md +400 -0
- package/docs/components/select/design.md +301 -0
- package/docs/components/skeleton/content.md +103 -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 +292 -0
- package/docs/components/text/content.md +142 -0
- package/docs/components/textarea/content.md +222 -0
- package/docs/components/tile/content.md +703 -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 +193 -0
- package/docs/llms.txt +193 -0
- package/docs/patterns/account-management/content.md +75 -0
- package/docs/patterns/authentication/content.md +52 -0
- package/docs/patterns/content.md +10 -0
- package/docs/patterns/dashboard/content.md +39 -0
- package/docs/patterns/empty-states/content.md +31 -0
- package/docs/patterns/forms/content.md +109 -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/content.md +64 -0
- 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/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/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/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/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/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/figma/ListItem.SectionHeader.figma.d.ts.map +1 -1
- package/package.json +8 -6
- 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/Tabs/index.tsx +25 -35
- package/src/components/Tabs/styles.ts +0 -9
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
# Carousel (https://design.candescent.com/docs/components/carousel)
|
|
2
|
+
|
|
3
|
+
Resources: [Figma](https://www.figma.com/design/0lEVMVlLj8ZS4fgItr3pmd/%E2%AD%90-Forge-DS--Components?node-id=11619-607), [Storybook](https://victorious-wave-0daadf00f.6.azurestaticapps.net/?path=/story/surfaces-carousel--default)
|
|
4
|
+
|
|
5
|
+
A swipeable carousel built on [`react-native-reanimated-carousel`](https://rn-carousel.dev). Compose with `Carousel.Pagination` for dot indicators, `Carousel.PrevButton` / `Carousel.NextButton` for optional ghost icon navigation, or use `useCarousel()` for sibling composition and imperative control.
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import { Carousel, useCarousel } from '@cdx-ui/components';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { Carousel } from '@cdx-ui/components';
|
|
15
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
16
|
+
|
|
17
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
18
|
+
// Carousel is still open.
|
|
19
|
+
export default function CarouselBasicDemo() {
|
|
20
|
+
return (
|
|
21
|
+
<Carousel
|
|
22
|
+
data={SLIDES}
|
|
23
|
+
style={{ width: 320, height: 220 }}
|
|
24
|
+
loop
|
|
25
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## With pagination
|
|
32
|
+
|
|
33
|
+
Nest `Carousel.Pagination` inside `Carousel` to bind dots to scroll progress via context — no manual wiring required.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { Box, Carousel } from '@cdx-ui/components';
|
|
37
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
38
|
+
|
|
39
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
40
|
+
// Carousel is still open.
|
|
41
|
+
export default function CarouselWithPaginationDemo() {
|
|
42
|
+
return (
|
|
43
|
+
<Box className="w-80 gap-3">
|
|
44
|
+
<Carousel
|
|
45
|
+
data={SLIDES}
|
|
46
|
+
style={{ width: 320, height: 220 }}
|
|
47
|
+
loop
|
|
48
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
49
|
+
>
|
|
50
|
+
<Carousel.Pagination data={SLIDES} />
|
|
51
|
+
</Carousel>
|
|
52
|
+
</Box>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Prev / Next buttons
|
|
58
|
+
|
|
59
|
+
Optional ghost icon prev/next controls mirroring `Carousel.Pagination`'s nested vs sibling wiring. Nest inside `Carousel` for zero-prop controls below the track, or use `useCarousel()` for sibling placement — header row with space between a title and the buttons, or an `HStack` flanking the track.
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { Box, Carousel, Heading, HStack, useCarousel, VStack } from '@cdx-ui/components';
|
|
63
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
64
|
+
|
|
65
|
+
function HeaderRowSample() {
|
|
66
|
+
const { ref, progress } = useCarousel();
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Box className="w-80 gap-3">
|
|
70
|
+
<HStack className="items-center justify-between">
|
|
71
|
+
<Heading size="sm">Featured</Heading>
|
|
72
|
+
<HStack space="sm">
|
|
73
|
+
<Carousel.PrevButton
|
|
74
|
+
itemCount={SLIDES.length}
|
|
75
|
+
progress={progress}
|
|
76
|
+
carouselRef={ref}
|
|
77
|
+
loop={false}
|
|
78
|
+
/>
|
|
79
|
+
<Carousel.NextButton
|
|
80
|
+
itemCount={SLIDES.length}
|
|
81
|
+
progress={progress}
|
|
82
|
+
carouselRef={ref}
|
|
83
|
+
loop={false}
|
|
84
|
+
/>
|
|
85
|
+
</HStack>
|
|
86
|
+
</HStack>
|
|
87
|
+
<Carousel
|
|
88
|
+
ref={ref}
|
|
89
|
+
data={SLIDES}
|
|
90
|
+
style={{ width: 320, height: 220 }}
|
|
91
|
+
loop={false}
|
|
92
|
+
onProgressChange={progress}
|
|
93
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
94
|
+
/>
|
|
95
|
+
</Box>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function FlankingSample() {
|
|
100
|
+
const { ref, progress } = useCarousel();
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<HStack className="max-w-full items-center justify-center" space="sm">
|
|
104
|
+
<Carousel.PrevButton
|
|
105
|
+
itemCount={SLIDES.length}
|
|
106
|
+
progress={progress}
|
|
107
|
+
carouselRef={ref}
|
|
108
|
+
loop={false}
|
|
109
|
+
/>
|
|
110
|
+
<Carousel
|
|
111
|
+
ref={ref}
|
|
112
|
+
data={SLIDES}
|
|
113
|
+
style={{ width: 252, height: 220 }}
|
|
114
|
+
loop={false}
|
|
115
|
+
onProgressChange={progress}
|
|
116
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
117
|
+
/>
|
|
118
|
+
<Carousel.NextButton
|
|
119
|
+
itemCount={SLIDES.length}
|
|
120
|
+
progress={progress}
|
|
121
|
+
carouselRef={ref}
|
|
122
|
+
loop={false}
|
|
123
|
+
/>
|
|
124
|
+
</HStack>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
129
|
+
// Carousel is still open.
|
|
130
|
+
export default function CarouselPrevNextDemo() {
|
|
131
|
+
return (
|
|
132
|
+
<VStack space="4xl" className="items-center">
|
|
133
|
+
<HeaderRowSample />
|
|
134
|
+
<FlankingSample />
|
|
135
|
+
</VStack>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Vertical
|
|
141
|
+
|
|
142
|
+
Set `vertical` to lay items out top-to-bottom instead of left-to-right.
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import { Carousel } from '@cdx-ui/components';
|
|
146
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
147
|
+
|
|
148
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
149
|
+
// Carousel is still open.
|
|
150
|
+
export default function CarouselVerticalDemo() {
|
|
151
|
+
return (
|
|
152
|
+
<Carousel
|
|
153
|
+
data={SLIDES}
|
|
154
|
+
style={{ width: 320, height: 420 }}
|
|
155
|
+
vertical
|
|
156
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Parallax mode
|
|
163
|
+
|
|
164
|
+
One of the library's built-in layout modes — adjacent items scale down and shift, creating a parallax depth effect while scrolling. Configure via `modeConfig`.
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
import { Carousel } from '@cdx-ui/components';
|
|
168
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
169
|
+
|
|
170
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
171
|
+
// Carousel is still open.
|
|
172
|
+
export default function CarouselParallaxDemo() {
|
|
173
|
+
return (
|
|
174
|
+
<Carousel
|
|
175
|
+
data={SLIDES}
|
|
176
|
+
style={{ width: 320, height: 220 }}
|
|
177
|
+
mode="parallax"
|
|
178
|
+
modeConfig={{ parallaxScrollingScale: 0.9, parallaxScrollingOffset: 50 }}
|
|
179
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
180
|
+
/>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Autoplay
|
|
186
|
+
|
|
187
|
+
Set `autoPlay` and `loop` to advance items automatically. Uses the sibling-composition pattern via `useCarousel()` to bind `Carousel.Pagination` outside of `Carousel`.
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
import { Box, Carousel, useCarousel } from '@cdx-ui/components';
|
|
191
|
+
import { CarouselSlide, SLIDES } from './_slides';
|
|
192
|
+
|
|
193
|
+
// Carousel lays out slides from its container size, so the demo sets one. Sizing guidance for
|
|
194
|
+
// Carousel is still open.
|
|
195
|
+
export default function CarouselAutoplayDemo() {
|
|
196
|
+
const { ref, progress } = useCarousel();
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<Box className="w-80 gap-3">
|
|
200
|
+
<Carousel
|
|
201
|
+
ref={ref}
|
|
202
|
+
data={SLIDES}
|
|
203
|
+
style={{ width: 320, height: 220 }}
|
|
204
|
+
loop
|
|
205
|
+
autoPlay
|
|
206
|
+
autoPlayInterval={2000}
|
|
207
|
+
onProgressChange={progress}
|
|
208
|
+
renderItem={({ item }) => <CarouselSlide {...item} />}
|
|
209
|
+
/>
|
|
210
|
+
<Carousel.Pagination data={SLIDES} progress={progress} carouselRef={ref} loop />
|
|
211
|
+
</Box>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## API
|
|
217
|
+
|
|
218
|
+
### Carousel
|
|
219
|
+
|
|
220
|
+
Forge-owned additions on top of the adopted library's props:
|
|
221
|
+
|
|
222
|
+
| Prop | Type | Default | Description |
|
|
223
|
+
| --- | --- | --- | --- |
|
|
224
|
+
| `className?` | `string` | — | — |
|
|
225
|
+
| `children?` | `ReactNode` | — | Rendered inside the carousel's progress-sharing provider — use to compose `Carousel.Pagination`, `Carousel.PrevButton`, and `Carousel.NextButton`. |
|
|
226
|
+
|
|
227
|
+
Also accepts all props from [`react-native-reanimated-carousel`](https://rn-carousel.dev/props), including:
|
|
228
|
+
|
|
229
|
+
| Prop | Type | Default | Description |
|
|
230
|
+
| ------------------ | ------------------------------------------------------------------------------------- | ------- | -------------------------------------------------------------------------------- |
|
|
231
|
+
| `data` | `T[]` | — | Items to render |
|
|
232
|
+
| `renderItem` | `(info: { item: T; index: number }) => ReactNode` | — | Renders each item |
|
|
233
|
+
| `loop` | `boolean` | `true` | Loop back to the first item after the last |
|
|
234
|
+
| `autoPlay` | `boolean` | `false` | Automatically advance items |
|
|
235
|
+
| `vertical` | `boolean` | `false` | Lay items out vertically instead of horizontally |
|
|
236
|
+
| `mode` | `'parallax' \| 'horizontal-stack' \| 'vertical-stack'` | — | Built-in layout mode |
|
|
237
|
+
| `onProgressChange` | `((offsetProgress: number, absoluteProgress: number) => void) \| SharedValue<number>` | — | Called on scroll; pass a `SharedValue` to adopt it as the shared progress source |
|
|
238
|
+
|
|
239
|
+
## Sub-components
|
|
240
|
+
|
|
241
|
+
### Carousel.Pagination
|
|
242
|
+
|
|
243
|
+
Dot indicators bound to the carousel's scroll progress. Nest inside `Carousel` to read shared progress via context, or pass `progress` / `carouselRef` explicitly for sibling composition.
|
|
244
|
+
|
|
245
|
+
| Prop | Type | Default | Description |
|
|
246
|
+
| --- | --- | --- | --- |
|
|
247
|
+
| `data` | `unknown[]` | — | Carousel items — must be the same array (or same length) passed to `Carousel`'s `data`. |
|
|
248
|
+
| `horizontal?` | `boolean` | `true (horizontal)` | Lay dots out vertically instead of horizontally. |
|
|
249
|
+
| `renderItem?` | `((item: unknown, index: number) => ReactNode)` | — | Custom content per dot; defaults to the library's built-in dot rendering. |
|
|
250
|
+
| `size?` | `number` | — | Dot size in pixels (both width and height). |
|
|
251
|
+
| `carouselName?` | `string` | — | Included in the default accessibility label, e.g. `"Slide 1 of 4 - {carouselName}"`. |
|
|
252
|
+
| `paginationItemAccessibility?` | `((index: number, length: number) => CarouselPaginationItemAccessibilityOverrides)` | — | Per-dot accessibility overrides. Defaults to `"Slide N of M"` / `"Go to Slide N of M"`. |
|
|
253
|
+
| `className?` | `string` | — | — |
|
|
254
|
+
| `progress?` | `SharedValue<number>` | — | Explicit progress value — only required when rendered outside `<Carousel>` (sibling composition). |
|
|
255
|
+
| `carouselRef?` | `RefObject<ICarouselInstance \| null>` | — | Explicit carousel ref for the default press-to-navigate behavior — only required outside `<Carousel>`. |
|
|
256
|
+
| `loop?` | `boolean` | — | Mirrors `Carousel`'s `loop` prop for shortest-path dot navigation. Defaults to `true` (same as `Carousel`) when omitted outside context. |
|
|
257
|
+
| `onPress?` | `((index: number) => void)` | — | Overrides the default press-to-navigate behavior (`scrollTo({ index })`). |
|
|
258
|
+
|
|
259
|
+
### Carousel.PrevButton / Carousel.NextButton
|
|
260
|
+
|
|
261
|
+
Ghost `IconButton` prev/next controls. Nest inside `Carousel` to read context, or pass `progress`, `carouselRef`, `itemCount`, `loop`, and `vertical` explicitly for sibling composition.
|
|
262
|
+
|
|
263
|
+
| Prop | Type | Default | Description |
|
|
264
|
+
| --- | --- | --- | --- |
|
|
265
|
+
| `itemCount?` | `number` | — | Mirrors `Carousel`'s `data.length` — only required when rendered outside `<Carousel>`. |
|
|
266
|
+
| `progress?` | `SharedValue<number>` | — | Explicit progress value — only required when rendered outside `<Carousel>`. |
|
|
267
|
+
| `carouselRef?` | `RefObject<ICarouselInstance \| null>` | — | Explicit carousel ref — only required outside `<Carousel>` (unless `onPress` is provided). |
|
|
268
|
+
| `loop?` | `boolean` | — | Mirrors `Carousel`'s `loop` prop for bounds-aware disabled state. Defaults to `true` (same as `Carousel`) when omitted outside context. |
|
|
269
|
+
| `vertical?` | `boolean` | — | Mirrors `Carousel`'s `vertical` prop for default icons and accessibility labels. Defaults to `false` when omitted outside context. |
|
|
270
|
+
| `onPress?` | `(() => void)` | — | Overrides the default press-to-navigate behavior (`prev` / `next` with `{ animated: true }`). |
|
|
271
|
+
| `disabled?` | `boolean` | — | Manual override; when omitted, derived from `loop` and `progress` at bounds. |
|
|
272
|
+
| `as?` | `ForgeIcon` | — | Forge icon component — defaults to direction-appropriate chevrons or arrows. |
|
|
273
|
+
| `accessibilityLabel?` | `string` | — | Overrides default `"Previous slide"` / `"Next slide"` (or item labels when `vertical`). |
|
|
274
|
+
| `children?` | `React.ReactNode \| ((state: PressableStateCallbackType) => React.ReactNode)` | — | Either children or a render prop that receives a boolean reflecting whether the component is currently pressed. |
|
|
275
|
+
| `style?` | `StyleProp<ViewStyle> \| ((state: PressableStateCallbackType) => StyleProp<ViewStyle>)` | — | Either view styles or a function that receives a boolean reflecting whether the component is currently pressed and returns view styles. |
|
|
276
|
+
| `hitSlop?` | `number \| Insets \| null` | — | Additional distance outside of this view in which a press is detected. |
|
|
277
|
+
| `id?` | `string` | — | Used to reference react managed views from native code. |
|
|
278
|
+
| `needsOffscreenAlphaCompositing?` | `boolean` | — | Whether this view needs to rendered offscreen and composited with an alpha in order to preserve 100% correct colors and blending behavior. The default (false) falls back to drawing the component and its children with an alpha applied to the paint used to draw each element instead of rendering the full component offscreen and compositing it back with an alpha value. This default may be noticeable and undesired in the case where the View you are setting an opacity on has multiple overlapping elements (e.g. multiple overlapping Views, or text and a background). Rendering offscreen to preserve correct alpha behavior is extremely expensive and hard to debug for non-native developers, which is why it is not turned on by default. If you do need to enable this property for an animation, consider combining it with renderToHardwareTextureAndroid if the view contents are static (i.e. it doesn't need to be redrawn each frame). If that property is enabled, this View will be rendered off-screen once, saved in a hardware texture, and then composited onto the screen with an alpha each frame without having to switch rendering targets on the GPU. |
|
|
279
|
+
| `onLayout?` | `((event: LayoutChangeEvent) => void)` | — | Invoked on mount and layout changes with {nativeEvent: { layout: {x, y, width, height}}}. |
|
|
280
|
+
| `pointerEvents?` | `'box-none' \| 'none' \| 'box-only' \| 'auto'` | — | In the absence of auto property, none is much like CSS's none value. box-none is as if you had applied the CSS class: .box-none { pointer-events: none; } .box-none * { pointer-events: all; } box-only is the equivalent of .box-only { pointer-events: all; } .box-only * { pointer-events: none; } But since pointerEvents does not affect layout/appearance, and we are already deviating from the spec by adding additional modes, we opt to not include pointerEvents on style. On some platforms, we would need to implement it as a className anyways. Using style or not is an implementation detail of the platform. |
|
|
281
|
+
| `removeClippedSubviews?` | `boolean` | — | This is a special performance property exposed by RCTView and is useful for scrolling content when there are many subviews, most of which are offscreen. For this property to be effective, it must be applied to a view that contains many subviews that extend outside its bound. The subviews must also have overflow: hidden, as should the containing view (or one of its superviews). |
|
|
282
|
+
| `testID?` | `string` | — | Used to locate this view in end-to-end tests. |
|
|
283
|
+
| `nativeID?` | `string` | — | Used to reference react managed views from native code. |
|
|
284
|
+
| `collapsable?` | `boolean` | — | Views that are only used to layout their children or otherwise don't draw anything may be automatically removed from the native hierarchy as an optimization. Set this property to false to disable this optimization and ensure that this View exists in the native view hierarchy. |
|
|
285
|
+
| `collapsableChildren?` | `boolean` | — | Setting to false prevents direct children of the view from being removed from the native view hierarchy, similar to the effect of setting `collapsable={false}` on each child. |
|
|
286
|
+
| `className?` | `string` | — | — |
|
|
287
|
+
| `onBlur?` | `((event: NativeSyntheticEvent<TargetedEvent>) => void) \| null` | — | Called after the element loses focus. |
|
|
288
|
+
| `onFocus?` | `((event: NativeSyntheticEvent<TargetedEvent>) => void) \| null` | — | Called after the element is focused. |
|
|
289
|
+
| `renderToHardwareTextureAndroid?` | `boolean` | — | Whether this view should render itself (and all of its children) into a single hardware texture on the GPU. On Android, this is useful for animations and interactions that only modify opacity, rotation, translation, and/or scale: in those cases, the view doesn't have to be redrawn and display lists don't need to be re-executed. The texture can just be re-used and re-composited with different parameters. The downside is that this can use up limited video memory, so this prop should be set back to false at the end of the interaction/animation. |
|
|
290
|
+
| `focusable?` | `boolean` | — | Whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard. |
|
|
291
|
+
| `tabIndex?` | `0 \| -1` | — | Indicates whether this `View` should be focusable with a non-touch input device, eg. receive focus with a hardware keyboard. See https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex for more details. Supports the following values: - 0 (View is focusable) - -1 (View is not focusable) |
|
|
292
|
+
| `shouldRasterizeIOS?` | `boolean` | — | Whether this view should be rendered as a bitmap before compositing. On iOS, this is useful for animations and interactions that do not modify this component's dimensions nor its children; for example, when translating the position of a static view, rasterization allows the renderer to reuse a cached bitmap of a static view and quickly composite it during each frame. Rasterization incurs an off-screen drawing pass and the bitmap consumes memory. Test and measure when using this property. |
|
|
293
|
+
| `isTVSelectable?` | `boolean` | — | *(Apple TV only)* When set to true, this view will be focusable and navigable using the Apple TV remote. |
|
|
294
|
+
| `hasTVPreferredFocus?` | `boolean` | — | **Deprecated.** *(Apple TV only)* May be set to true to force the Apple TV focus engine to move focus to this view. |
|
|
295
|
+
| `tvParallaxShiftDistanceX?` | `number` | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. |
|
|
296
|
+
| `tvParallaxShiftDistanceY?` | `number` | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 2.0. |
|
|
297
|
+
| `tvParallaxTiltAngle?` | `number` | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 0.05. |
|
|
298
|
+
| `tvParallaxMagnification?` | `number` | — | *(Apple TV only)* May be used to change the appearance of the Apple TV parallax effect when this view goes in or out of focus. Defaults to 1.0. |
|
|
299
|
+
| `onStartShouldSetResponder?` | `((event: GestureResponderEvent) => boolean)` | — | Does this view want to become responder on the start of a touch? |
|
|
300
|
+
| `onMoveShouldSetResponder?` | `((event: GestureResponderEvent) => boolean)` | — | Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness? |
|
|
301
|
+
| `onResponderEnd?` | `((event: GestureResponderEvent) => void)` | — | If the View returns true and attempts to become the responder, one of the following will happen: |
|
|
302
|
+
| `onResponderGrant?` | `((event: GestureResponderEvent) => void)` | — | The View is now responding for touch events. This is the time to highlight and show the user what is happening |
|
|
303
|
+
| `onResponderReject?` | `((event: GestureResponderEvent) => void)` | — | Something else is the responder right now and will not release it |
|
|
304
|
+
| `onResponderMove?` | `((event: GestureResponderEvent) => void)` | — | The user is moving their finger |
|
|
305
|
+
| `onResponderRelease?` | `((event: GestureResponderEvent) => void)` | — | Fired at the end of the touch, ie "touchUp" |
|
|
306
|
+
| `onResponderStart?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
307
|
+
| `onResponderTerminationRequest?` | `((event: GestureResponderEvent) => boolean)` | — | Something else wants to become responder. Should this view release the responder? Returning true allows release |
|
|
308
|
+
| `onResponderTerminate?` | `((event: GestureResponderEvent) => void)` | — | The responder has been taken from the View. Might be taken by other views after a call to onResponderTerminationRequest, or might be taken by the OS without asking (happens with control center/ notification center on iOS) |
|
|
309
|
+
| `onStartShouldSetResponderCapture?` | `((event: GestureResponderEvent) => boolean)` | — | onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable. However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true. |
|
|
310
|
+
| `onMoveShouldSetResponderCapture?` | `((event: GestureResponderEvent) => boolean)` | — | onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, where the deepest node is called first. That means that the deepest component will become responder when multiple Views return true for *ShouldSetResponder handlers. This is desirable in most cases, because it makes sure all controls and buttons are usable. However, sometimes a parent will want to make sure that it becomes responder. This can be handled by using the capture phase. Before the responder system bubbles up from the deepest component, it will do a capture phase, firing on*ShouldSetResponderCapture. So if a parent View wants to prevent the child from becoming responder on a touch start, it should have a onStartShouldSetResponderCapture handler which returns true. |
|
|
311
|
+
| `onTouchStart?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
312
|
+
| `onTouchMove?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
313
|
+
| `onTouchEnd?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
314
|
+
| `onTouchCancel?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
315
|
+
| `onTouchEndCapture?` | `((event: GestureResponderEvent) => void)` | — | — |
|
|
316
|
+
| `onPointerEnter?` | `((event: PointerEvent) => void)` | — | — |
|
|
317
|
+
| `onPointerEnterCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
318
|
+
| `onPointerLeave?` | `((event: PointerEvent) => void)` | — | — |
|
|
319
|
+
| `onPointerLeaveCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
320
|
+
| `onPointerMove?` | `((event: PointerEvent) => void)` | — | — |
|
|
321
|
+
| `onPointerMoveCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
322
|
+
| `onPointerCancel?` | `((event: PointerEvent) => void)` | — | — |
|
|
323
|
+
| `onPointerCancelCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
324
|
+
| `onPointerDown?` | `((event: PointerEvent) => void)` | — | — |
|
|
325
|
+
| `onPointerDownCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
326
|
+
| `onPointerUp?` | `((event: PointerEvent) => void)` | — | — |
|
|
327
|
+
| `onPointerUpCapture?` | `((event: PointerEvent) => void)` | — | — |
|
|
328
|
+
| `accessible?` | `boolean` | — | When true, indicates that the view is an accessibility element. By default, all the touchable elements are accessible. |
|
|
329
|
+
| `accessibilityActions?` | `readonly Readonly<{ name: AccessibilityActionName \| string; label?: string; }>[]` | — | Provides an array of custom actions available for accessibility. |
|
|
330
|
+
| `aria-label?` | `string` | — | Alias for accessibilityLabel https://reactnative.dev/docs/view#accessibilitylabel https://github.com/facebook/react-native/issues/34424 |
|
|
331
|
+
| `accessibilityRole?` | `'none' \| 'button' \| 'togglebutton' \| 'link' \| 'search' \| 'image' \| 'keyboardkey' \| 'text' \| 'adjustable' \| 'imagebutton' \| 'header' \| 'summary' \| 'alert' \| 'checkbox' \| 'combobox' \| 'menu' \| 'menubar' \| 'menuitem' \| 'progressbar' \| 'radio' \| 'radiogroup' \| 'scrollbar' \| 'spinbutton' \| 'switch' \| 'tab' \| 'tabbar' \| 'tablist' \| 'timer' \| 'list' \| 'toolbar'` | — | Accessibility Role tells a person using either VoiceOver on iOS or TalkBack on Android the type of element that is focused on. |
|
|
332
|
+
| `accessibilityState?` | `AccessibilityState` | — | Accessibility State tells a person using either VoiceOver on iOS or TalkBack on Android the state of the element currently focused on. |
|
|
333
|
+
| `aria-busy?` | `boolean` | — | alias for accessibilityState see https://reactnative.dev/docs/accessibility#accessibilitystate |
|
|
334
|
+
| `aria-checked?` | `boolean \| "mixed"` | — | — |
|
|
335
|
+
| `aria-disabled?` | `boolean` | — | — |
|
|
336
|
+
| `aria-expanded?` | `boolean` | — | — |
|
|
337
|
+
| `aria-selected?` | `boolean` | — | — |
|
|
338
|
+
| `accessibilityHint?` | `string` | — | An accessibility hint helps users understand what will happen when they perform an action on the accessibility element when that result is not obvious from the accessibility label. |
|
|
339
|
+
| `accessibilityValue?` | `AccessibilityValue` | — | Represents the current value of a component. It can be a textual description of a component's value, or for range-based components, such as sliders and progress bars, it contains range information (minimum, current, and maximum). |
|
|
340
|
+
| `aria-valuemax?` | `number` | — | — |
|
|
341
|
+
| `aria-valuemin?` | `number` | — | — |
|
|
342
|
+
| `aria-valuenow?` | `number` | — | — |
|
|
343
|
+
| `aria-valuetext?` | `string` | — | — |
|
|
344
|
+
| `onAccessibilityAction?` | `((event: AccessibilityActionEvent) => void)` | — | When `accessible` is true, the system will try to invoke this function when the user performs an accessibility custom action. |
|
|
345
|
+
| `importantForAccessibility?` | `'auto' \| 'yes' \| 'no' \| 'no-hide-descendants'` | — | [Android] Controlling if a view fires accessibility events and if it is reported to accessibility services. |
|
|
346
|
+
| `aria-hidden?` | `boolean` | — | A value indicating whether the accessibility elements contained within this accessibility element are hidden. |
|
|
347
|
+
| `aria-modal?` | `boolean` | — | — |
|
|
348
|
+
| `role?` | `'none' \| 'button' \| 'link' \| 'summary' \| 'alert' \| 'checkbox' \| 'combobox' \| 'menu' \| 'menubar' \| 'menuitem' \| 'progressbar' \| 'radio' \| 'radiogroup' \| 'scrollbar' \| 'spinbutton' \| 'switch' \| 'tab' \| 'tablist' \| 'timer' \| 'list' \| 'toolbar' \| 'alertdialog' \| 'application' \| 'article' \| 'banner' \| 'cell' \| 'columnheader' \| 'complementary' \| 'contentinfo' \| 'definition' \| 'dialog' \| 'directory' \| 'document' \| 'feed' \| 'figure' \| 'form' \| 'grid' \| 'group' \| 'heading' \| 'img' \| 'listitem' \| 'log' \| 'main' \| 'marquee' \| 'math' \| 'meter' \| 'navigation' \| 'note' \| 'option' \| 'presentation' \| 'region' \| 'row' \| 'rowgroup' \| 'rowheader' \| 'searchbox' \| 'separator' \| 'slider' \| 'status' \| 'table' \| 'tabpanel' \| 'term' \| 'tooltip' \| 'tree' \| 'treegrid' \| 'treeitem'` | — | Indicates to accessibility services to treat UI component like a specific role. |
|
|
349
|
+
| `accessibilityLabelledBy?` | `string \| string[]` | — | Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props, the text is read aloud. The value should should match the nativeID of the related element. |
|
|
350
|
+
| `aria-labelledby?` | `string` | — | Identifies the element that labels the element it is applied to. When the assistive technology focuses on the component with this props, the text is read aloud. The value should should match the nativeID of the related element. |
|
|
351
|
+
| `accessibilityLiveRegion?` | `'none' \| 'polite' \| 'assertive'` | — | Indicates to accessibility services whether the user should be notified when this view changes. Works for Android API >= 19 only. |
|
|
352
|
+
| `aria-live?` | `'polite' \| 'assertive' \| 'off'` | — | Indicates to accessibility services whether the user should be notified when this view changes. Works for Android API >= 19 only. |
|
|
353
|
+
| `screenReaderFocusable?` | `boolean` | — | Enables the view to be screen reader focusable, not keyboard focusable. |
|
|
354
|
+
| `accessibilityElementsHidden?` | `boolean` | — | A Boolean value indicating whether the accessibility elements contained within this accessibility element are hidden to the screen reader. |
|
|
355
|
+
| `accessibilityViewIsModal?` | `boolean` | — | A Boolean value indicating whether VoiceOver should ignore the elements within views that are siblings of the receiver. |
|
|
356
|
+
| `onAccessibilityEscape?` | `(() => void)` | — | When accessible is true, the system will invoke this function when the user performs the escape gesture (scrub with two fingers). |
|
|
357
|
+
| `onAccessibilityTap?` | `(() => void)` | — | When `accessible` is true, the system will try to invoke this function when the user performs accessibility tap gesture. |
|
|
358
|
+
| `onMagicTap?` | `(() => void)` | — | When accessible is true, the system will invoke this function when the user performs the magic tap gesture. |
|
|
359
|
+
| `accessibilityIgnoresInvertColors?` | `boolean` | — | https://reactnative.dev/docs/accessibility#accessibilityignoresinvertcolorsios |
|
|
360
|
+
| `accessibilityLanguage?` | `string` | — | By using the accessibilityLanguage property, the screen reader will understand which language to use while reading the element's label, value and hint. The provided string value must follow the BCP 47 specification (https://www.rfc-editor.org/info/bcp47). https://reactnative.dev/docs/accessibility#accessibilitylanguage-ios |
|
|
361
|
+
| `accessibilityShowsLargeContentViewer?` | `boolean` | — | A Boolean value that indicates whether or not to show the item in the large content viewer. Available on iOS 13.0+ https://reactnative.dev/docs/accessibility#accessibilityshowslargecontentviewer |
|
|
362
|
+
| `accessibilityLargeContentTitle?` | `string` | — | When `accessibilityShowsLargeContentViewer` is set, this string will be used as title for the large content viewer. https://reactnative.dev/docs/accessibility#accessibilitylargecontenttitle |
|
|
363
|
+
| `accessibilityRespondsToUserInteraction?` | `boolean` | — | Blocks the user from interacting with the component through keyboard while still allowing screen reader to interact with it if this View is still accessible. |
|
|
364
|
+
| `size?` | `'default' \| 'small' \| null` | — | — |
|
|
365
|
+
| `color?` | `'neutral' \| 'action' \| 'danger' \| null` | — | — |
|
|
366
|
+
| `iconClassName?` | `string` | — | Passed through to the underlying `Icon`. |
|
|
367
|
+
| `onHoverIn?` | `((event: MouseEvent) => void) \| null` | — | Called when the hover is activated to provide visual feedback. |
|
|
368
|
+
| `onHoverOut?` | `((event: MouseEvent) => void) \| null` | — | Called when the hover is deactivated to undo visual feedback. |
|
|
369
|
+
| `onPressIn?` | `((event: GestureResponderEvent) => void) \| null` | — | Called when a touch is engaged before `onPress`. |
|
|
370
|
+
| `onPressOut?` | `((event: GestureResponderEvent) => void) \| null` | — | Called when a touch is released before `onPress`. |
|
|
371
|
+
| `onLongPress?` | `((event: GestureResponderEvent) => void) \| null` | — | Called when a long-tap gesture is detected. |
|
|
372
|
+
| `cancelable?` | `boolean \| null` | — | Whether a press gesture can be interrupted by a parent gesture such as a scroll event. Defaults to true. |
|
|
373
|
+
| `delayHoverIn?` | `number \| null` | — | Duration to wait after hover in before calling `onHoverIn`. |
|
|
374
|
+
| `delayHoverOut?` | `number \| null` | — | Duration to wait after hover out before calling `onHoverOut`. |
|
|
375
|
+
| `delayLongPress?` | `number \| null` | — | Duration (in milliseconds) from `onPressIn` before `onLongPress` is called. |
|
|
376
|
+
| `pressRetentionOffset?` | `number \| Insets \| null` | — | Additional distance outside of this view in which a touch is considered a press before `onPressOut` is triggered. |
|
|
377
|
+
| `android_disableSound?` | `boolean \| null` | — | If true, doesn't play system sound on touch. |
|
|
378
|
+
| `android_ripple?` | `PressableAndroidRippleConfig \| null` | — | Enables the Android ripple effect and configures its color. |
|
|
379
|
+
| `testOnly_pressed?` | `boolean \| null` | — | Used only for documentation or testing (e.g. snapshot testing). |
|
|
380
|
+
| `unstable_pressDelay?` | `number` | — | Duration (in milliseconds) to wait after press down before calling onPressIn. |
|
|
381
|
+
|
|
382
|
+
## Hook
|
|
383
|
+
|
|
384
|
+
### useCarousel
|
|
385
|
+
|
|
386
|
+
Convenience hook for sibling composition and imperative navigation. Creates a ref and shared progress value:
|
|
387
|
+
|
|
388
|
+
```tsx
|
|
389
|
+
const { ref, progress, next, prev, scrollTo } = useCarousel(); // optional: useCarousel({ defaultIndex: 2 })
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
| Return | Type | Description |
|
|
393
|
+
| ---------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
|
|
394
|
+
| `ref` | `RefObject<CarouselRef \| null>` | Pass to `Carousel` |
|
|
395
|
+
| `progress` | `SharedValue<number>` | Pass to `Carousel`'s `onProgressChange` and sibling `Carousel.Pagination` / nav button `progress` props |
|
|
396
|
+
| `next` | `(opts?) => void` | Advance to the next item |
|
|
397
|
+
| `prev` | `(opts?) => void` | Go to the previous item |
|
|
398
|
+
| `scrollTo` | `(opts?: { index?, count?, animated? }) => void` | Jump to a specific index |
|
|
399
|
+
|
|
400
|
+
For advanced imperative control, access `ref.current` directly (`CarouselRef`).
|
|
401
|
+
|
|
402
|
+
## Accessibility
|
|
403
|
+
|
|
404
|
+
| Aspect | Behavior |
|
|
405
|
+
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
406
|
+
| Gesture model | Swipe/pan via `react-native-gesture-handler`. The underlying library does not document a dedicated keyboard equivalent for web — arrow-key navigation is not built in. |
|
|
407
|
+
| Pagination dots | Each dot has `accessibilityRole="button"`, a default `accessibilityLabel` of `"Slide N of M"` (plus `carouselName` if provided), a default `accessibilityHint` of `"Go to Slide N of M"` (empty when already selected), and `accessibilityState={{ selected }}`. |
|
|
408
|
+
| Prev / Next buttons | Ghost `IconButton`s with `accessibilityRole="button"` and default labels `"Previous slide"` / `"Next slide"` (horizontal) or `"Previous item"` / `"Next item"` (vertical). `accessibilityState={{ disabled }}` reflects bounds when `loop={false}`. |
|
|
409
|
+
| Overrides | Per-dot via `paginationItemAccessibility`. Nav labels via `accessibilityLabel`; icons via `as`. |
|
|
410
|
+
| Autoplay | Does not pause automatically for reduced-motion preferences — out of scope for this component. |
|
|
411
|
+
|
|
412
|
+
## Constraints
|
|
413
|
+
|
|
414
|
+
- `Carousel.Pagination` must either be rendered inside `<Carousel>` (reads shared progress and ref via context) or receive explicit `progress` and `carouselRef` props (sibling composition via `useCarousel()`) — otherwise it throws. A custom `onPress` may substitute for `carouselRef`.
|
|
415
|
+
- `Carousel.PrevButton` and `Carousel.NextButton` follow the same nested vs sibling contract as `Carousel.Pagination`, and additionally require `itemCount` when rendered outside `<Carousel>`.
|
|
416
|
+
- When using `defaultIndex` with sibling composition, seed progress via `useCarousel({ defaultIndex })` so pagination highlights the correct initial dot.
|