---
title: IconButton
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Box, StackView } from '@telus-uds/components-web'
import { IconButton } from '@telus-uds/components-web'
import { IconButton as WebDocs } from 'docs/@telus-uds/components-web'
import { IconButton as BaseDocs } from 'docs/@telus-uds/components-base'

# IconButton

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D3756%253A42273" />

```jsx live
<IconButton action="add" onPress={() => {}} />
```

## Introduction

IconButton can be used to control actions or navigation on pressing a universally-recognizable icon that
doesn’t need visually displayed accompanying text (but may include an accessibility label for screen reader users).

The button shows the icon only, which is limited to a sub-set of multi-brand icons (add, close, play, subtract, moveLeft,
moveRight, moveDown, moveUp).

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

## Guidance

- Use `accessibilityLabel` to provide context for screen reader users.
- Use `action` to set the icon to a multi-brand compatabile icon: one of `add`, `close`, `play`, `subtract`, `moveUp`, `moveDown`, `moveLeft`, `moveRight`.
- Use `iconName` to set the icon: one of Add, Close, Play, Subtract, ArrowLeft, ArrowRight, CaretDown, CaretUp
- Use `icon` to set a custom icon.
- Pass a `href` if the IconButton should render as an `<a>` link with a URL as a target. Rendered semantic role may
  also be controlled using `accessibilityRole` (default role is `button` if `href` is not provided).

```jsx live
<Box space={4}>
  <StackView space={4} direction="row">
    <IconButton action="add" href="https://telus.com" />
    <IconButton action="close" href="https://telus.com" />
    <IconButton action="play" href="https://telus.com" />
    <IconButton action="subtract" href="https://telus.com" />
    <IconButton action="moveLeft" href="https://telus.com" />
    <IconButton action="moveRight" href="https://telus.com" />
    <IconButton action="moveDown" href="https://telus.com" />
    <IconButton action="moveUp" href="https://telus.com" />
    <IconButton action="expand" href="https://telus.com" />
  </StackView>
</Box>
```

### Accessibility

- Pass an `accessibilityLabel` so that the icon button is accessible to screen readers.

## Props

<PropsTable base={BaseDocs} web={WebDocs} />

## Tokens

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

:::danger
The `iconName` property is deprecated, it is only available in `ds-allium`. Please use `action` instead when using `components-web`.
:::

## Variants

There are three sizes available (`default`, small, large) and "inverse" and "raised" stylistic variants.
There is also a "action" variant to use multi-brand supported icons.

### Default

The default choice on light backgrounds.

```jsx live
<Box space={4}>
  <StackView space={4} direction="row">
    <IconButton action="add" onPress={() => {}} variant={{ size: 'small' }} />
    <IconButton action="add" onPress={() => {}} />
    <IconButton action="add" onPress={() => {}} variant={{ size: 'large' }} />
  </StackView>
</Box>
```

### Inverse

A light icon button for use on dark backgrounds.

```jsx live
<Box space={4} variant={{ background: 'darkest' }}>
  <StackView space={4} direction="row">
    <IconButton action="add" onPress={() => {}} variant={{ inverse: true, size: 'small' }} />
    <IconButton action="add" onPress={() => {}} variant={{ inverse: true }} />
    <IconButton action="add" onPress={() => {}} variant={{ inverse: true, size: 'large' }} />
  </StackView>
</Box>
```

### Raised

Uses a solid background and shadow effect, for sitting above other content.

```jsx live
<Box space={4} background="darkest">
  <StackView space={4} direction="row">
    <IconButton action="add" onPress={() => {}} variant={{ raised: true, size: 'small' }} />
    <IconButton action="add" onPress={() => {}} variant={{ raised: true }} />
    <IconButton action="add" onPress={() => {}} variant={{ raised: true, size: 'large' }} />
  </StackView>
</Box>
```

## Feedback

<Feedback component="IconButton" />
