# React Native Status Tracker (Pro)

> A React Native status tracker for iOS, Android and the web: a row of bars coloured by status, as uptime pages show service health, with each period's details by touch, pointer or keyboard, and a screen-reader count of each status.

# Status tracker Pro

A row of bars, one per period, coloured by status: a service's uptime or a habit's streak at a glance, as status pages draw it. Press, hover or arrow through it for each period's details. Screen readers hear how many periods had each status.

```tsx
import { StatusTracker } from '@patine-ui/pro';
```

```tsx live
import { StatusTracker } from '@patine-ui/pro';

const days = Array.from({ length: 45 }, (_, i) => ({
  status: i === 12 ? 'error' : i === 30 || i === 31 ? 'warning' : 'ok',
  tooltip: `Day ${i + 1}${i === 12 ? ': 14 min down' : ''}`,
}));

export default function Example() {
  return <StatusTracker data={days} accessibilityLabel="API uptime, last 45 days" style={{ width: 360 }} />;
}
```

## Example: a status page

A service's public status page: one row per component over the last 60 days, its uptime beside the name, and each bar's tooltip says what happened that day.

```tsx live wide
import { HStack, Text, VStack } from 'patine-ui';
import { StatusTracker } from '@patine-ui/pro';

const day = (n: number) => new Date(Date.now() - (59 - n) * 86400000).toLocaleDateString(undefined, { month: 'short', day: 'numeric' });
const history = (incidents: Record<number, ['warning' | 'error', string]>) =>
  Array.from({ length: 60 }, (_, i) => ({
    status: incidents[i]?.[0] ?? 'ok',
    tooltip: `${day(i)}: ${incidents[i]?.[1] ?? 'No incidents'}`,
  }));

const SERVICES = [
  { name: 'API', uptime: '99.98%', data: history({ 17: ['error', '12 min outage'], 44: ['warning', 'Slow responses for 40 min'] }) },
  { name: 'Dashboard', uptime: '100%', data: history({}) },
  { name: 'Webhooks', uptime: '99.91%', data: history({ 30: ['warning', 'Delayed deliveries'], 31: ['warning', 'Delayed deliveries'], 52: ['error', '38 min outage'] }) },
];

export default function Example() {
  return (
    <VStack gap="lg" style={{ width: '100%' }}>
      {SERVICES.map((s) => (
        <VStack key={s.name} gap="xs">
          <HStack justify="space-between">
            <Text weight="medium">{s.name}</Text>
            <Text size="sm" color="textSecondary">{s.uptime} uptime</Text>
          </HStack>
          <StatusTracker data={s.data} height={28} showLegend={false} accessibilityLabel={`${s.name}, last 60 days`} />
        </VStack>
      ))}
    </VStack>
  );
}
```

## Statuses

The defaults are an uptime page's: `ok` (Operational, the theme's success colour), `warning` (Degraded), `error` (Down, danger) and `none` (No data). Pass `statuses` to name and colour your own; a colour is a theme colour name or any CSS colour.

```tsx
<StatusTracker
  data={habit}
  statuses={{ done: { label: 'Done', color: 'primary' }, missed: { label: 'Missed', color: 'border' } }}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data` | `{ status, tooltip? }[]` | — | One bar per period, oldest first. |
| `statuses` | `Record<string, { label, color }>` | uptime statuses | |
| `height` | `number` | `32` | |
| `width` | `number` | fills the container | |
| `showLegend` | `boolean` | `true` | Each status with its count. |
| `showTooltip` | `boolean` | `true` | |
| `accessibilityLabel` | `string` | — | |
| `animate` | `boolean` | `true` | |
| `loading` | `boolean` | `false` | A pulsing placeholder in place of the bars. |
| `theme` / `design` | | provider's | Bar gaps and corners follow the design. |
