Skip to Content
🎉 Coral now has an MCP Server, check out the docs
DocumentationMoleculesCarousel

Carousel

Swipe or click through items in a carousel. Built using Embla .

Visit our Sandbox app for further Carousel inspiration 

Basic Usage

import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext } from '@octopus-energy/coral/molecules'; <Carousel> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <CarouselPrevious /> <CarouselNext /> </Carousel>

1

2

3

4

5

6

7

8

Properties

gap

The spacing between the individual slides in the carousel.

import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext } from '@octopus-energy/coral/molecules'; <Carousel gap="xxl"> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <CarouselPrevious /> <CarouselNext /> </Carousel>

1

2

3

4

5

6

7

8

orientation

The orientation of the carousel, either horizontal or vertical.

Notes:

  • If orientation is set to vertical, you must specify a height for the carousel to display correctly
  • If you’re using the default positioning of the controls, it’s important to set a container width that matches the slide width
import { Container } from '@octopus-energy/coral/atoms'; import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext } from '@octopus-energy/coral/molecules'; <Container width={420}> <Carousel orientation="vertical" height={260}> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <CarouselPrevious /> <CarouselNext /> </Carousel> </Container>

1

2

3

4

5

6

7

8

overflow

It’s possible to set the overflow to “visible” if you’d like the slides to extend beyond the carousel container.

Notes:

  • Be sure to set either your body or a Container to overflow: hidden to prevent the entire page becoming scrollable horizontally.
  • This example is not best displayed in these docs, as we have sidebars, but on a marketing page this is a nice feature to be able to have Carousels go edge-to-edge
import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext } from '@octopus-energy/coral/molecules'; <Carousel overflow="visible"> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <CarouselPrevious /> <CarouselNext /> </Carousel>

1

2

3

4

5

6

7

8

emblaOptions

For a full list of available options, refer to the Embla documentation .

Guides

Custom control placement

You can control exactly where the previous and next buttons are by removing them from their default positioning, this can be controlled with the defaultPositioning prop on each control.

In this example we place the controls under the Carousel, instead of on top.

import { Container, Stack } from '@octopus-energy/coral/atoms'; import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext } from '@octopus-energy/coral/molecules'; <Carousel> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <Container paddingTop="sm"> <Stack gap="xs"> <CarouselPrevious defaultPositioning={false} /> <CarouselNext defaultPositioning={false} /> </Stack> </Container> </Carousel>

1

2

3

4

5

6

7

8

Usage of the <CarouselDots /> sub-component we offer to indicate what slide the user is currently viewing.

import { Container, Stack } from '@octopus-energy/coral/atoms'; import { Carousel, CarouselBody, CarouselSlide, CarouselPrevious, CarouselNext, CarouselDots } from '@octopus-energy/coral/molecules'; <Carousel> <CarouselBody> <CarouselSlide>1</CarouselSlide> <CarouselSlide>2</CarouselSlide> </CarouselBody> <Container paddingTop="sm"> <Stack gap="sm" justifyContent="center"> <CarouselPrevious defaultPositioning={false} /> <CarouselDots /> <CarouselNext defaultPositioning={false} /> </Stack> </Container> </Carousel>

1

2

3

4

5

6

7

8

Content example

A realistic example combining the Carousel with Card, CardImage, and CardBody to display product content.

import { Button, Card, CardBody, CardImage, Container, Stack, Typography } from '@octopus-energy/coral/atoms'; import { Carousel, CarouselBody, CarouselDots, CarouselNext, CarouselPrevious, CarouselSlide } from '@octopus-energy/coral/molecules'; const products = [ { title: 'Flexible Octopus', description: '...', image: '...' }, // ...more products ]; <Carousel overflow="hidden" gap="md"> <CarouselBody> {products.map((product) => ( <CarouselSlide key={product.title}> <Container width={380} fullHeight> <Card theme="secondary900" padding="none" borderless fullHeight> <CardImage src={product.image} height={220} /> <CardBody padding="medium"> <Stack flexDirection="column" justifyContent="space-between" fullHeight> <Stack flexDirection="column" gap="sm"> <Typography textStyle="heading3">{product.title}</Typography> <Typography textStyle="body2">{product.description}</Typography> </Stack> <Button color="secondary500" size="small">Find out more</Button> </Stack> </CardBody> </Card> </Container> </CarouselSlide> ))} </CarouselBody> <Container paddingTop="sm"> <Stack gap="sm" justifyContent="center"> <CarouselPrevious defaultPositioning={false} /> <CarouselDots /> <CarouselNext defaultPositioning={false} /> </Stack> </Container> </Carousel>

Flexible Octopus

A variable tariff that tracks wholesale prices — when energy is cheap, you save.

Agile Octopus

Half-hourly prices that change with the grid. Shift your usage and pay less.

Octopus Go

Cheap overnight electricity for EV drivers. Charge up while you sleep.

Cosy Octopus

Designed for heat pump owners — low rates during off-peak hours to keep your home warm for less.

Full API

NameTypeDefault
attributesAttributes

This prop can be used to pass HTML attributes directly to the component. We currently allow passing data-* and aria-* attributes and the id. However, you can pass anything else with a type hack if necessary since this object is despread in to the component, without filtering its content.

Example usage:

AttributesProps: { 'id': 'close-button', 'aria-label': 'Close button', 'data-testid': 'close-button' };
childrenReact.ReactNode
emblaOptionsPartial<OptionsType> | undefined
gapResponsiveVariant<keyof CoralSpacing>

The gap between each carousel slide.

sm
overflow"visible" | "hidden"

Should the carousel content overflow its container.

hidden
orientationCarouselOrientation

The orientation of the carousel, either horizontal or vertical.

If set to vertical, you must also set the height prop.

horizontal
heightstring | number

When the carousel is in the vertical orientation, this defines the height of the carousel.

auto
Last updated on