@coinbase/cds-mcp-server 8.42.0 → 8.43.2
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/CHANGELOG.md +12 -0
- package/dts/analytics.d.ts +6 -9
- package/dts/index.d.ts +1 -1
- package/dts/server.d.ts +1 -1
- package/dts/setup.d.ts +1 -1
- package/mcp-docs/mobile/components/Banner.txt +1 -1
- package/mcp-docs/mobile/components/Button.txt +2 -2
- package/mcp-docs/mobile/components/Carousel.txt +393 -72
- package/mcp-docs/mobile/components/CellMedia.txt +1 -1
- package/mcp-docs/mobile/components/CheckboxCell.txt +11 -0
- package/mcp-docs/mobile/components/Chip.txt +8 -0
- package/mcp-docs/mobile/components/Combobox.txt +26 -0
- package/mcp-docs/mobile/components/ContentCell.txt +17 -0
- package/mcp-docs/mobile/components/DataCard.txt +11 -0
- package/mcp-docs/mobile/components/DotCount.txt +9 -0
- package/mcp-docs/mobile/components/DotSymbol.txt +1 -1
- package/mcp-docs/mobile/components/Icon.txt +9 -1
- package/mcp-docs/mobile/components/IconButton.txt +1 -1
- package/mcp-docs/mobile/components/ListCell.txt +23 -0
- package/mcp-docs/mobile/components/MediaCard.txt +12 -0
- package/mcp-docs/mobile/components/MessagingCard.txt +12 -0
- package/mcp-docs/mobile/components/PageHeader.txt +10 -0
- package/mcp-docs/mobile/components/ProgressBar.txt +8 -0
- package/mcp-docs/mobile/components/ProgressBarWithFixedLabels.txt +10 -0
- package/mcp-docs/mobile/components/ProgressBarWithFloatLabel.txt +9 -0
- package/mcp-docs/mobile/components/ProgressCircle.txt +12 -0
- package/mcp-docs/mobile/components/RadioCell.txt +11 -0
- package/mcp-docs/mobile/components/RollingNumber.txt +16 -0
- package/mcp-docs/mobile/components/SelectAlpha.txt +26 -0
- package/mcp-docs/mobile/components/SelectChipAlpha.txt +26 -0
- package/mcp-docs/mobile/components/SlideButton.txt +9 -0
- package/mcp-docs/mobile/components/Stepper.txt +13 -0
- package/mcp-docs/mobile/components/TabbedChipsAlpha.txt +8 -0
- package/mcp-docs/mobile/getting-started/styling.txt +6 -2
- package/mcp-docs/web/components/AvatarButton.txt +5 -5
- package/mcp-docs/web/components/Banner.txt +1 -1
- package/mcp-docs/web/components/Box.txt +5 -5
- package/mcp-docs/web/components/Button.txt +7 -7
- package/mcp-docs/web/components/Carousel.txt +358 -62
- package/mcp-docs/web/components/CellMedia.txt +1 -1
- package/mcp-docs/web/components/Checkbox.txt +1 -1
- package/mcp-docs/web/components/CheckboxCell.txt +12 -1
- package/mcp-docs/web/components/Chip.txt +9 -1
- package/mcp-docs/web/components/Combobox.txt +26 -0
- package/mcp-docs/web/components/ContentCard.txt +5 -5
- package/mcp-docs/web/components/ContentCardBody.txt +5 -5
- package/mcp-docs/web/components/ContentCardFooter.txt +5 -5
- package/mcp-docs/web/components/ContentCardHeader.txt +5 -5
- package/mcp-docs/web/components/ContentCell.txt +23 -5
- package/mcp-docs/web/components/DataCard.txt +11 -0
- package/mcp-docs/web/components/DateInput.txt +1 -1
- package/mcp-docs/web/components/DatePicker.txt +1 -1
- package/mcp-docs/web/components/DotCount.txt +9 -0
- package/mcp-docs/web/components/DotSymbol.txt +1 -1
- package/mcp-docs/web/components/Fallback.txt +5 -5
- package/mcp-docs/web/components/Grid.txt +5 -5
- package/mcp-docs/web/components/GridColumn.txt +5 -5
- package/mcp-docs/web/components/HStack.txt +5 -5
- package/mcp-docs/web/components/Icon.txt +9 -1
- package/mcp-docs/web/components/IconButton.txt +6 -6
- package/mcp-docs/web/components/InputChip.txt +1 -1
- package/mcp-docs/web/components/Interactable.txt +5 -5
- package/mcp-docs/web/components/Link.txt +5 -5
- package/mcp-docs/web/components/ListCell.txt +25 -5
- package/mcp-docs/web/components/MediaCard.txt +12 -0
- package/mcp-docs/web/components/MediaChip.txt +1 -1
- package/mcp-docs/web/components/MessagingCard.txt +12 -0
- package/mcp-docs/web/components/MultiContentModule.txt +5 -5
- package/mcp-docs/web/components/NavigationBar.txt +271 -45
- package/mcp-docs/web/components/PageHeader.txt +10 -0
- package/mcp-docs/web/components/Pressable.txt +5 -5
- package/mcp-docs/web/components/ProgressBar.txt +8 -0
- package/mcp-docs/web/components/ProgressBarWithFixedLabels.txt +10 -0
- package/mcp-docs/web/components/ProgressBarWithFloatLabel.txt +9 -0
- package/mcp-docs/web/components/ProgressCircle.txt +10 -0
- package/mcp-docs/web/components/Radio.txt +1 -1
- package/mcp-docs/web/components/RadioCell.txt +12 -1
- package/mcp-docs/web/components/RollingNumber.txt +21 -5
- package/mcp-docs/web/components/Scrubber.txt +10 -0
- package/mcp-docs/web/components/SearchInput.txt +1 -1
- package/mcp-docs/web/components/SelectAlpha.txt +26 -0
- package/mcp-docs/web/components/SelectChip.txt +1 -1
- package/mcp-docs/web/components/SelectChipAlpha.txt +26 -0
- package/mcp-docs/web/components/Sidebar.txt +10 -0
- package/mcp-docs/web/components/SidebarItem.txt +2 -2
- package/mcp-docs/web/components/Spacer.txt +5 -5
- package/mcp-docs/web/components/Stepper.txt +13 -0
- package/mcp-docs/web/components/Switch.txt +1 -1
- package/mcp-docs/web/components/TabbedChipsAlpha.txt +10 -0
- package/mcp-docs/web/components/Text.txt +5 -5
- package/mcp-docs/web/components/TextInput.txt +1 -1
- package/mcp-docs/web/components/TileButton.txt +5 -5
- package/mcp-docs/web/components/VStack.txt +5 -5
- package/mcp-docs/web/getting-started/styling.txt +35 -12
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ import { Carousel } from '@coinbase/cds-web/carousel/Carousel'
|
|
|
10
10
|
|
|
11
11
|
## Examples
|
|
12
12
|
|
|
13
|
-
###
|
|
13
|
+
### Basics
|
|
14
14
|
|
|
15
15
|
Carousels are a great way to showcase a list of items in a compact and engaging way.
|
|
16
16
|
By default, Carousels have navigation and pagination enabled.
|
|
@@ -28,7 +28,9 @@ Images inside of the carousel have `pointer-events` disabled by default.
|
|
|
28
28
|
|
|
29
29
|
```jsx live
|
|
30
30
|
function MyCarousel() {
|
|
31
|
-
|
|
31
|
+
const toast = useToast();
|
|
32
|
+
|
|
33
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
32
34
|
return (
|
|
33
35
|
<ContainedAssetCard
|
|
34
36
|
description={
|
|
@@ -37,6 +39,7 @@ function MyCarousel() {
|
|
|
37
39
|
</Text>
|
|
38
40
|
}
|
|
39
41
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
42
|
+
onClick={onClick}
|
|
40
43
|
subtitle={name}
|
|
41
44
|
title="$0.87"
|
|
42
45
|
/>
|
|
@@ -45,7 +48,8 @@ function MyCarousel() {
|
|
|
45
48
|
return (
|
|
46
49
|
<Box marginX={-3}>
|
|
47
50
|
<Carousel
|
|
48
|
-
|
|
51
|
+
loop
|
|
52
|
+
paginationVariant="dot"
|
|
49
53
|
title="Explore Assets"
|
|
50
54
|
styles={{
|
|
51
55
|
root: { paddingInline: 'var(--space-3)' },
|
|
@@ -54,7 +58,13 @@ function MyCarousel() {
|
|
|
54
58
|
>
|
|
55
59
|
{Object.values(assets).map((asset, index) => (
|
|
56
60
|
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
57
|
-
|
|
61
|
+
{({ isVisible }) => (
|
|
62
|
+
<SquareAssetCard
|
|
63
|
+
imageUrl={asset.imageUrl}
|
|
64
|
+
name={asset.symbol}
|
|
65
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
66
|
+
/>
|
|
67
|
+
)}
|
|
58
68
|
</CarouselItem>
|
|
59
69
|
))}
|
|
60
70
|
</Carousel>
|
|
@@ -98,14 +108,7 @@ function DynamicSizingCarousel() {
|
|
|
98
108
|
}
|
|
99
109
|
function ActionButton({ isVisible, children }) {
|
|
100
110
|
return (
|
|
101
|
-
<Button
|
|
102
|
-
compact
|
|
103
|
-
flush="start"
|
|
104
|
-
numberOfLines={1}
|
|
105
|
-
onClick={NoopFn}
|
|
106
|
-
tabIndex={isVisible ? undefined : -1}
|
|
107
|
-
variant="secondary"
|
|
108
|
-
>
|
|
111
|
+
<Button compact flush="start" numberOfLines={1} onClick={NoopFn} variant="secondary">
|
|
109
112
|
{children}
|
|
110
113
|
</Button>
|
|
111
114
|
);
|
|
@@ -467,13 +470,14 @@ When set to `snap`, upon release the carousel will snap to either the nearest it
|
|
|
467
470
|
|
|
468
471
|
```jsx live
|
|
469
472
|
function DragCarousel() {
|
|
473
|
+
const toast = useToast();
|
|
470
474
|
const dragOptions = [
|
|
471
475
|
{ id: 'snap', label: 'Snap' },
|
|
472
476
|
{ id: 'free', label: 'Free' },
|
|
473
477
|
{ id: 'none', label: 'None' },
|
|
474
478
|
];
|
|
475
479
|
const [drag, setDrag] = useState(dragOptions[0]);
|
|
476
|
-
function SquareAssetCard({ imageUrl, name }) {
|
|
480
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
477
481
|
return (
|
|
478
482
|
<ContainedAssetCard
|
|
479
483
|
description={
|
|
@@ -482,6 +486,7 @@ function DragCarousel() {
|
|
|
482
486
|
</Text>
|
|
483
487
|
}
|
|
484
488
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
489
|
+
onClick={onClick}
|
|
485
490
|
subtitle={name}
|
|
486
491
|
title="$0.87"
|
|
487
492
|
/>
|
|
@@ -508,8 +513,14 @@ function DragCarousel() {
|
|
|
508
513
|
key={drag.id}
|
|
509
514
|
>
|
|
510
515
|
{Object.values(assets).map((asset, index) => (
|
|
511
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
512
|
-
|
|
516
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
517
|
+
{({ isVisible }) => (
|
|
518
|
+
<SquareAssetCard
|
|
519
|
+
imageUrl={asset.imageUrl}
|
|
520
|
+
name={asset.symbol}
|
|
521
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
522
|
+
/>
|
|
523
|
+
)}
|
|
513
524
|
</CarouselItem>
|
|
514
525
|
))}
|
|
515
526
|
</Carousel>
|
|
@@ -527,12 +538,13 @@ When set to `item`, the carousel will snap to the nearest item.
|
|
|
527
538
|
|
|
528
539
|
```jsx live
|
|
529
540
|
function SnapModeCarousel() {
|
|
541
|
+
const toast = useToast();
|
|
530
542
|
const snapModeOptions = [
|
|
531
543
|
{ id: 'page', label: 'Page' },
|
|
532
544
|
{ id: 'item', label: 'Item' },
|
|
533
545
|
];
|
|
534
546
|
const [snapMode, setSnapMode] = useState(snapModeOptions[0]);
|
|
535
|
-
function SquareAssetCard({ imageUrl, name }) {
|
|
547
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
536
548
|
return (
|
|
537
549
|
<ContainedAssetCard
|
|
538
550
|
description={
|
|
@@ -541,6 +553,7 @@ function SnapModeCarousel() {
|
|
|
541
553
|
</Text>
|
|
542
554
|
}
|
|
543
555
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
556
|
+
onClick={onClick}
|
|
544
557
|
subtitle={name}
|
|
545
558
|
title="$0.87"
|
|
546
559
|
/>
|
|
@@ -557,6 +570,7 @@ function SnapModeCarousel() {
|
|
|
557
570
|
<Box marginX={-3}>
|
|
558
571
|
<Carousel
|
|
559
572
|
title="Explore Assets"
|
|
573
|
+
paginationVariant="dot"
|
|
560
574
|
styles={{
|
|
561
575
|
root: { paddingInline: 'var(--space-3)' },
|
|
562
576
|
carousel: { gap: 'var(--space-1)' },
|
|
@@ -565,8 +579,14 @@ function SnapModeCarousel() {
|
|
|
565
579
|
key={snapMode.id}
|
|
566
580
|
>
|
|
567
581
|
{Object.values(assets).map((asset, index) => (
|
|
568
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
569
|
-
|
|
582
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
583
|
+
{({ isVisible }) => (
|
|
584
|
+
<SquareAssetCard
|
|
585
|
+
imageUrl={asset.imageUrl}
|
|
586
|
+
name={asset.symbol}
|
|
587
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
588
|
+
/>
|
|
589
|
+
)}
|
|
570
590
|
</CarouselItem>
|
|
571
591
|
))}
|
|
572
592
|
</Carousel>
|
|
@@ -593,7 +613,8 @@ If you want to have the next item be shown at the edge of the screen, make sure
|
|
|
593
613
|
|
|
594
614
|
```jsx live
|
|
595
615
|
function OverflowCarousel() {
|
|
596
|
-
|
|
616
|
+
const toast = useToast();
|
|
617
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
597
618
|
return (
|
|
598
619
|
<ContainedAssetCard
|
|
599
620
|
description={
|
|
@@ -602,7 +623,7 @@ function OverflowCarousel() {
|
|
|
602
623
|
</Text>
|
|
603
624
|
}
|
|
604
625
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
605
|
-
onClick={
|
|
626
|
+
onClick={onClick}
|
|
606
627
|
subtitle={name}
|
|
607
628
|
title="$0.87"
|
|
608
629
|
/>
|
|
@@ -612,6 +633,7 @@ function OverflowCarousel() {
|
|
|
612
633
|
<Box marginX={-3}>
|
|
613
634
|
<Carousel
|
|
614
635
|
title="Explore Assets"
|
|
636
|
+
paginationVariant="dot"
|
|
615
637
|
snapMode="item"
|
|
616
638
|
styles={{
|
|
617
639
|
root: { paddingInline: 'var(--space-3)' },
|
|
@@ -619,12 +641,12 @@ function OverflowCarousel() {
|
|
|
619
641
|
}}
|
|
620
642
|
>
|
|
621
643
|
{Object.values(assets).map((asset, index) => (
|
|
622
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
644
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
623
645
|
{({ isVisible }) => (
|
|
624
646
|
<SquareAssetCard
|
|
625
|
-
isVisible={isVisible}
|
|
626
647
|
imageUrl={asset.imageUrl}
|
|
627
648
|
name={asset.symbol}
|
|
649
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
628
650
|
/>
|
|
629
651
|
)}
|
|
630
652
|
</CarouselItem>
|
|
@@ -635,19 +657,17 @@ function OverflowCarousel() {
|
|
|
635
657
|
}
|
|
636
658
|
```
|
|
637
659
|
|
|
638
|
-
###
|
|
639
|
-
|
|
640
|
-
Enable infinite looping with the `loop` prop. You must have at least two pages of content to enable looping.
|
|
660
|
+
### Autoplay
|
|
641
661
|
|
|
642
|
-
|
|
662
|
+
Use `autoplay` to allow for automatic page advancement. The default interval is 3 seconds but can be changed with `autoplayInterval`.
|
|
643
663
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
When looping is enabled with snap drag mode, the carousel will snap to the nearest item or page (depending on `snapMode`) after releasing, allowing infinite scrolling in either direction.
|
|
664
|
+
It is recommended to use pagination with autoplay so users know how many pages there are, and you should also set `paginationVariant="dot"` to best indicate the active page and progress.
|
|
647
665
|
|
|
648
666
|
```jsx live
|
|
649
|
-
function
|
|
650
|
-
|
|
667
|
+
function AutoplayCarousel() {
|
|
668
|
+
const toast = useToast();
|
|
669
|
+
|
|
670
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
651
671
|
return (
|
|
652
672
|
<ContainedAssetCard
|
|
653
673
|
description={
|
|
@@ -656,6 +676,7 @@ function LoopingSnapCarousel() {
|
|
|
656
676
|
</Text>
|
|
657
677
|
}
|
|
658
678
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
679
|
+
onClick={onClick}
|
|
659
680
|
subtitle={name}
|
|
660
681
|
title="$0.87"
|
|
661
682
|
/>
|
|
@@ -664,8 +685,10 @@ function LoopingSnapCarousel() {
|
|
|
664
685
|
return (
|
|
665
686
|
<Box marginX={-3}>
|
|
666
687
|
<Carousel
|
|
688
|
+
autoplay
|
|
667
689
|
loop
|
|
668
|
-
|
|
690
|
+
paginationVariant="dot"
|
|
691
|
+
title="Trending Assets"
|
|
669
692
|
styles={{
|
|
670
693
|
root: { paddingInline: 'var(--space-3)' },
|
|
671
694
|
carousel: { gap: 'var(--space-1)' },
|
|
@@ -673,7 +696,13 @@ function LoopingSnapCarousel() {
|
|
|
673
696
|
>
|
|
674
697
|
{Object.values(assets).map((asset) => (
|
|
675
698
|
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
676
|
-
|
|
699
|
+
{({ isVisible }) => (
|
|
700
|
+
<SquareAssetCard
|
|
701
|
+
imageUrl={asset.imageUrl}
|
|
702
|
+
name={asset.symbol}
|
|
703
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
704
|
+
/>
|
|
705
|
+
)}
|
|
677
706
|
</CarouselItem>
|
|
678
707
|
))}
|
|
679
708
|
</Carousel>
|
|
@@ -682,13 +711,14 @@ function LoopingSnapCarousel() {
|
|
|
682
711
|
}
|
|
683
712
|
```
|
|
684
713
|
|
|
685
|
-
|
|
714
|
+
### Looping
|
|
686
715
|
|
|
687
|
-
|
|
716
|
+
Use `loop` to allow for infinite scrolling.
|
|
688
717
|
|
|
689
718
|
```jsx live
|
|
690
|
-
function
|
|
691
|
-
|
|
719
|
+
function LoopingCarousel() {
|
|
720
|
+
const toast = useToast();
|
|
721
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
692
722
|
return (
|
|
693
723
|
<ContainedAssetCard
|
|
694
724
|
description={
|
|
@@ -697,6 +727,7 @@ function LoopingFreeDragCarousel() {
|
|
|
697
727
|
</Text>
|
|
698
728
|
}
|
|
699
729
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
730
|
+
onClick={onClick}
|
|
700
731
|
subtitle={name}
|
|
701
732
|
title="$0.87"
|
|
702
733
|
/>
|
|
@@ -705,10 +736,11 @@ function LoopingFreeDragCarousel() {
|
|
|
705
736
|
return (
|
|
706
737
|
<Box marginX={-3}>
|
|
707
738
|
<Carousel
|
|
739
|
+
autoplay
|
|
708
740
|
loop
|
|
709
|
-
|
|
741
|
+
paginationVariant="dot"
|
|
710
742
|
snapMode="item"
|
|
711
|
-
title="
|
|
743
|
+
title="Infinite Scroll"
|
|
712
744
|
styles={{
|
|
713
745
|
root: { paddingInline: 'var(--space-3)' },
|
|
714
746
|
carousel: { gap: 'var(--space-1)' },
|
|
@@ -716,7 +748,13 @@ function LoopingFreeDragCarousel() {
|
|
|
716
748
|
>
|
|
717
749
|
{Object.values(assets).map((asset) => (
|
|
718
750
|
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
719
|
-
|
|
751
|
+
{({ isVisible }) => (
|
|
752
|
+
<SquareAssetCard
|
|
753
|
+
imageUrl={asset.imageUrl}
|
|
754
|
+
name={asset.symbol}
|
|
755
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
756
|
+
/>
|
|
757
|
+
)}
|
|
720
758
|
</CarouselItem>
|
|
721
759
|
))}
|
|
722
760
|
</Carousel>
|
|
@@ -727,14 +765,14 @@ function LoopingFreeDragCarousel() {
|
|
|
727
765
|
|
|
728
766
|
### Accessibility
|
|
729
767
|
|
|
730
|
-
The carousel is accessible by default.
|
|
768
|
+
The carousel is accessible by default, and works best with interactive elements that can be focused. Users can navigate via keyboard or voiceover and will switch pages as they navigate through the carousel.
|
|
731
769
|
|
|
732
|
-
|
|
770
|
+
Each carousel item should have proper text within the focusable element or you use `accessibilityLabel` or `accessibilityLabelledBy` props to provide a label.
|
|
733
771
|
|
|
734
|
-
|
|
772
|
+
While not recommended, if your carousel has disabled drag, you can use `isVisible` render prop to prevent users from focusing on carousel items that are not visible.
|
|
735
773
|
|
|
736
774
|
```jsx
|
|
737
|
-
<Carousel>
|
|
775
|
+
<Carousel paginationVariant="dot" drag="none">
|
|
738
776
|
<CarouselItem id="btc" accessibilityLabel="Bitcoin">
|
|
739
777
|
<SquareAssetCard imageUrl={assets.btc.imageUrl} name={assets.btc.symbol} />
|
|
740
778
|
</CarouselItem>
|
|
@@ -772,6 +810,28 @@ If you have elements that are focusable, you can use `isVisible` render prop to
|
|
|
772
810
|
</Carousel>
|
|
773
811
|
```
|
|
774
812
|
|
|
813
|
+
#### Autoplay
|
|
814
|
+
|
|
815
|
+
You should note use `hideNavigation` and `autoplay` together, unless you provide an alternative pause mechanism. See [this example](#custom-autoplay-controls) with custom autoplay controls as an example.
|
|
816
|
+
|
|
817
|
+
#### Accessibility Labels
|
|
818
|
+
|
|
819
|
+
The Carousel provides several props to customize accessibility labels for screen reader users
|
|
820
|
+
|
|
821
|
+
```jsx
|
|
822
|
+
<Carousel
|
|
823
|
+
nextPageAccessibilityLabel="Go to next slide"
|
|
824
|
+
previousPageAccessibilityLabel="Go to previous slide"
|
|
825
|
+
paginationAccessibilityLabel={(pageIndex) => `Go to page ${pageIndex + 1}`}
|
|
826
|
+
autoplayAccessibilityLabel="Play/pause carousel"
|
|
827
|
+
pageChangeAccessibilityLabel={(activePageIndex, totalPages) =>
|
|
828
|
+
`Showing page ${activePageIndex + 1} of ${totalPages}`
|
|
829
|
+
}
|
|
830
|
+
>
|
|
831
|
+
...
|
|
832
|
+
</Carousel>
|
|
833
|
+
```
|
|
834
|
+
|
|
775
835
|
### Customization
|
|
776
836
|
|
|
777
837
|
#### Custom Components
|
|
@@ -1005,6 +1065,7 @@ function CustomStylesCarousel() {
|
|
|
1005
1065
|
return (
|
|
1006
1066
|
<Box marginX={-3}>
|
|
1007
1067
|
<Carousel
|
|
1068
|
+
paginationVariant="dot"
|
|
1008
1069
|
styles={{
|
|
1009
1070
|
root: { position: 'relative', paddingInline: 'var(--space-6)' },
|
|
1010
1071
|
carousel: { gap: 'var(--space-6)' },
|
|
@@ -1086,15 +1147,190 @@ function CustomStylesCarousel() {
|
|
|
1086
1147
|
}
|
|
1087
1148
|
```
|
|
1088
1149
|
|
|
1150
|
+
#### Custom Autoplay Controls
|
|
1151
|
+
|
|
1152
|
+
You can use `useCarouselAutoplayContext` inside a custom `PaginationComponent` to build your own controls. This example shows a composed layout with pagination and play/pause on the left, and navigation arrows on the right.
|
|
1153
|
+
|
|
1154
|
+
```jsx live
|
|
1155
|
+
function ComposedAutoplayCarousel() {
|
|
1156
|
+
const carouselRef = useRef(null);
|
|
1157
|
+
|
|
1158
|
+
function CustomPaginationDots({ totalPages, activePageIndex, onClickPage }) {
|
|
1159
|
+
const autoplay = useCarouselAutoplayContext();
|
|
1160
|
+
|
|
1161
|
+
return (
|
|
1162
|
+
<HStack
|
|
1163
|
+
alignItems="center"
|
|
1164
|
+
background="bgSecondary"
|
|
1165
|
+
borderRadius={1000}
|
|
1166
|
+
gap={0.5}
|
|
1167
|
+
paddingX={1.5}
|
|
1168
|
+
style={{ height: 40 }}
|
|
1169
|
+
>
|
|
1170
|
+
{Array.from({ length: totalPages }, (_, index) => {
|
|
1171
|
+
const isActive = index === activePageIndex;
|
|
1172
|
+
const showProgress = isActive && autoplay.isEnabled;
|
|
1173
|
+
|
|
1174
|
+
// Calculate progress from timing info
|
|
1175
|
+
const remainingTime = autoplay.getRemainingTime();
|
|
1176
|
+
const progress = 1 - remainingTime / autoplay.totalTime;
|
|
1177
|
+
const progressDuration = autoplay.isPlaying ? remainingTime / 1000 : 0;
|
|
1178
|
+
|
|
1179
|
+
return (
|
|
1180
|
+
<Pressable
|
|
1181
|
+
key={index}
|
|
1182
|
+
accessibilityLabel={`Go to page ${index + 1}`}
|
|
1183
|
+
background={isActive && !showProgress ? 'fgPrimary' : 'bgTertiary'}
|
|
1184
|
+
borderRadius={1000}
|
|
1185
|
+
borderWidth={0}
|
|
1186
|
+
onClick={() => onClickPage?.(index)}
|
|
1187
|
+
style={{
|
|
1188
|
+
height: 8,
|
|
1189
|
+
width: isActive ? 24 : 8,
|
|
1190
|
+
transition: 'width 0.2s ease',
|
|
1191
|
+
overflow: 'hidden',
|
|
1192
|
+
}}
|
|
1193
|
+
>
|
|
1194
|
+
{showProgress && (
|
|
1195
|
+
<m.div
|
|
1196
|
+
animate={{ width: autoplay.isPlaying ? '100%' : `${progress * 100}%` }}
|
|
1197
|
+
initial={false}
|
|
1198
|
+
transition={{ duration: progressDuration, ease: 'linear' }}
|
|
1199
|
+
style={{
|
|
1200
|
+
height: '100%',
|
|
1201
|
+
background: 'var(--color-fgPrimary)',
|
|
1202
|
+
borderRadius: 'var(--borderRadius-1000)',
|
|
1203
|
+
}}
|
|
1204
|
+
/>
|
|
1205
|
+
)}
|
|
1206
|
+
</Pressable>
|
|
1207
|
+
);
|
|
1208
|
+
})}
|
|
1209
|
+
</HStack>
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
function CustomControls({ totalPages, activePageIndex, onClickPage }) {
|
|
1214
|
+
const autoplay = useCarouselAutoplayContext();
|
|
1215
|
+
|
|
1216
|
+
return (
|
|
1217
|
+
<HStack justifyContent="space-between" paddingY={1}>
|
|
1218
|
+
<HStack gap={1} alignItems="center">
|
|
1219
|
+
<CustomPaginationDots
|
|
1220
|
+
totalPages={totalPages}
|
|
1221
|
+
activePageIndex={activePageIndex}
|
|
1222
|
+
onClickPage={onClickPage}
|
|
1223
|
+
/>
|
|
1224
|
+
<IconButton
|
|
1225
|
+
accessibilityLabel={'Play/Pause Carousel'}
|
|
1226
|
+
name={autoplay.isStopped ? 'play' : 'pause'}
|
|
1227
|
+
onClick={autoplay.toggle}
|
|
1228
|
+
variant="secondary"
|
|
1229
|
+
/>
|
|
1230
|
+
</HStack>
|
|
1231
|
+
<HStack gap={1}>
|
|
1232
|
+
<IconButton
|
|
1233
|
+
accessibilityLabel="Previous"
|
|
1234
|
+
disabled={activePageIndex <= 0}
|
|
1235
|
+
name="caretLeft"
|
|
1236
|
+
onClick={() => carouselRef.current?.goToPage(activePageIndex - 1)}
|
|
1237
|
+
variant="secondary"
|
|
1238
|
+
/>
|
|
1239
|
+
<IconButton
|
|
1240
|
+
accessibilityLabel="Next"
|
|
1241
|
+
disabled={activePageIndex >= totalPages - 1}
|
|
1242
|
+
name="caretRight"
|
|
1243
|
+
onClick={() => carouselRef.current?.goToPage(activePageIndex + 1)}
|
|
1244
|
+
variant="secondary"
|
|
1245
|
+
/>
|
|
1246
|
+
</HStack>
|
|
1247
|
+
</HStack>
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
return (
|
|
1252
|
+
<Box marginX={-3}>
|
|
1253
|
+
<Carousel
|
|
1254
|
+
ref={carouselRef}
|
|
1255
|
+
autoplay
|
|
1256
|
+
loop
|
|
1257
|
+
hideNavigation
|
|
1258
|
+
PaginationComponent={CustomControls}
|
|
1259
|
+
styles={{
|
|
1260
|
+
root: { paddingInline: 'var(--space-3)' },
|
|
1261
|
+
carousel: { gap: 'var(--space-2)' },
|
|
1262
|
+
}}
|
|
1263
|
+
>
|
|
1264
|
+
<CarouselItem id="innovation-1" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1265
|
+
<NudgeCard
|
|
1266
|
+
title="Innovation"
|
|
1267
|
+
description="Cards are a great way to showcase content."
|
|
1268
|
+
pictogram="shield"
|
|
1269
|
+
width="100%"
|
|
1270
|
+
minWidth="0"
|
|
1271
|
+
/>
|
|
1272
|
+
</CarouselItem>
|
|
1273
|
+
<CarouselItem id="innovation-2" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1274
|
+
<NudgeCard
|
|
1275
|
+
title="Innovation"
|
|
1276
|
+
description="Cards are a great way to showcase content."
|
|
1277
|
+
pictogram="security"
|
|
1278
|
+
width="100%"
|
|
1279
|
+
minWidth="0"
|
|
1280
|
+
/>
|
|
1281
|
+
</CarouselItem>
|
|
1282
|
+
<CarouselItem id="innovation-3" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1283
|
+
<NudgeCard
|
|
1284
|
+
title="Innovation"
|
|
1285
|
+
description="Cards are a great way to showcase content."
|
|
1286
|
+
pictogram="institutions"
|
|
1287
|
+
width="100%"
|
|
1288
|
+
minWidth="0"
|
|
1289
|
+
/>
|
|
1290
|
+
</CarouselItem>
|
|
1291
|
+
<CarouselItem id="innovation-4" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1292
|
+
<NudgeCard
|
|
1293
|
+
title="Innovation"
|
|
1294
|
+
description="Cards are a great way to showcase content."
|
|
1295
|
+
pictogram="key"
|
|
1296
|
+
width="100%"
|
|
1297
|
+
minWidth="0"
|
|
1298
|
+
/>
|
|
1299
|
+
</CarouselItem>
|
|
1300
|
+
<CarouselItem id="innovation-5" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1301
|
+
<NudgeCard
|
|
1302
|
+
title="Innovation"
|
|
1303
|
+
description="Cards are a great way to showcase content."
|
|
1304
|
+
pictogram="receipt"
|
|
1305
|
+
width="100%"
|
|
1306
|
+
minWidth="0"
|
|
1307
|
+
/>
|
|
1308
|
+
</CarouselItem>
|
|
1309
|
+
<CarouselItem id="innovation-6" width="calc((100% - 2 * var(--space-2)) / 3)">
|
|
1310
|
+
<NudgeCard
|
|
1311
|
+
title="Innovation"
|
|
1312
|
+
description="Cards are a great way to showcase content."
|
|
1313
|
+
pictogram="worldwide"
|
|
1314
|
+
width="100%"
|
|
1315
|
+
minWidth="0"
|
|
1316
|
+
/>
|
|
1317
|
+
</CarouselItem>
|
|
1318
|
+
</Carousel>
|
|
1319
|
+
</Box>
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
```
|
|
1323
|
+
|
|
1089
1324
|
#### Dynamic Content
|
|
1090
1325
|
|
|
1091
1326
|
You can dynamically add and remove items from the carousel.
|
|
1092
1327
|
|
|
1093
1328
|
```jsx live
|
|
1094
1329
|
function DynamicContentCarousel() {
|
|
1330
|
+
const toast = useToast();
|
|
1095
1331
|
const [items, setItems] = useState(Object.values(assets).slice(0, 3));
|
|
1096
1332
|
|
|
1097
|
-
function SquareAssetCard({ imageUrl, name }) {
|
|
1333
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
1098
1334
|
return (
|
|
1099
1335
|
<ContainedAssetCard
|
|
1100
1336
|
description={
|
|
@@ -1103,6 +1339,7 @@ function DynamicContentCarousel() {
|
|
|
1103
1339
|
</Text>
|
|
1104
1340
|
}
|
|
1105
1341
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1342
|
+
onClick={onClick}
|
|
1106
1343
|
subtitle={name}
|
|
1107
1344
|
title="$0.87"
|
|
1108
1345
|
/>
|
|
@@ -1126,14 +1363,21 @@ function DynamicContentCarousel() {
|
|
|
1126
1363
|
<Box marginX={-3}>
|
|
1127
1364
|
<Carousel
|
|
1128
1365
|
title="Explore Assets"
|
|
1366
|
+
paginationVariant="dot"
|
|
1129
1367
|
styles={{
|
|
1130
1368
|
root: { paddingInline: 'var(--space-3)' },
|
|
1131
1369
|
carousel: { gap: 'var(--space-1)', height: '156px' },
|
|
1132
1370
|
}}
|
|
1133
1371
|
>
|
|
1134
1372
|
{items.map((asset, index) => (
|
|
1135
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1136
|
-
|
|
1373
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1374
|
+
{({ isVisible }) => (
|
|
1375
|
+
<SquareAssetCard
|
|
1376
|
+
imageUrl={asset.imageUrl}
|
|
1377
|
+
name={asset.symbol}
|
|
1378
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
1379
|
+
/>
|
|
1380
|
+
)}
|
|
1137
1381
|
</CarouselItem>
|
|
1138
1382
|
))}
|
|
1139
1383
|
</Carousel>
|
|
@@ -1147,7 +1391,8 @@ You can also animate items as they enter or leave the viewport.
|
|
|
1147
1391
|
|
|
1148
1392
|
```jsx live
|
|
1149
1393
|
function AnimatedCarousel() {
|
|
1150
|
-
|
|
1394
|
+
const toast = useToast();
|
|
1395
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
1151
1396
|
const ref = useRef(null);
|
|
1152
1397
|
// useInView is a framer motion hook that detects when an element is in the viewport
|
|
1153
1398
|
const isInView = useInView(ref, {
|
|
@@ -1170,6 +1415,7 @@ function AnimatedCarousel() {
|
|
|
1170
1415
|
</Text>
|
|
1171
1416
|
}
|
|
1172
1417
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1418
|
+
onClick={onClick}
|
|
1173
1419
|
subtitle={name}
|
|
1174
1420
|
title="$0.87"
|
|
1175
1421
|
/>
|
|
@@ -1188,8 +1434,14 @@ function AnimatedCarousel() {
|
|
|
1188
1434
|
hidePagination
|
|
1189
1435
|
>
|
|
1190
1436
|
{Object.values(assets).map((asset, index) => (
|
|
1191
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1192
|
-
|
|
1437
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1438
|
+
{({ isVisible }) => (
|
|
1439
|
+
<SquareAssetCard
|
|
1440
|
+
imageUrl={asset.imageUrl}
|
|
1441
|
+
name={asset.symbol}
|
|
1442
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
1443
|
+
/>
|
|
1444
|
+
)}
|
|
1193
1445
|
</CarouselItem>
|
|
1194
1446
|
))}
|
|
1195
1447
|
</Carousel>
|
|
@@ -1264,6 +1516,7 @@ function AnimatedSelectionCarousel() {
|
|
|
1264
1516
|
<Box marginX={-3}>
|
|
1265
1517
|
<Carousel
|
|
1266
1518
|
title="Explore Assets"
|
|
1519
|
+
paginationVariant="dot"
|
|
1267
1520
|
styles={{
|
|
1268
1521
|
root: { paddingInline: 'var(--space-3)' },
|
|
1269
1522
|
carousel: { gap: 'var(--space-1)' },
|
|
@@ -1291,13 +1544,14 @@ function AnimatedSelectionCarousel() {
|
|
|
1291
1544
|
|
|
1292
1545
|
You can hide the navigation and pagination components of the carousel if desired (using `hideNavigation` and `hidePagination` props).
|
|
1293
1546
|
|
|
1294
|
-
Note that this can prevent proper accessibility for the carousel. If hiding pagination, it's recommended instead to
|
|
1547
|
+
Note that this can prevent proper accessibility for the carousel, if carousel items are not focusable. If hiding pagination, it's recommended instead to
|
|
1295
1548
|
pass in `DefaultCarouselNavigation` with `hideUnlessFocused` prop. Alternatively, you can ensure that the carousel is
|
|
1296
1549
|
navigable by keyboard through other means.
|
|
1297
1550
|
|
|
1298
1551
|
```jsx live
|
|
1299
1552
|
function HideNavigationAndPaginationCarousel() {
|
|
1300
|
-
|
|
1553
|
+
const toast = useToast();
|
|
1554
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
1301
1555
|
return (
|
|
1302
1556
|
<ContainedAssetCard
|
|
1303
1557
|
description={
|
|
@@ -1306,6 +1560,7 @@ function HideNavigationAndPaginationCarousel() {
|
|
|
1306
1560
|
</Text>
|
|
1307
1561
|
}
|
|
1308
1562
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1563
|
+
onClick={onClick}
|
|
1309
1564
|
subtitle={name}
|
|
1310
1565
|
title="$0.87"
|
|
1311
1566
|
/>
|
|
@@ -1325,8 +1580,14 @@ function HideNavigationAndPaginationCarousel() {
|
|
|
1325
1580
|
}}
|
|
1326
1581
|
>
|
|
1327
1582
|
{Object.values(assets).map((asset, index) => (
|
|
1328
|
-
<CarouselItem key={asset.symbol} id={asset.symbol}>
|
|
1329
|
-
|
|
1583
|
+
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1584
|
+
{({ isVisible }) => (
|
|
1585
|
+
<SquareAssetCard
|
|
1586
|
+
imageUrl={asset.imageUrl}
|
|
1587
|
+
name={asset.symbol}
|
|
1588
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
1589
|
+
/>
|
|
1590
|
+
)}
|
|
1330
1591
|
</CarouselItem>
|
|
1331
1592
|
))}
|
|
1332
1593
|
</Carousel>
|
|
@@ -1341,6 +1602,7 @@ You can create smooth pagination animations by customizing the pagination dots.
|
|
|
1341
1602
|
|
|
1342
1603
|
```jsx live
|
|
1343
1604
|
function AnimatedPaginationCarousel() {
|
|
1605
|
+
const toast = useToast();
|
|
1344
1606
|
const AnimatedPagination = memo((props) => {
|
|
1345
1607
|
const { totalPages, activePageIndex, onClickPage, style } = props;
|
|
1346
1608
|
|
|
@@ -1374,7 +1636,7 @@ function AnimatedPaginationCarousel() {
|
|
|
1374
1636
|
);
|
|
1375
1637
|
});
|
|
1376
1638
|
|
|
1377
|
-
function SquareAssetCard({ imageUrl, name }) {
|
|
1639
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
1378
1640
|
return (
|
|
1379
1641
|
<ContainedAssetCard
|
|
1380
1642
|
description={
|
|
@@ -1383,6 +1645,7 @@ function AnimatedPaginationCarousel() {
|
|
|
1383
1645
|
</Text>
|
|
1384
1646
|
}
|
|
1385
1647
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1648
|
+
onClick={onClick}
|
|
1386
1649
|
subtitle={name}
|
|
1387
1650
|
title="$0.87"
|
|
1388
1651
|
/>
|
|
@@ -1403,7 +1666,13 @@ function AnimatedPaginationCarousel() {
|
|
|
1403
1666
|
>
|
|
1404
1667
|
{Object.values(assets).map((asset, index) => (
|
|
1405
1668
|
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1406
|
-
|
|
1669
|
+
{({ isVisible }) => (
|
|
1670
|
+
<SquareAssetCard
|
|
1671
|
+
imageUrl={asset.imageUrl}
|
|
1672
|
+
name={asset.symbol}
|
|
1673
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
1674
|
+
/>
|
|
1675
|
+
)}
|
|
1407
1676
|
</CarouselItem>
|
|
1408
1677
|
))}
|
|
1409
1678
|
</Carousel>
|
|
@@ -1418,6 +1687,7 @@ You can control the carousel programmatically using a ref. The carousel exposes
|
|
|
1418
1687
|
|
|
1419
1688
|
```jsx live
|
|
1420
1689
|
function ImperativeApiCarousel() {
|
|
1690
|
+
const toast = useToast();
|
|
1421
1691
|
const carouselRef = useRef(null);
|
|
1422
1692
|
const [currentPageInfo, setCurrentPageInfo] = useState('Page 1');
|
|
1423
1693
|
|
|
@@ -1451,7 +1721,7 @@ function ImperativeApiCarousel() {
|
|
|
1451
1721
|
}
|
|
1452
1722
|
}
|
|
1453
1723
|
|
|
1454
|
-
function SquareAssetCard({ imageUrl, name }) {
|
|
1724
|
+
function SquareAssetCard({ imageUrl, name, onClick }) {
|
|
1455
1725
|
return (
|
|
1456
1726
|
<ContainedAssetCard
|
|
1457
1727
|
description={
|
|
@@ -1460,6 +1730,7 @@ function ImperativeApiCarousel() {
|
|
|
1460
1730
|
</Text>
|
|
1461
1731
|
}
|
|
1462
1732
|
header={<RemoteImage height="32px" source={imageUrl} width="32px" />}
|
|
1733
|
+
onClick={onClick}
|
|
1463
1734
|
subtitle={name}
|
|
1464
1735
|
title="$0.87"
|
|
1465
1736
|
/>
|
|
@@ -1529,7 +1800,13 @@ function ImperativeApiCarousel() {
|
|
|
1529
1800
|
>
|
|
1530
1801
|
{Object.values(assets).map((asset, index) => (
|
|
1531
1802
|
<CarouselItem key={asset.symbol} id={asset.symbol} accessibilityLabel={asset.name}>
|
|
1532
|
-
|
|
1803
|
+
{({ isVisible }) => (
|
|
1804
|
+
<SquareAssetCard
|
|
1805
|
+
imageUrl={asset.imageUrl}
|
|
1806
|
+
name={asset.symbol}
|
|
1807
|
+
onClick={() => toast.show(`${asset.symbol} clicked`)}
|
|
1808
|
+
/>
|
|
1809
|
+
)}
|
|
1533
1810
|
</CarouselItem>
|
|
1534
1811
|
))}
|
|
1535
1812
|
</Carousel>
|
|
@@ -1545,6 +1822,7 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1545
1822
|
|
|
1546
1823
|
```tsx
|
|
1547
1824
|
<Carousel
|
|
1825
|
+
paginationVariant="dot"
|
|
1548
1826
|
onChangePage={(pageIndex: number) => console.log('Page changed', activePageIndex)}
|
|
1549
1827
|
onDragStart={() => console.log('Drag started')}
|
|
1550
1828
|
onDragEnd={() => console.log('Drag ended')}
|
|
@@ -1564,6 +1842,8 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1564
1842
|
| `alignSelf` | `ResponsiveProp<center \| normal \| auto \| start \| end \| flex-start \| flex-end \| self-start \| self-end \| stretch \| baseline \| first baseline \| last baseline>` | No | `-` | - |
|
|
1565
1843
|
| `as` | `div` | No | `-` | The underlying element or component the polymorphic component will render. Changing as also changes the inherited native props (e.g. href for as=a) and the expected ref type. |
|
|
1566
1844
|
| `aspectRatio` | `inherit \| auto \| revert \| -moz-initial \| initial \| revert-layer \| unset` | No | `-` | - |
|
|
1845
|
+
| `autoplay` | `boolean` | No | `-` | Whether autoplay is enabled for the carousel. |
|
|
1846
|
+
| `autoplayInterval` | `number` | No | `3000 (3 seconds)` | The interval in milliseconds for autoplay. |
|
|
1567
1847
|
| `background` | `currentColor \| fg \| fgMuted \| fgInverse \| fgPrimary \| fgWarning \| fgPositive \| fgNegative \| bg \| bgAlternate \| bgInverse \| bgOverlay \| bgElevation1 \| bgElevation2 \| bgPrimary \| bgPrimaryWash \| bgSecondary \| bgTertiary \| bgSecondaryWash \| bgNegative \| bgNegativeWash \| bgPositive \| bgPositiveWash \| bgWarning \| bgWarningWash \| bgLine \| bgLineHeavy \| bgLineInverse \| bgLinePrimary \| bgLinePrimarySubtle \| accentSubtleRed \| accentBoldRed \| accentSubtleGreen \| accentBoldGreen \| accentSubtleBlue \| accentBoldBlue \| accentSubtlePurple \| accentBoldPurple \| accentSubtleYellow \| accentBoldYellow \| accentSubtleGray \| accentBoldGray \| transparent` | No | `-` | - |
|
|
1568
1848
|
| `borderBottomLeftRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
1569
1849
|
| `borderBottomRightRadius` | `0 \| 100 \| 200 \| 300 \| 400 \| 500 \| 600 \| 700 \| 800 \| 900 \| 1000` | No | `-` | - |
|
|
@@ -1617,7 +1897,7 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1617
1897
|
| `gridTemplateColumns` | `ResponsiveProp<GridTemplateColumns<string \| number>>` | No | `-` | - |
|
|
1618
1898
|
| `gridTemplateRows` | `ResponsiveProp<GridTemplateRows<string \| number>>` | No | `-` | - |
|
|
1619
1899
|
| `height` | `ResponsiveProp<Height<string \| number>>` | No | `-` | - |
|
|
1620
|
-
| `hideNavigation` | `boolean` | No | `-` | Hides the navigation arrows (previous/next buttons). |
|
|
1900
|
+
| `hideNavigation` | `boolean` | No | `-` | Hides the navigation arrows (previous/next buttons and autoplay control). |
|
|
1621
1901
|
| `hidePagination` | `boolean` | No | `-` | Hides the pagination indicators (dots/bars showing current page). |
|
|
1622
1902
|
| `justifyContent` | `ResponsiveProp<left \| right \| center \| normal \| start \| end \| flex-start \| flex-end \| stretch \| space-between \| space-around \| space-evenly>` | No | `-` | - |
|
|
1623
1903
|
| `key` | `Key \| null` | No | `-` | - |
|
|
@@ -1635,7 +1915,7 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1635
1915
|
| `maxWidth` | `ResponsiveProp<MaxWidth<string \| number>>` | No | `-` | - |
|
|
1636
1916
|
| `minHeight` | `ResponsiveProp<MinHeight<string \| number>>` | No | `-` | - |
|
|
1637
1917
|
| `minWidth` | `ResponsiveProp<MinWidth<string \| number>>` | No | `-` | - |
|
|
1638
|
-
| `nextPageAccessibilityLabel` | `string` | No |
|
|
1918
|
+
| `nextPageAccessibilityLabel` | `string` | No | `'Next page'` | Accessibility label for the next page button. |
|
|
1639
1919
|
| `onChange` | `FormEventHandler<HTMLDivElement>` | No | `-` | - |
|
|
1640
1920
|
| `onChangePage` | `((activePageIndex: number) => void)` | No | `-` | Callback fired when the carousel page changes. |
|
|
1641
1921
|
| `opacity` | `inherit \| revert \| -moz-initial \| initial \| revert-layer \| unset` | No | `-` | - |
|
|
@@ -1647,14 +1927,18 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1647
1927
|
| `paddingTop` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
1648
1928
|
| `paddingX` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
1649
1929
|
| `paddingY` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
1650
|
-
| `
|
|
1930
|
+
| `pageChangeAccessibilityLabel` | `((activePageIndex: number, totalPages: number) => string)` | No | ``Page X of Y`` | Accessibility label announced by screen readers when the page changes. Receives the current page index (0-based) and total pages. |
|
|
1931
|
+
| `paginationAccessibilityLabel` | `string \| ((pageIndex: number) => string)` | No | ``Go to page X`` | Accessibility label for the go to page button. When a string is provided, it is used as-is for all indicators. When a function is provided, it receives the page index and returns a label. |
|
|
1932
|
+
| `paginationVariant` | `dot \| pill` | No | `'pill'` | Visual variant for the pagination indicators. - pill: All indicators are pill-shaped (default) - dot: Inactive indicators are small dots, active indicator expands to a pill |
|
|
1651
1933
|
| `pin` | `top \| bottom \| left \| right \| all` | No | `-` | Direction in which to absolutely pin the box. |
|
|
1652
1934
|
| `position` | `ResponsiveProp<fixed \| static \| relative \| absolute \| sticky>` | No | `-` | - |
|
|
1653
|
-
| `previousPageAccessibilityLabel` | `string` | No |
|
|
1935
|
+
| `previousPageAccessibilityLabel` | `string` | No | `'Previous page'` | Accessibility label for the previous page button. |
|
|
1654
1936
|
| `ref` | `((instance: CarouselImperativeHandle \| null) => void) \| RefObject<CarouselImperativeHandle> \| null` | No | `-` | - |
|
|
1655
1937
|
| `right` | `ResponsiveProp<Right<string \| number>>` | No | `-` | - |
|
|
1656
1938
|
| `rowGap` | `0 \| 1 \| 2 \| 0.25 \| 0.5 \| 0.75 \| 1.5 \| 3 \| 4 \| 5 \| 6 \| 7 \| 8 \| 9 \| 10` | No | `-` | - |
|
|
1657
1939
|
| `snapMode` | `page \| item` | No | `'page'` | Specifies the pagination and navigation strategy for the carousel. item treats each item as a separate page for navigation, pagination, and snapping. page groups items into pages based on visible area for navigation, pagination, and snapping. This affects page calculation, navigation button behavior, and snap targets when dragging. |
|
|
1940
|
+
| `startAutoplayAccessibilityLabel` | `string` | No | `'Play Carousel'` | Accessibility label for starting autoplay. |
|
|
1941
|
+
| `stopAutoplayAccessibilityLabel` | `string` | No | `'Pause Carousel'` | Accessibility label for stopping autoplay. |
|
|
1658
1942
|
| `style` | `CSSProperties` | No | `-` | Custom styles for the root element. |
|
|
1659
1943
|
| `styles` | `{ root?: CSSProperties; title?: CSSProperties \| undefined; navigation?: CSSProperties \| undefined; pagination?: CSSProperties \| undefined; carousel?: CSSProperties \| undefined; carouselContainer?: CSSProperties \| undefined; } \| undefined` | No | `-` | Custom styles for the component. |
|
|
1660
1944
|
| `testID` | `string` | No | `-` | Used to locate this element in unit and end-to-end tests. Under the hood, testID translates to data-testid on Web. On Mobile, testID stays the same - testID |
|
|
@@ -1670,3 +1954,15 @@ You can use the `onChangePage`, `onDragStart`, and `onDragEnd` callbacks to list
|
|
|
1670
1954
|
| `zIndex` | `inherit \| auto \| revert \| -moz-initial \| initial \| revert-layer \| unset` | No | `-` | - |
|
|
1671
1955
|
|
|
1672
1956
|
|
|
1957
|
+
## Styles
|
|
1958
|
+
|
|
1959
|
+
| Selector | Static class name | Description |
|
|
1960
|
+
| --- | --- | --- |
|
|
1961
|
+
| `root` | `-` | root element. |
|
|
1962
|
+
| `title` | `-` | title element. |
|
|
1963
|
+
| `navigation` | `-` | navigation element. |
|
|
1964
|
+
| `pagination` | `-` | pagination element. |
|
|
1965
|
+
| `carousel` | `-` | main carousel element. |
|
|
1966
|
+
| `carouselContainer` | `-` | outer carousel container element. |
|
|
1967
|
+
|
|
1968
|
+
|