---
title: Parallax
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, FigmaEmbed, PropsTable } from '../../src/components'
import { Parallax as ParallaxDocs } from 'docs/@telus-uds/components-community'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Parallax

<LibraryInfo
  isWebOnly={true}
  packageName="components-community.parallax"
  compatibility={['React 18']}
  figmaLink="https://www.figma.com/file/fEEHR8V8Xeob87kae7C6g7/SH-2.0-MVE-1.0?type=design&node-id=8651-65103&mode=design&t=OElWO2HmoyUkgK5S-0"
/>

```jsx live
<Parallax reduceMotion={false} reverseColumns={false} sections={imageSections} />
```

## Introduction

`Parallax` is a component that allows for a more dynamic, visually appealing,
and engaging experience. It has multiple layouts and can be used to display any type of content.

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

```jsx
import { Parallax } from '@telus-uds/components-community.parallax'
```

## Guidance

`Parallax` was designed with to be flexible, allowing full customization of the layout.

Both sides of `Parallax` can take in any content, but it is recommended to use images or another
visual/interactive element on one side and text on the other.

Content on the left side of `Parallax` will scroll naturally through the page, content on the
right side will stay stickied to the center of the page until the left side has scrolled 50% of
the way through the page. At that point, the right side will fade to new content, matching the left side.

Each section will always take up 100% of the viewport height. This is so the content on the sticky
side will only change when content on the opposite side is in view.

```jsx live
<Parallax reduceMotion={false} reverseColumns={false} sections={contentSections} />
```

`Parallax` can be fully customized with just 3 Props.

The `sections` prop accepts an array of objects that each contain `rightChild` and `leftChild`
properties. Each property accepts any valid react node and will be displayed on the appropriate
side of `Parallax`.

`leftChild:` The content that will be displayed on the left (`static`) side of `Parallax`.
`rightChild:` The content that will be displayed on the right (`sticky`) side of `Parallax`.

Both left and right child can be any content. You can send in a single `component`, or even a
`function` that returns multiple components.

There is no limit to the number of sections that can be sent in, but it is recommended to keep it
to 3 or less.

```jsx live
<Parallax
  reduceMotion={false}
  reverseColumns={false}
  sections={singleSection}
  isSingleColumn={true}
/>
```

A new view for `Parallax` has been added that allows only a single section to be sent in. When sending
only a single section, the `Parallax` will stack on top of eachother. The `leftChild` will always be
on top, and the `rightChild` will always be on the bottom. When you scroll through the page, the
`leftChild` will stick to the top of the container, and the `rightChild` will scroll normally, covering the
`leftChild` as it goes.

# Single Column with sections

```jsx live
<Parallax
  reduceMotion={false}
  reverseColumns={false}
  sections={singleColumnSectionsContent}
  isSingleColumn={true}
/>
```

A new view for `Parallax` has been added that allows for a single column with multiple sections.
For this option, we have to send the sections within the `leftChild` so that the `Parallax` component
will stack on top of each other. Each `leftChild` will stick to the screen,
covering the previous `leftChild` as it progresses.

```jsx
<Parallax
  sections={[
    {
      leftChild: (
        <>
          <Typography block variant={{ size: 'h1' }}>
            Header 1
          </Typography>
          <Box space={3} />
          <Typography>
            Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
            nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
            officia deserunt mollit anim id est laborum.
          </Typography>
        </>
      ),
      rightChild: <Image alt="image1" src="/universal-design-system/img/pigs-allium-lo.png" />
    },
    {
      leftChild: (
        <>
          <Typography block variant={{ size: 'h1' }}>
            Header 2
          </Typography>
          <Box space={3} />
          <Typography>
            Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
            nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
            officia deserunt mollit anim id est laborum.
          </Typography>
        </>
      ),
      rightChild: <Image alt="image2" src="/universal-design-system/img/pigs-allium-lo.png" />
    },
    {
      leftChild: (
        <>
          <Typography block variant={{ size: 'h1' }}>
            Header 3
          </Typography>
          <Box space={3} />
          <Typography>
            Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
            nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
            officia deserunt mollit anim id est laborum.
          </Typography>
        </>
      ),
      rightChild: <Image alt="image3" src="/universal-design-system/img/pigs-allium-lo.png" />
    }
  ]}
/>
```

Which side has the parallax effect can be controlled with the `reverseColumns` prop. If `true`
or by default, the right side is sticky and the left side scrolls normally. Changing this value
will also flip the content.

The content you want to be sticky should always be sent through the `rightChild`.

When in mobile view the content will stack on top of each other, all animations are turned off,
and `rightChild` will always be on top. `reverseColumns` will have no effect in mobile view.

### Accessibility

`Parallax` is fully accessible. By setting `reduceMotion` to false, the content will be displayed
with no animations or sticky effect. This is intended to be used for `reduced motion`.

Even with the parallax effect on, screen readers will still be able to read the content properly
as the content `visibility` is set to `hidden` when it is not in view. This `css` property has a delay
so that there is no clipping of the content as the `fade` transition is happening.

As `Parallax` is ultimately just a container for other content, it is recommended you follow
[accessibility guidelines](https://www.telus.com/en/brand-resources/categories/accessibility) for the content you are passing through the `sections` prop.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={ParallaxDocs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Parallax" />
