# Text

One component for any paragraph or line of body text.

```tsx
import { Text } from '@halo-ds/react';
```

## When to use it
Use Text whenever you need body copy: paragraphs, descriptions, captions, and the default content of slots such as the Accordion. It is built on the Body text styles and colour tokens, so it stays consistent and works in dark mode.

Pick a size, a weight and a colour, and edit the words with the Text property. For headings, use the Heading text styles instead.

## Do
- Use Text for body copy and slot content.
- Keep lines between about 45 and 80 characters for reading.
- Use Secondary for supporting details only.
- Use the Heading text styles for titles.

## Don't
- Set important information in Secondary; it is the quietest colour.
- Use Semibold for whole paragraphs.
- Mix several sizes in one paragraph.
- Detach Text to change its colour; switch the Colour property instead.

## Props
### Text props
| Prop | Type | What it does |
| --- | --- | --- |
| `size` | `TextSize \| undefined` | lg 16/24, md 14/22 (default), sm 12/20. Figma: Size. |
| `weight` | `TextWeight \| undefined` | Figma: Weight. |
| `color` | `TextColor \| undefined` | Figma: Colour. |
| `as` | `"label" \| "p" \| "span" \| "div" \| "small" \| undefined` | The element to render. Defaults to a paragraph. |
| `children` (required) | `ReactNode` |  |
It also takes the usual HTML attributes for its element.

## Examples
### Overview
```tsx
import { Text } from '@halo-ds/react';

export default function Example() {
  return (
    <div style={{ display: 'grid', gap: 8, maxWidth: 420 }}>
      <Text size="lg" weight="semibold">Quarterly report</Text>
      <Text>Revenue grew in every region this quarter, led by online sales.</Text>
      <Text size="sm" color="secondary">Updated 2 hours ago</Text>
    </div>
  );
}
```

### Sizes and weights
Large for reading, medium for most text, small for captions. Semibold for short emphasis.
```tsx
import { Text } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-stack" style={{ maxWidth: 420 }}>
      <Text size="lg">Large: for longer reading.</Text>
      <Text size="md">Medium: most interface text.</Text>
      <Text size="sm">Small: captions and metadata.</Text>
      <Text weight="semibold">Semibold: a name or a short label.</Text>
    </div>
  );
}
```

### Colours
Primary for main text, contrast for descriptions, secondary for captions.
```tsx
import { Text } from '@halo-ds/react';

export default function Demo() {
  return (
    <div className="demo-stack" style={{ maxWidth: 420 }}>
      <Text color="primary">Primary: the main text.</Text>
      <Text color="contrast">Contrast: descriptions under a title.</Text>
      <Text color="secondary">Secondary: dates and other metadata.</Text>
    </div>
  );
}
```

More: https://halodesignsystem.dev/components/text
