Paste

Design System

Flex

A primitive component that can be used to build flexbox based elements and layouts.

Status
beta
Version
0.1.2
Sources
Install
yarn add @twilio-paste/flex

Guidelines#

Flex is a utility component that allows you to build flexbox based elements and layouts. These flexible elements and layouts allow your components to adapt to the available space or screen size.

About Flex#

Flex utilizes a simplified flexbox API that allows you more efficient ways to layout, align, and distribute space among elements in a container. The Flex API helps take the confusion out of using flexbox CSS properties, by giving you simple methods to change properties like flex, flex-direction, flex-wrap, and so on.

Flexible elements can adapt to fill space within the layout. This allows Flex to work well for product layouts or elements that change orientation, resize, stretch, or shrink.

The Flex API was created because flexbox can be a difficult CSS property to wrap your head around, which leads to confusion on how it all works. If you’d like to learn more about flexbox, the learning resources below provide further information:

Accessibility#

The Flex component is an all purpose component. By default, it has no accessibility concerns. If you use the Flex as a custom element, it is up to you to manage the resulting accessibility implications.

Examples#

Left area
Right area

Flex Properties#

Left area
Right area

Vertical Property#

Left area
Right area

Wrap Property#

Left area
Right area

Vertical Alignment Properties#

Left area
Right area

Horizontal Alignment Properties#

Left area
Right area

Composition Notes#

The Flex component is used to compose flexible layout experiences. Let's look at an example where we need to build a flexible content layout with two sidebars: its has a left sidebar, a content area, and a right sidebar. Here's how we’ll compose the flexible layout using Flex:

Left sidebar area
Content area
Right sidebar area

When to use Flex#

The Flex component should be used when a flexible layout is needed with a page layout or custom component layout.

Do

Use Flex to layout your page or custom component.

Don't

Use Flex to set margins or padding within layouts and components.

Do

Use Flex to build responsive experiences.

Don't

Use inline CSS or classNames to add styles that Flex can provide.


Usage Guide#

API#

Installation#

yarn add @twilio-paste/flex

Usage#

import {Flex} from '@twilio-paste/flex';
<Flex>
Foo
</Flex>

Props#

PropTypeDescriptionDefault
display?string, ResponsiveValue<'flex', 'inline-flex'>Display property'flex'
basis?string, number, ResponsiveValue<string, number>Flex basis property
grow?boolean, number, ResponsiveValue<boolean, number>Flex grow property
shrink?string, number, ResponsiveValue<string, number>Flex shrink property
hAlignContent?string, number, ResponsiveValue<string, number>Horizontal alignment property
vAlignContent?string, number, ResponsiveValue<string, number>Vertical alignment property
vertical?boolean, number, ResponsiveValue<boolean, number>Flex direction property
wrap?boolean, number, ResponsiveValue<boolean, number>Flex wrap property

Change Log

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

0.1.2 (2020-01-17)

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

0.1.1 (2019-12-20)

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

0.1.0 (2019-12-19)

Bug Fixes#

  • add prop-types package, add description, bump types (#234) (c97d878)

Features#