---
title: Spacer
---

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

# Spacer

<LibraryInfo />

```jsx live
<>
  <Typography>Above</Typography>
  <Divider />
  <Spacer space={8} />
  <Divider />
  <Typography>Below</Typography>
</>
```

## Introduction

An empty element used to create a gap between components.

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

## Guidance

Use Spacer where a specific amount of space is needed between two specific items.

Where multiple items require a consistent amount of space between them, use [`StackView`](stack-view) instead.

### `space` prop

The `space` prop sets the size of the spacer, using the [**spacing scale**](sizing#spacing-and-layout). See spacing scale docs for details.

```jsx live
<>
  <Divider />
  <Spacer space={1} />
  <Divider />
  <Spacer space={2} />
  <Divider />
  <Spacer space={3} />
  <Divider />
  <Spacer space={{ xs: 4, md: 5, lg: 6 }} />
  <Divider />
</>
```

### `direction` prop

If used inside a container with `flexDirection: 'row'`, the spacer's `direction` prop should be set to `'row'`, which applies the space horizontally.

By default, the `direction` is `column` and space is applied vertically.

```jsx live
<StackView space={0} direction="row">
  <Typography>Start</Typography>
  <Spacer space={{ xs: 2, sm: 3, md: 4, lg: 5 }} direction="row" />
  <Divider vertical />
  <Spacer space={6} direction="row" />
  <Divider vertical />
  <Spacer space={7} direction="row" />
  <Divider vertical />
  <Spacer space={8} direction="row" />
  <Typography>End</Typography>
</StackView>
```

### Accessibility

Spacer has no accessibility props and is ignored by accessibility tools such as screen readers.

### Platform considerations

<AvailableOnBoth />

## Tokens

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

## Props

<PropsTable base={BaseDocs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Spacer" />
