---
title: Responsive
---

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

# Responsive

<LibraryInfo />

```jsx live
<Responsive min="sm" max="lg">
  <Typography>This text only shows between sm and lg viewports.</Typography>
  <Typography>Try resizing the screen if you don't see it.</Typography>
</Responsive>
```

## Introduction

The Responsive component shows its children only if the current viewport is within a given range.

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

## Guidance

Use the Responsive prop for content that should only be shown at certain viewports.

Normally, this should be non-essential cosmetic content, or content that is displayed differently in another Responsive component at the viewports where it is hidden.

### `min`

If a `min` prop is provided, the component's children will be hidden if the current viewport is smaller.

```jsx live
<Responsive min="md">
  <Typography>This text only shows on md viewport or above.</Typography>
  <Typography>Try resizing the screen if you don't see it.</Typography>
</Responsive>
```

### `max`

If a `max` prop is provided, the component's children will be hidden if the current viewport is larger.

```jsx live
<Responsive max="md">
  <Typography>This text only shows on md viewport or below.</Typography>
  <Typography>Try resizing the screen if you don't see it.</Typography>
</Responsive>
```

### Use on SSR

In SSR web apps, the viewport is assumed to be `xs` on the server-side render and the first client-side hydration, then if the real viewport is different, the component re-renders after hydration.

:::danger
Enabling `enableMediaQueryStyleSheet` will introduce breaking changes to the Responsive component.
The Responsive component traditionally relied on client-side JavaScript to toggle the visibility of its children without rendering any node specific to itself.
Enabling `enableMediaQueryStylesheet` alters the styling approach and could disrupt the expected behavior.
Please be aware of potential side effects and thoroughly test your application when making this change.
:::

### Alternatives

Responsive component uses the [useResponsiveProps hook](responsiveness), which can be used instead if more subtly is required than simply rendering or not rendering children.

### Accessibility

Responsive component doesn't render anything specific itself, so doesn't take any accessibility props.

Be careful to ensure that essential content is available somewhere at all viewports.

### Platform considerations

<AvailableOnBoth />

## Props

<PropsTable base={BaseDocs} />

## Figma

Responsive is an invisible utility component, so does not have designs.

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Responsive" />
