---
title: Paragraph
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, PropsTable, TokensTable } from '../../src/components'
import { Paragraph as WebDocs } from 'docs/@telus-uds/components-web'
import AvailableOnWebOnly from '../../partials/_platform-considerations-web-only.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Paragraph

<LibraryInfo
  packageType="Web Component"
  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%3D7549%253A149618"
/>

```jsx live
<Paragraph>Our commitment to service is demonstrated in everything we do.</Paragraph>
```

## Introduction

Paragraph renders a block of text as an HTML `<p>` paragraph element.

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

## Guidance

All body text on Web should be contained in a **Paragraph**, regardless of length.

### Spacing

Paragraphs have a default spacing of one line applied above and below, unless they are the first or last child in a container.

This ensures that body text is neatly spaced without distorting the height or padding of a container.

```jsx live
<Card variant={{ padding: 'compact' }}>
  <Paragraph>Space after but not before this initial paragraph.</Paragraph>
  <Paragraph>One line of space around the first middle paragraph.</Paragraph>
  <Paragraph>One line of space around the second middle paragraph.</Paragraph>
  <BlockQuote additionalInfo="The space comes from the paragraphs before and after">
    This blockquote doesn't set any space around itself
  </BlockQuote>
  <Paragraph>Space before but not after this final paragraph.</Paragraph>
</Card>
```

#### `linesBetween` prop

This default spacing may be overridden with the prop `linesBetween` (default: `1`). This should only be used in unusual cases, for example, to set the spacing to 0 if a sibling has its own spacing, or if a design requires wider spacing than usual.

Paragraph spacing uses [CSS margin collapsing](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing), so in cases where adjacent paragraphs have different lines between set, the wider will apply.

```jsx live
<Card variant={{ padding: 'compact' }}>
  <Paragraph linesBetween={0}>
    Zero lines around this paragraph - no gap between it and the divider.
  </Paragraph>
  <Divider variant={{ decorative: true }} />
  <Paragraph>Default of one line is applied around this paragraph.</Paragraph>
  <Paragraph linesBetween={2}>
    This paragraph's two lines collapse the previous paragraph's one line.
  </Paragraph>
</Card>
```

### Accessibility

#### Semantic tag

Paragraph renders a semantic `<p>` paragraph tag. Assistive technology tools may have features specific to paragraphs, such as tools to help navigate multiple-paragraph passages of text.

#### Text alignment

Paragraph has an `align` prop, but for the vast majority of cases it should not be used: text is most readable in the default alignment.

In particular, aligning body text with "justify" should be avoided because it usually increases the difficulty for readers to visually track text.

See [W3C guidance](https://www.w3.org/WAI/GL/low-vision-a11y-tf/wiki/Supplemental_Guidance:_Text_Justification) for more details.

### Platform considerations

<AvailableOnWebOnly />

`<p>` tags and first/last-child styling are not supported in React Native Web, so this component uses a web-only implementation. See [Typography](typography) for cross-platform themed text using React Native's `<Text>`.

## Props

<PropsTable web={WebDocs} />

## Tokens

As Paragraph uses the Typography theme, it accepts the same [tokens as Typography](typography#tokens).

<TokensTable base={WebDocs} component="Typography" />

## Variants

Paragraph has the same [theme variants as Typography](typography#variants), but without header-like sizes or compact.

### Size

```jsx live
<>
  <Paragraph variant={{ size: 'large' }}>Paragraph with variant size large text.</Paragraph>
  <Paragraph>Paragraph with default size medium text.</Paragraph>
  <Paragraph variant={{ size: 'small' }}>Paragraph with variant size small text.</Paragraph>
  <Paragraph variant={{ size: 'micro' }}>Paragraph with variant size micro text.</Paragraph>
</>
```

### Inverse

As with Typography, inverse variant must be used on dark backgrounds.

```jsx live dark
<div style={{ backgroundColor: 'black', padding: '1rem' }}>
  <Paragraph variant={{ size: 'large', inverse: true }}>
    Inverse paragraph with variant size large text.
  </Paragraph>
  <Paragraph variant={{ inverse: true }}>
    Inverse paragraph with default size medium text.
  </Paragraph>
  <Paragraph variant={{ size: 'small', inverse: true }}>
    Inverse paragraph with variant size small text.
  </Paragraph>
  <Paragraph variant={{ size: 'micro', inverse: true }}>
    Inverse paragraph with variant size micro text.
  </Paragraph>
</div>
```

### Secondary colour

```jsx live
<>
  <Paragraph variant={{ size: 'large', colour: 'secondary' }}>
    Secondary paragraph with variant size large text.
  </Paragraph>
  <Paragraph variant={{ colour: 'secondary' }}>
    Secondary paragraph with default size medium text.
  </Paragraph>
  <Paragraph variant={{ size: 'small', colour: 'secondary' }}>
    Secondary paragraph with variant size small text.
  </Paragraph>
  <Paragraph variant={{ size: 'micro', colour: 'secondary' }}>
    Secondary paragraph with variant size micro text.
  </Paragraph>
</>
```

### Bold

Entirely bold paragraphs should usually be avoided. One exception is short, important paragraphs in long passages of many paragraphs.

It is usually more impactful to pick out a few choice words by nesting bold typography inside a paragraph.

```jsx live
<>
  <Paragraph>This is a long passage of text.</Paragraph>
  <Paragraph>
    It is a rare case where it is regrettably unavoidable that it contains a large number of
    paragraphs.
  </Paragraph>
  <Paragraph variant={{ bold: true }}>This line is especially important.</Paragraph>
  <Paragraph>Bold must be used sparingly, else it becomes less impactful.</Paragraph>
  <Paragraph>
    It is often better to pick out a{' '}
    <Typography variant={{ bold: true }} tag="strong">
      few choice words
    </Typography>{' '}
    in bold, rather than a whole paragraph.
  </Paragraph>
</>
```

## Feedback

<Feedback component="Paragraph" />
