Engineering Guidelines for Paste

Notes on how to install and use Paste


Installation#

The best way to use Paste is by using the core package. Paste Core provides all of the current Paste components which are ready for use.

Paste Core requires external dependencies, and other Paste system packages in order to function properly.

Install the following dependencies using yarn:

Install External dependencies#

The list of external third party dependencies are as follows:

PackageVersion
react^16.8.6
react-dom^16.8.6
prop-types^15.7.2
react-uid^2.2.0

Install them using:

yarn add react react-dom prop-types react-uid

Install Paste System packages#

Paste also requires these system dependencies:

PackageVersion
@twilio-paste/types3.0.24
@twilio-paste/style-props1.6.4
@twilio-paste/design-tokens6.3.2
@twilio-paste/theme3.2.21
@twilio-paste/icons3.5.2
@twilio-paste/styling-library0.1.2
@twilio-paste/animation-library0.2.1
@twilio-paste/dropdown-library1.0.0
@twilio-paste/reakit-library0.7.1

Install them using:

yarn add @twilio-paste/types @twilio-paste/style-props @twilio-paste/design-tokens @twilio-paste/theme @twilio-paste/icons @twilio-paste/styling-library @twilio-paste/animation-library @twilio-paste/dropdown-library @twilio-paste/reakit-library

Install the Paste Core package#

Finally, install Paste Core.

PackageVersion
@twilio-paste/core2.16.55
yarn add @twilio-paste/core

Paste Core includes all Paste components in a single bundle. This is extremely useful if you are committed to using all Paste components and want an easy way to keep up to date with library updates.

🚨 ATTENTION!! 🚨

If you're using Paste core there is no need to include individual component packages that are listed below. You've already got them. Just import the named component from @twilio-paste/core.

Paste Core includes:#
PackageVersion
@twilio-paste/absolute^2.0.70
@twilio-paste/alert^1.0.20
@twilio-paste/anchor^1.2.5
@twilio-paste/aspect-ratio^1.0.70
@twilio-paste/avatar^0.2.12
@twilio-paste/box^2.10.4
@twilio-paste/button^2.3.9
@twilio-paste/card^1.3.64
@twilio-paste/combobox^1.3.21
@twilio-paste/combobox-primitive^0.1.6
@twilio-paste/disclosure^0.2.23
@twilio-paste/disclosure-primitive^0.2.3
@twilio-paste/flex^0.3.57
@twilio-paste/form^2.2.16
@twilio-paste/grid^0.2.59
@twilio-paste/heading^2.0.39
@twilio-paste/list^0.2.39
@twilio-paste/media-object^1.2.57
@twilio-paste/menu^1.1.22
@twilio-paste/menu-primitive^0.1.9
@twilio-paste/modal^1.0.22
@twilio-paste/modal-dialog-primitive^0.1.6
@twilio-paste/non-modal-dialog-primitive^0.2.6
@twilio-paste/paragraph^1.1.40
@twilio-paste/popover^1.0.21
@twilio-paste/screen-reader-only^1.1.12
@twilio-paste/separator^0.2.7
@twilio-paste/spinner^2.0.16
@twilio-paste/stack^0.1.38
@twilio-paste/tabs^0.3.14
@twilio-paste/tabs-primitive^0.1.8
@twilio-paste/text^2.3.4
@twilio-paste/tooltip^0.3.3
@twilio-paste/tooltip-primitive^0.1.4
@twilio-paste/truncate^1.0.11

Usage#

Once Paste Core and its dependencies are installed, you can import the Paste Theme at the root of your application:

import {Theme} from '@twilio-paste/theme';
// Wrap your root component with the Theme.Provider like so:
const App = () => (
<Theme.Provider theme="default">
<RestOfYourAppInHere />
</Theme.Provider>
);

Now you can use the Paste themed and tokenized components anywhere in your app:

import {Box} from '@twilio-paste/core';
const Component = () => (
<Box margin="space20" backgroundColor="colorBackground">
Hello Paste!
</Box>
);

The Paste tokens are readily available on our components and typescript typings are provided.

Jest / Testing#

Just like rendering Paste components in a web application, when rendering components for the purposes of testing you are required to wrap them in the theme provider. If you do not, your components may fail to render correctly.

Using Icons#

The Paste Icons package provides icon components. They can be used to enhance the appearance of a web interface and break up the monotony of text. Icons have to be imported individually.

Install Paste Icons using yarn:

PackageVersion
@twilio-paste/icons3.5.2
yarn add @twilio-paste/icons

Then you can use an icon inside your app:

import {PlusIcon} from '@twilio-paste/icons/esm/PlusIcon';
const Component = () => (
<Button variant="secondary" size="small" onClick={() => {}}>
<PlusIcon decorative={true} />
Add to cart
</Button>
);

For more information about our icon system, checkout our usage guide here.

You can view and play with icons on our storybook icon list. Our icon set is still limited, and more will be added over time. Please file an icon request or follow the guide on how to add an icon.

Global Styles#

Many apps/websites utilize global stylesheets. Even though Paste styles are scoped at the component level, global styles can creep in and cause some havoc. Make sure to thoroughly test Paste components to verify everything looks as they should.

Fonts#

Paste leaves it up to you to load the fonts needed for the theme you've selected. Console uses Whitney ScreenSmart and SendGrid uses Colfax. More often than not you are working within existing SendGrid and Twilio Console applications and these fonts are automatically loaded for you.

Special note on Whitney#

The Whitney font is loaded by the Typography.com service and is only allowed on *.twilio.com domains as well as localhost. Make sure to serve your app from the correct hostname if you're having issues with font loading.

If you are not working in an existing Twilio Console experience, you can include the following link element in your sites head to load these fonts if you are serving your application from *.twilio.com domains.

<link rel="stylesheet" type="text/css" href="//cloud.typography.com/6230892/752864/css/fonts.css">

Special note on Inter#

The default theme (UDL theme) uses Inter as its primary font family. This is a free font that is hosted on Google Fonts. Feel free to copy how we load the font into your own app if you are using the default theme.

Support

If you need support, please open a new issue in our GitHub repository. Please try to provide as much detail as possible in your issue.

Contributing

The Paste design system is open source and contributions are welcome. Check out the project on GitHub to learn more about contributing.

Copyright © 2020 Twilio, Inc.