Design System

Aspect Ratio

yarn add @twilio-paste/aspect-ratio


About Aspect Ratio#

The Aspect Ratio component dynamically modifies the height of an element based on its current width to match a width-to-height ratio. For example, a 4:3 ratio would make an element with a width of 400px have a height of 300px. This updates in real time when you resize the screen.

Composition Notes#

Aspect Ratio must contain exactly one child element. The child element should be sized fully to the Aspect Ratio bounding box so that it resizes correctly. One way of achieving this is through the Absolute component.

Be considerate of smaller devices when using this component. If necessary, you can modify the aspect ratio property at certain media query breakpoints.

When to use Aspect Ratio#

Aspect Ratio can be used to embed images and videos.

Use Aspect Ratio to make sure images and videos are scaled correctly on displays of various sizes. For example, you can use Aspect Ratio when a customer needs to see a preview of an uploaded document.

Aspect Ratio can also be used to embed components, or other HTML elements that needs to be set to a specific width-to-height ratio. A component or other HTML element use case is the need to align an HTML element with an image in two columns.

Another use case is for color swatches on a documentation site. These color swatches could be a specific height/width div that need to resize on specific devices. Aspect Ratio will allow the color swatches to resize correctly based on a ratio.


Use for an image or embedded video, and have it resize at a specific ratio.


Don’t use with fixed size (width & height) elements, as those will not adhere to the width-to-height ratio.


Use to embed a component or other HTML element.


Don’t use without any child elements, because this is only a container element.

Usage Guide#



yarn add @twilio-paste/aspect-ratio


import {AspectRatio} from '@twilio-paste/aspect-ratio';
<AspectRatio ratio="4:3">


ratiostringDetermines the aspect ratio of the element. Use a colon separated number pattern (width:height). Required4:3

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.0.14 (2020-02-14)

Bug Fixes#

  • aspect-ratio: add missing peer deps (5e1000d)

1.0.13 (2020-02-13)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.12 (2020-02-11)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.11 (2020-02-11)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.10 (2020-02-11)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.9 (2020-02-03)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.8 (2020-01-24)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.7 (2020-01-17)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.6 (2019-12-20)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.5 (2019-12-19)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.4 (2019-12-05)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.3 (2019-11-20)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.2 (2019-11-18)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.1 (2019-11-12)

Note: Version bump only for package @twilio-paste/aspect-ratio

1.0.0 (2019-11-11)


  • icons: delete old icons, add new streamline icons (#129) (571791d)


  • icons: removed all the inherited icons since we're moving to a new system

  • chore(icons): update icon list for storybook

  • fix(spinner): use new icon

  • fix(storybook): use new icon for story

  • fix(story): button icons should be 24px

  • fix: adjust icon size tokens

  • feat: add iconSizes as separate key in theme-tokens

  • feat(icons): icons package to use tokens and update icons

  • fix(spinner): update to use tokens and new icons

  • fix(button): use correct spinner size

  • fix(icons): major icons package fixes

  • huge overhaul to build process
  • now uses rollup
  • builds into cjs and esm directories
  • made the package publishable to npm
  • moved svg folder out of src, now src only holds react stuff
  • updated scripts to use new paths and cleaned up the code
  • programmatically generates rollup config from the icon-list command
  • chore: add new icons dist folders to gitignore

  • fix: spinner and button icon usage

  • feat(icons): add rollup icon list cache file

  • fix(core-bundle): sort packages for consistent builds

  • chore: use esm instead of es in rollup for correctness

  • chore: yarn.lock

  • fix(spinner): lint error

  • chore(icons): move rollup icon list

  • chore(spinner): use types package in story

  • fix(spinner): swap out destructured props for explicit props

0.2.1 (2019-10-31)

Note: Version bump only for package @twilio-paste/aspect-ratio

0.2.0 (2019-10-29)


0.1.1 (2019-09-16)#

Bug Fixes#

  • website: composable do-dont, add anchor examples (#81) (a799f1b)