# SplitBar

Splits one total between two parts, with a legend under the bar.

[View source and API](https://github.com/tempoxyz/ds/blob/main/src/web/components/SplitBar.tsx)

Figma: [Data/Split Bar](https://www.figma.com/design/yE96kcymnNR88PJp6G1sPs?node-id=5227-4474)

## Overview

A split bar renders a thin bar that two parts share in proportion to their values, and a legend that names each part with its value. A part of zero draws no segment, so the other part fills the bar.

## Examples

### Basic

```tsx
import { SplitBar } from '@tempoxyz/ds'

export function Demo() {
  return (
    <SplitBar
      items={[
        { label: 'Available', text: '$75.62', value: 75.62 },
        { label: 'Agents', text: '$8.58', value: 8.58 },
      ]}
    />
  )
}
```

[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SplitBar/Basic.tsx)

### One Part

A part of 0 keeps its legend entry and draws no segment.

```tsx
import { SplitBar } from '@tempoxyz/ds'

export function Demo() {
  return (
    <SplitBar
      items={[
        { label: 'Available', text: '$75.62', value: 75.62 },
        { label: 'Agents', text: '$0.00', value: 0 },
      ]}
    />
  )
}
```

[View example source](https://github.com/tempoxyz/ds/blob/main/docs/src/examples/demos/SplitBar/Empty.tsx)

## Anatomy

Import the component and assemble its parts.

```tsx
import { SplitBar } from '@tempoxyz/ds'

<SplitBar />
```

## Guidelines

### When to Use

* Show how a balance splits between two uses, such as the available funds and the funds set aside for agents.

### When Not to Use

* Use [BarChart](/docs/components/bar-chart) for values over time.
* Use [Progress](/docs/components/progress) for the progress of one task.
* Use [Gauge](/docs/components/gauge) for one value against a limit.

### Show the Values

**Do:** Give each part its amount, in the unit people act on.

```tsx
import { SplitBar } from '@tempoxyz/ds'

export function Demo() {
  return (
    <SplitBar
      items={[
        { label: 'Available', text: '$75.62', value: 75.62 },
        { label: 'Agents', text: '$8.58', value: 8.58 },
      ]}
    />
  )
}
```

**Don't:** Show percentages alone when people act on amounts.

```tsx
import { SplitBar } from '@tempoxyz/ds'

export function Demo() {
  return (
    <SplitBar
      items={[
        { label: 'Available', text: '90%', value: 90 },
        { label: 'Agents', text: '10%', value: 10 },
      ]}
    />
  )
}
```

## Content

### Name the Parts

Name each part with one or two words, such as Available and Agents. Format each value as the rest of the page does, such as $75.62.

## Accessibility

A split bar renders a `<div>` whose bar is hidden from screen readers. The legend carries each label and value as text, in reading order.

### Semantics

* **Bar (aria-hidden):** Screen readers skip the bar and read the legend.

### Your Responsibilities

* **Name the Total (SC 1.3.1):** Place a heading or a label before the bar that names what it splits.

## Related

[BarChart](/docs/components/bar-chart)

Use for values over time.

[Progress](/docs/components/progress)

Use for the progress of one task.
