---
title: Carousel
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Carousel, CarouselItem } from '@telus-uds/components-web'
import { Carousel as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Carousel

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2FTkOGIVaatADU8fDgNEA3GW%2FAllium-Community-Components-Work-in-Progress%3Fnode-id%3D2286%253A43925" />

```jsx live
<Carousel>
  <CarouselItem>
    <img src="/universal-design-system/img/lovebirds.jpeg" />
  </CarouselItem>
  <CarouselItem>
    <img src="/universal-design-system/img/pigs-allium-lo.png" />
  </CarouselItem>
  <CarouselItem>
    <img src="/universal-design-system/img/lovebirds.jpeg" />
  </CarouselItem>
</Carousel>
```

## Introduction

A carousel is a component for cycling through slides, designed to take up a designated space to allow the user to interact with the content at their own pace.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

:::caution
Though the carousel has been built with many accessibility considerations and visual styles tailored to our brand, there are associated risks when deciding to use carousel for your online experiences that include:

- Carousels always include content that is hidden from the customer’s view, and it is very likely they will not see that content
- Carousel items have a low click-through rate
- Carousels are often skipped entirely by customers
- Content within carousels are hidden when they are not in view, which may prevent them from being indexed in search results

:::

:::info
CarouselItem can also be used with dot notation. E.g. `<Carousel.Item />`.
This is useful when you want to import the Carousel component without importing the subcomponents separately,
:::

- Use a carousel when other alternatives have been exhausted
  - Users often overlook and scroll past carousel
  - Users often miss content after the first slide
  - Key points or messages can be missed or misinterpreted if they span multiple slides
- Use a carousel for the following considerations
  - Location is a priority and there is limited space
  - Provide supplemental content without disrupting the main objective
- Display content in order of priority and relevance
- Must not display content integral to the main objective
- Avoid showing more than 3 panels
- Avoid showing more than 4 slides of full content
- Avoid automatically switching between slides without a user interaction
- Provide meaningful Carousel labels
  - Use generic noun like “Élément” (item), or a specific noun like “Offre” (offer), “Solde” (sale), or “Image” (image)
  - Be mindful of context as example 2 and 5 are phrased as call-to-actions
    - a.`%{stepCount}` éléments
    - b.Montrer `%{itemLabel} %{targetStep} de %{stepCount}`
    - c.`%{itemLabel} %{stepNumber}`
    - d.`%{itemLabel} %{stepNumber} de %{stepCount}`
    - e.Passer `%{title}`

## Usage

- `Carousel` is a top-level export from `@telus-uds/components-base` which is used to render a Carousel
- Immediately within `Carousel`, individual slides are wrapped in `CarouselItem` for the top-level `Carousel` to know how to identify an individual slide
- You can use any UDS component or other platform-specific component, (based on the platform you're rendering on) to achieve any desired layout
- By default, Carousel takes all the `width` available to it and the `height` is determined based on the content in the slide with more content
- You may want to wrap `Carousel` in other layout components like `Box`, `FlexGrid` etc, to achieve a responsive layout of your need (as shown in the above example)

### Mixed content

Carousel may contain mixed content compositions beyond just images, and adapts to the width of the content's overall container.

To avoid repetition, it is often a good idea to set up your content compositions in a subcomponent, to ensure consistency between slides.

This example creates a subcomponent `ContentSlide` and composes slides with an image, a title, descriptive text and a button.

```jsx live
function() {
  // A content slide to generalize the repeatable slide layout
  const ContentSlide = ({
    imageSource,
    imageAlt,
    imageSize,
    boxProps = { horizontal: { xs: 1, md: 5, lg: 8 }},
    headingLabel,
    description,
    slideNumber,
    buttonLabel
  }) => {
    const { activeIndex } = useCarousel()
    const resolvedImageSize = useResponsiveProp(imageSize)
    return (
      <StackView tokens={{ alignItems: 'center' }} space={2}>
        <img src={imageSource} alt={imageAlt}/>
        <Box {...boxProps}>
          <StackView tokens={{ alignItems: 'center' }} space={3}>
            <Typography block variant={{ size: 'h1' }}>
              {headingLabel}
            </Typography>
            <Typography>{description}</Typography>
            <Button
              onPress={console.log}
              variant={{ priority: 'high' }}
              tokens={{ alignSelf: 'center' }}
              focusable={activeIndex + 1 === slideNumber}
            >
              {buttonLabel}
            </Button>
          </StackView>
        </Box>
      </StackView>
    )
  }
  return (
    <Carousel refocus itemLabel="offer" accessibilityLabel="Summer offers">
      <CarouselItem>
        <ContentSlide
          imageSource="/universal-design-system/img/lovebirds.jpeg"
          imageAlt="Two colourful love birds sitting together and connecting."
          imageSize={{ xs: 280, md: 360, lg: 480 }}
          headingLabel="Beat the heat with the coolest deals."
          description="Explore our deals on Unlimited data plans, the latest smartphones, accessories and a whole lot more."
          slideNumber={1}
          buttonLabel="Sign Up"
        />
      </CarouselItem>
      <CarouselItem>
        <FlexGrid>
          <FlexGridRow>
            <FlexGridCol xs={12} sm={6} flex>
              <ContentSlide
                imageSource="/universal-design-system/img/guinea-pig.png"
                imageAlt="A guinea pig cooling itself down with a gentle breeze."
                boxProps={{ left: { xs: 1, md: 3, lg: 5 }}}
                headingLabel="Save $10 monthly"
                description="Example content only."
                slideNumber={2}
                buttonLabel="Sign Up"
              />
            </FlexGridCol>
            <FlexGridCol xs={12} sm={6} flex>
              <ContentSlide
                imageSource="/universal-design-system/img/guinea-pig.png"
                imageAlt="A guinea pig cooling itself down with a gentle breeze."
                boxProps={{ right: { xs: 1, md: 3, lg: 5 }}}
                headingLabel="Save $10 monthly"
                description="Example content only."
                slideNumber={2}
                buttonLabel="Sign Up"
              />
            </FlexGridCol>
          </FlexGridRow>
        </FlexGrid>
      </CarouselItem>
      <CarouselItem>
        <ContentSlide
          imageSource="/universal-design-system/img/pigs-allium-lo.png"
          imageAlt="Some playful pigs with an allium flower."
          imageSize={{ xs: 280, md: 360, lg: 480 }}
          headingLabel="Beat the heat with the coolest deals."
          description="Explore our deals on Unlimited data plans, the latest smartphones, accessories and a whole lot more."
          slideNumber={3}
          buttonLabel="Sign Up"
        />
      </CarouselItem>
    </Carousel>
  )
}
```

### `useCarousel` custom hook

```jsx
import { useCarousel } from '@telus-uds/components-base'
const SomeComponentWithinCarouselItem = () => {
  const {
    activeIndex,
    totalItems,
    width,
    goTo,
    getCopyWithPlaceholders,
    itemLabel,
    refocus,
    themeTokens,
    maximumItemsForSlide
  } = useCarousel()
  return <Text>Hi!</Text>
}
```

You can use `useCarousel` to hook into internal state of the Carousel component like:

- `activeIndex`: Index of the current slide
- `totalItems`: Total number of items/slides passed to the Carousel
- `width`: Width of the individual carousel slide
- `goTo`: A function to go to a particular slide by passing the index of that slide, e.g: goTo(0) where `0` is the index of the first slide
- `getCopyWithPlaceholders`: A function to get copy text with placeholders replaced
- `itemLabel`: The label for each item in the carousel
- `refocus`: A boolean indicating whether to refocus on slide change
- `themeTokens`: Theme tokens for the Carousel component
- `maximumItemsForSlide`: Maximum number of items that can be displayed per slide based on viewport

### Tabs navigation

If the `tabs` prop is passed an array of objects with `title` strings and optional additional props, and if the theme considers the viewport to be wide enough, a display of tabs is shown giving a title for each slide.

This is advised for rich-content presentations. Having the title of each item always visible this way increases the chances of a user noticing a relevant item, and helps the user understand the set of items. However, users on narrower screens won't benefit from this.

```jsx live
<Carousel
  itemLabel="offer"
  title="summer offers"
  tabs={[
    { title: 'Home bundle for $105/month' },
    {
      title: '$840 off TV & internet bundles',
      onPress: () => console.log('Press on second tab'),
      onFocus: () => console.log('Focus in on second tab'),
      onBlur: () => console.log('Focus out on second tab')
    },
    { title: 'Save big with the TELUS Family Discount' }
  ]}
>
  <CarouselItem>
    <Box space={3} bottom={9}>
      <FlexGrid>
        <FlexGridRow>
          <FlexGridCol flex xs={12} lg={6}>
            <StackView space={3}>
              <Typography variant={{ size: 'h2' }}>
                Get Internet, Optik TV+, SmartHome Security - starting at $105/month.
              </Typography>
              <Typography>
                Whole Home Bundle helps keep your family connected, entertained, and secure.
              </Typography>
              <Button variant={{ priority: 'high' }}>Shop bundles</Button>
            </StackView>
          </FlexGridCol>
          <FlexGridCol flex xs={12} lg={6}>
            <img src="/universal-design-system/img/pigs-allium-lo.png" />
          </FlexGridCol>
        </FlexGridRow>
      </FlexGrid>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box vertical={6}>
      <FlexGrid>
        <FlexGridRow>
          <FlexGridCol flex xs={12} lg={6}>
            <img src="/universal-design-system/img/pigs-allium-lo.png" />
          </FlexGridCol>
          <FlexGridCol flex xs={12} lg={6}>
            <StackView space={3}>
              <Typography variant={{ size: 'h2' }}>
                TV and Internet bundles - for up to $840 less!
              </Typography>
              <Typography>
                Get the all the quality content you need for a fraction of the price.
              </Typography>
              <Button variant={{ priority: 'high' }}>Shop bundles</Button>
            </StackView>
          </FlexGridCol>
        </FlexGridRow>
      </FlexGrid>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <StackView space={3} tokens={{ alignItems: 'center' }}>
      <img src="/universal-design-system/img/pigs-allium-lo.png" />
      <Typography variant={{ size: 'h2' }} tokens={{ alignSelf: 'center' }}>
        Are you eligible for family-sized savings?
      </Typography>
      <Typography>You could save BIG with the TELUS Family Discount.</Typography>
      <Box>
        <ChevronLink>Find out now</ChevronLink>
      </Box>
    </StackView>
  </CarouselItem>
</Carousel>
```

### Thumbnail navigation

You can add thumbnail navigation to the `Carousel` component by passing an array of thumbnail properties via the `thumbnails` prop. Each element of such an
array may contain the following properties:

- `src`: image source for the thumbnail, required; note that the thumbnail will be rendered as is (but scaled as per the theme), so please make sure
  that the images are cropped and optimized accordingly
- `alt`: alternative text to be used in case the image cannot be rendered or on hover
- `accessibilityLabel`: text to be used as an a11y label.

```jsx live
<Carousel
  thumbnails={[
    {
      src: '/universal-design-system/img/pigs-allium-lo.png',
      accessibilityLabel: 'A guinea pig'
    },
    {
      src: '/universal-design-system/img/pigs-allium-lo.png',
      accessibilityLabel: 'Another guinea pig'
    },
    {
      src: '/universal-design-system/img/pigs-allium-lo.png',
      accessibilityLabel: 'Yet another guinea pig'
    }
  ]}
>
  <CarouselItem>
    <img src="/universal-design-system/img/pigs-allium-lo.png" alt="A guinea pig" />
  </CarouselItem>
  <CarouselItem>
    <img src="/universal-design-system/img/pigs-allium-lo.png" alt="A guinea pig" />
  </CarouselItem>
  <CarouselItem>
    <img src="/universal-design-system/img/pigs-allium-lo.png" alt="A guinea pig" />
  </CarouselItem>
</Carousel>
```

### Advance usage - combining the box component and Carousel

You can wrap the Carousel within the Box component and set a background variant for the Box and using the `useCarousel` hooks
it's possible to control the background color of the box based on the current shown slide, when using tabs
you can use `inverse:true` property to make the tabs looks lighter. For the Carousel Step tracker on mobile you need to pass
the `stepTrackerVariant` prop and set `inverse` to `true` below there is a complete example.

```jsx live
function() {

  const [currentBackground, setCurrentBackground] = React.useState('purpleGradient')
  const [isStepTrackerInverse, setIsStepTrackerInverse] = React.useState(false)

  const item = {
    headingLabel: 'Lorem ipsum dolor sit amet',
    description:
      'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vitae turpis sit amet nulla faucibus tincidunt in vitae leo. Integer luctus arcu eget est rutrum, non aliquam risus tincidunt. Pellentesque suscipit eros ac sem imperdiet, nec consequat eros convallis. Etiam quis pretium magna, quis interdum enim. Ut sed dui tristique, gravida orci ut, aliquam diam. Integer aliquam fermentum ante, a placerat odio ullamcorper eu. Nulla vel velit eu velit pellentesque facilisis.',
    buttonLabel: 'A label for the button',
    setCurrentBackground,
    setIsStepTrackerInverse
  }

  const InverseTemplate = ({
    headingLabel,
    description,
    buttonLabel,
    inverse = true,
    index,
    setCurrentBackground,
    bg,
    setIsStepTrackerInverse
  }) => {
    const { activeIndex } = useCarousel()

    useEffect(() => {
      if (setCurrentBackground && activeIndex === index && bg) {
        setCurrentBackground(bg)
        setIsStepTrackerInverse(inverse)
      }
    }, [setCurrentBackground, activeIndex, bg, index, setIsStepTrackerInverse, inverse])

    return (
      <Box space={5}>
        <Box vertical={2} bottom={5}>
          <Typography block variant={{ size: 'h1', inverse }}>
            {headingLabel}
          </Typography>
        </Box>
        <Box bottom={5}>
          <Typography variant={{ inverse }}>{description}</Typography>
        </Box>
        <Box bottom={5}>
          <Button onPress={() => {}} variant={{ priority: 'high' }} tokens={{ alignSelf: 'center' }}>
            {buttonLabel}
          </Button>
        </Box>
      </Box>
    )
  }

  return (
    <Box space={5} variant={{ background: currentBackground }}>
      <Carousel
        previousNextNavigationPosition='inside'
        previousNextIconSize='default'
        tabs={[
          { title: 'Feature Primary', inverse: true },
          { title: 'Feature Secondary', inverse: true },
          { title: 'Feature Neutral' },
          { title: 'Feature Brand', inverse: true },
          { title: 'Light' },
          { title: 'Lightest' },
          { title: 'Dark', inverse: true },
          { title: 'Darkest', inverse: true }
        ]}
        stepTrackerVariant={{ inverse: isStepTrackerInverse }}
      >
        {[
          { ...item, bg: 'featurePrimary' },
          { ...item, bg: 'featureSecondary' },
          { ...item, bg: 'featureNeutral', inverse: false },
          { ...item, bg: 'featureBrand' },
          { ...item, bg: 'light', inverse: false },
          { ...item, bg: 'lightest', inverse: false },
          { ...item, bg: 'dark' },
          { ...item, bg: 'darkest' }
        ].map((itemProps, index) => (
          <CarouselItem key={`${item.bg}-carousel`}>
            <InverseTemplate {...itemProps} index={index} />
          </CarouselItem>
        ))}
      </Carousel>
    </Box>
  )
}
```

### Advance usage - Hero mode and custom item background color

You can use the `enableHero` prop to make the carousel full width of the viewport. You can also set a custom background color for each item by passing the `backgroundColor` prop to the `CarouselItem` component.

```jsx live
function() {
  const [isStepTrackerInverse, setIsStepTrackerInverse] = React.useState(false)

  const item = {
    headingLabel: 'Lorem ipsum dolor sit amet',
    description:
      'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vitae turpis sit amet nulla faucibus tincidunt in vitae leo. Integer luctus arcu eget est rutrum, non aliquam risus tincidunt. Pellentesque suscipit eros ac sem imperdiet, nec consequat eros convallis. Etiam quis pretium magna, quis interdum enim. Ut sed dui tristique, gravida orci ut, aliquam diam. Integer aliquam fermentum ante, a placerat odio ullamcorper eu. Nulla vel velit eu velit pellentesque facilisis.',
    buttonLabel: 'A label for the button',
    setIsStepTrackerInverse
  }

  const Template = ({
    headingLabel,
    description,
    buttonLabel,
    inverse = true,
    index,
    bg,
    setIsStepTrackerInverse
  }) => {
    const { activeIndex } = useCarousel()

    useEffect(() => {
      if (activeIndex === index && bg) {
        setIsStepTrackerInverse(inverse)
      }
    }, [activeIndex, bg, index, setIsStepTrackerInverse, inverse])

    return (
      <Box space={10}>
        <Box vertical={2} bottom={5}>
          <Typography block variant={{ size: 'h1', inverse }}>
            {headingLabel}
          </Typography>
        </Box>
        <Box bottom={5}>
          <Typography variant={{ inverse }}>{description}</Typography>
        </Box>
        <Box bottom={5}>
          <Button onPress={() => {}} variant={{ priority: 'high' }} tokens={{ alignSelf: 'center' }}>
            {buttonLabel}
          </Button>
        </Box>
      </Box>
    )
  }

  return (
      <Carousel
        previousNextNavigationPosition='inside'
        previousNextIconSize='default'
        tabs={[
          { title: 'Light' },
          { title: 'Lightest' },
          { title: 'Dark', inverse: true },
          { title: 'Darkest', inverse: true }
        ]}
        stepTrackerVariant={{ inverse: isStepTrackerInverse }}
        enableHero
      >
        {[
          { ...item, bg: 'light', inverse: false },
          { ...item, bg: 'lightest', inverse: false },
          { ...item, bg: 'dark' },
          { ...item, bg: 'darkest' }
        ].map((itemProps, index) => (
          <CarouselItem key={`${item.bg}-carousel`} backgroundColor={itemProps.bg}>
            <Template {...itemProps} index={index} />
          </CarouselItem>
        ))}
      </Carousel>
  )
}
```

### Autoplay

:::warning

Autoplaying carousels pose challenges to user experience and engagement due to their disruptive nature. Here are some reasons why avoiding autoplay feature can enhance user satisfaction:

- Users may feel frustrated and disengaged when content changes without their input.
- Providing users with control over navigation empowers them to engage meaningfully.
- Allowing users to digest information at their preferred pace enhances satisfaction and interaction.
- Respecting user autonomy fosters a positive user experience.

:::

Use autoplaying carousels with caution. Follow the [guidance](#autoplay) and consider alternative layouts to prioritize important content.

You can enable the `autoPlay` mode by configuring the following props:

- `autoPlay`: `true` to enable the auto play
- `slideDuration`: the duration in seconds for each slide to be shown
- `transitionDuration`: the duration in seconds for the transition between slides

Here's an example of `autoPlay` mode with a duration of 10 seconds for each slide and a transition duration of 2 seconds, with 3 slides.

```jsx live
<Carousel
  autoPlay
  slideDuration={10}
  transitionDuration={2}
  itemLabel="offer"
  title="summer offers"
  tabs={[
    { title: 'Home bundle for $105/month' },
    {
      title: '$840 off TV & internet bundles',
      onPress: () => console.log('Press on second tab'),
      onFocus: () => console.log('Focus in on second tab'),
      onBlur: () => console.log('Focus out on second tab')
    },
    { title: 'Save big with the TELUS Family Discount' }
  ]}
>
  <CarouselItem>
    <Box space={3} bottom={9}>
      <FlexGrid>
        <FlexGridRow>
          <FlexGridCol flex xs={12} lg={6}>
            <StackView space={3}>
              <Typography variant={{ size: 'h2' }}>
                Get Internet, Optik TV+, SmartHome Security - starting at $105/month.
              </Typography>
              <Typography>
                Whole Home Bundle helps keep your family connected, entertained, and secure.
              </Typography>
              <Button variant={{ priority: 'high' }}>Shop bundles</Button>
            </StackView>
          </FlexGridCol>
          <FlexGridCol flex xs={12} lg={6}>
            <img src="/universal-design-system/img/pigs-allium-lo.png" />
          </FlexGridCol>
        </FlexGridRow>
      </FlexGrid>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box space={3} vertical={6}>
      <FlexGrid>
        <FlexGridRow>
          <FlexGridCol flex xs={12} lg={6}>
            <img src="/universal-design-system/img/pigs-allium-lo.png" />
          </FlexGridCol>
          <FlexGridCol flex xs={12} lg={6}>
            <StackView space={3}>
              <Typography variant={{ size: 'h2' }}>
                TV and Internet bundles - for up to $840 less!
              </Typography>
              <Typography>
                Get the all the quality content you need for a fraction of the price.
              </Typography>
              <Button variant={{ priority: 'high' }}>Shop bundles</Button>
            </StackView>
          </FlexGridCol>
        </FlexGridRow>
      </FlexGrid>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box space={3} vertical={6}>
      <FlexGrid>
        <FlexGridRow>
          <FlexGridCol flex xs={12} lg={6}>
            <img src="/universal-design-system/img/pigs-allium-lo.png" />
          </FlexGridCol>
          <FlexGridCol flex xs={12} lg={6}>
            <StackView space={3} tokens={{ alignItems: 'center' }}>
              <Typography variant={{ size: 'h2' }} tokens={{ alignSelf: 'center' }}>
                Are you eligible for family-sized savings?
              </Typography>
              <Typography>You could save BIG with the TELUS Family Discount.</Typography>
              <Box>
                <ChevronLink>Find out now</ChevronLink>
              </Box>
            </StackView>
          </FlexGridCol>
        </FlexGridRow>
      </FlexGrid>
    </Box>
  </CarouselItem>
</Carousel>
```

### Peeking

This function allows the user to see a portion of the next slide, which can help them understand that there is more content to see.

- Limit use to smaller viewports such as mobile apps
- Highly recommend to use other alternatives for larger viewports

When the peeking feature is enabled, the `previousNextNavigationPosition` cannot be set to `outside`.

```jsx live
<Carousel enablePeeking>
  <CarouselItem>
    <Box variant={{ background: 'brand' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industry's standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'darkest' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industry's standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'featureNeutral' }} space={4} flex={1}>
      <Typography>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industry's standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
</Carousel>
```

### Display multiple items per slide

You can display multiple items at once by setting the `enableDisplayMultipleItemsPerSlide` prop. This prop will allow you to display multiple items at once in a single slide.

```jsx live
<Carousel enableDisplayMultipleItemsPerSlide progressBarVariant={{ style: 'dots' }}>
  <CarouselItem>
    <Box variant={{ background: 'brand' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'darkest' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries;s standard dummy text ever since the 1500s, when an unknown printer took
        a galley of type and scrambled it to make a type specimen book. It has survived not only
        five centuries, but also the leap into electronic typesetting, remaining essentially
        unchanged. It was popularised in the 1960s with the release of Letraset sheets containing
        Lorem Ipsum passages, and more recently with desktop publishing software like Aldus
        PageMaker including versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'featureNeutral' }} space={4} flex={1}>
      <Typography variant={{ inverse: false }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'brand' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'darkest' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'featureNeutral' }} space={4} flex={1}>
      <Typography variant={{ inverse: false }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'brand' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'darkest' }} space={4} flex={1}>
      <Typography variant={{ inverse: true }}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
        been the industries standard dummy text ever since the 1500s, when an unknown printer took a
        galley of type and scrambled it to make a type specimen book. It has survived not only five
        centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
        It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum
        passages, and more recently with desktop publishing software like Aldus PageMaker including
        versions of Lorem Ipsum.
      </Typography>
    </Box>
  </CarouselItem>
</Carousel>
```

### Hero mode with multiple items per slide

You can combine hero mode with multiple items per slide to create a full-width carousel that displays multiple items simultaneously. This is particularly useful for showcasing multiple products or features in a prominent hero section.

```jsx live
<Carousel enableHero enableDisplayMultipleItemsPerSlide progressBarVariant={{ style: 'dots' }}>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 1
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 1</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 2
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 2</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 3
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 3</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 4
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 4</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 5
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 5</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
</Carousel>
```

### Hero mode with multiple items and peeking

For an enhanced user experience, you can combine hero mode, multiple items per slide, and peeking to show a preview of the next items while maintaining the full-width hero presentation.

```jsx live
<Carousel
  enableHero
  enableDisplayMultipleItemsPerSlide
  enablePeeking
  progressBarVariant={{ style: 'dots' }}
>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 1
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 1</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 2
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 2</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 3
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 3</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 4
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 4</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
  <CarouselItem>
    <Box variant={{ background: 'lightest' }} space={4} flex={1}>
      <StackView space={3}>
        <Typography variant={{ size: 'caption' }} tokens={{ color: 'brand' }}>
          SLIDE 5
        </Typography>
        <Typography variant={{ size: 'h3' }}>Title 5</Typography>
        <Typography variant={{ size: 'body' }}>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Doloribus ducimus inventore,
          placeat aperiam in nostrum ex. Officiis, similique nobis dicta optio aperiam, aliquid
          fugit, nisi officia quibusdam provident vel commodi.
        </Typography>
      </StackView>
    </Box>
  </CarouselItem>
</Carousel>
```

### Accessibility

When implementing the carousel, take care to ensure the component is accessible.

- Must supply accessible content for each slide
- Images must have appropriate “alt” text in English and French
- Must be able to navigate and read content using assistive technologies

#### Accessibility features

To attempt to mitigate the inherent difficulties of using a Carousel with assistive technology, the UDS carousel has the following features:

- (TODO) Renders content as a semantic unordered list
- (TODO) Renders a single slide at a time to the DOM
  - (TO IMPROVE) Mitigates overwhelming a user of assistive technologies by not announcing all content at once
  - (TODO) Allows user to navigate to the next slide within the slider, or skip and navigate away from the slider
- (TODO) Announces each slide to assistive technologies using the “aria-live” attribute on a visually hidden `<div>` element. Example: `` <div aria-live="polite">{`Slide number ${currentSlide} of ${total} slides`}</div> ``
- (TODO) Each active slide will receive focus so the user could interact with its content
  - (TO IMPROVE) By default, `<li>` elements cannot receive focus
  - (TODO) Set tabindex attribute to `-1`; allow the element to receive focus through JavaScript
- (TO IMPROVE) Must have a descriptive text on each navigational element for assistive technologies
  - (TODO) Must allow ability to switch it to French using the required `copy` prop

## Platform considerations

The component is available on both native platforms and web

## Props

:::warning
Note: `progressBarVariant` will be deprecated in the next major version.
:::

### Carousel

<PropsTable base={BaseDocs} />

### CarouselItem

<PropsTable base={BaseDocs.Item} />

## Tokens

<TokensTable base={BaseDocs} component="Carousel" />

## Other considerations

- You may want to use the same kind of layout in all your slides to avoid visual and height differences
- `previous` and `next` navigation buttons are automatically removed in `sm` and `xs` viewports, as these smaller viewports offer swipe functionality

## Variants

<NoStylisticVariants />

## Tokens

You can override the following tokens in exceptional circumstances:

- `previousIcon` - Icon of the previous button
- `nextIcon` - Icon of the next button
- `showPreviousNextNavigation` - If you want to show/hide the previous/next navigation
- `showPanelNavigation` - If you want to show/hide the panel navigation
- `spaceBetweenSlideAndPreviousNextNavigation` - Horizontal space between slide and previous/next navigational buttons
- `spaceBetweenSlideAndPanelNavigation` - Vertical space between slide area and panel navigation area

## Feedback

<Feedback component="Carousel" />
