# React Native Order Tracker, delivery status (Pro)

> A React Native order tracker for iOS, Android and the web: the arrival day, status badge, a progress bar or step line to the step reached, delayed and failed states, carrier and copyable tracking number, and the carrier's scan history. Accessible and animated.

# Order tracker Pro

Where an order is, as Shop and Amazon show it: the arrival day up top ("Arriving tomorrow"), the status in a badge, a bar that fills to the step it has reached, the carrier with a copyable tracking number, and the carrier's scans under Tracking history. The bar is a progress bar for screen readers ("Step 3 of 4: Out for delivery").

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

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

const tomorrow = new Date(Date.now() + 86400000);
const minutesAgo = (m) => new Date(Date.now() - m * 60000);
const scans = [
  { time: minutesAgo(40), description: 'Out for delivery', location: 'Brooklyn, NY' },
  { time: minutesAgo(540), description: 'Arrived at facility', location: 'Newark, NJ' },
  { time: minutesAgo(1500), description: 'Shipped', location: 'Edison, NJ' },
];

export default function Example() {
  return (
    <OrderTracker
      current="out"
      eta={tomorrow}
      orderNumber="#10482"
      carrier="UPS"
      trackingNumber="1Z999AA10123456784"
      events={scans}
      style={{ width: 420 }}
    />
  );
}
```

## Example: a delayed parcel

An order page when something went wrong: the carrier missed a scan, so the tracker shows the delay, the newest scans are open, and the actions offer the next useful step.

```tsx live
import { useState } from 'react';
import { View } from 'react-native';
import { Button, Text } from 'patine-ui';
import { OrderTracker } from '@patine-ui/pro';

const hoursAgo = (h: number) => new Date(Date.now() - h * 3600000);
const SCANS = [
  { time: hoursAgo(5), description: 'Delayed: missed connection at the hub', location: 'Utrecht, NL' },
  { time: hoursAgo(19), description: 'Arrived at the sorting hub', location: 'Utrecht, NL' },
  { time: hoursAgo(31), description: 'Shipped', location: 'Venlo, NL' },
];

export default function Example() {
  const [asked, setAsked] = useState(false);
  return (
    <View style={{ width: '100%', maxWidth: 440, gap: 8 }}>
      <OrderTracker
        current="shipped"
        status="delayed"
        eta={new Date(Date.now() + 2 * 86400000)}
        orderNumber="#20417"
        carrier="PostNL"
        trackingNumber="3SABC1234567890"
        events={SCANS}
        eventsOpen
        actions={
          <View style={{ flexDirection: 'row', gap: 8, flexWrap: 'wrap' }}>
            <Button size="sm" variant="outline" onPress={() => setAsked(true)}>
              Deliver to a pickup point
            </Button>
            <Button size="sm" variant="ghost">Contact us</Button>
          </View>
        }
      />
      {asked ? <Text size="sm" color="success">We asked PostNL to send it to your nearest pickup point.</Text> : null}
    </View>
  );
}
```

## Steps and status

The default steps are Ordered, Shipped, Out for delivery and Delivered; pass your own `steps` (`{ key, label, description?, time?, icon? }`). `current` is the reached step's key or index. `status` colors the bar and badge: `'active'`, `'delayed'`, `'exception'`, `'cancelled'` or `'delivered'` (the default once the last step is reached). `deliveredAt` turns the headline into "Delivered Mon, Mar 9".

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

const steps = [
  { key: 'confirmed', label: 'Confirmed', icon: 'checkCircle' },
  { key: 'preparing', label: 'Preparing', icon: 'coffee' },
  { key: 'ready', label: 'Ready for pickup', icon: 'bag' },
];

export default function Example() {
  return (
    <View style={{ gap: 16, width: 420 }}>
      <OrderTracker steps={steps} current="preparing" orderNumber="A-17" />
      <OrderTracker current={1} status="delayed" eta={new Date(Date.now() + 3 * 86400000)} orderNumber="#10391" />
      <OrderTracker current={3} deliveredAt={new Date(Date.now() - 86400000)} orderNumber="#10220" />
    </View>
  );
}
```

## Down a line

`orientation="vertical"` draws the steps down a [Timeline](./timeline), each with its time, for a page of its own. `variant="plain"` drops the card.

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

const hoursAgo = (h) => new Date(Date.now() - h * 3600000);
const steps = [
  { key: 'ordered', label: 'Ordered', time: hoursAgo(50), icon: 'receipt' },
  { key: 'shipped', label: 'Shipped', time: hoursAgo(20), description: 'UPS Ground', icon: 'package' },
  { key: 'out', label: 'Out for delivery', icon: 'truck' },
  { key: 'delivered', label: 'Delivered', icon: 'home' },
];

export default function Example() {
  return (
    <OrderTracker
      steps={steps}
      current="shipped"
      orientation="vertical"
      eta={new Date(Date.now() + 2 * 86400000)}
      actions={
        <>
          <Button variant="outline" size="sm">Contact support</Button>
          <Button variant="ghost" size="sm">Return items</Button>
        </>
      }
      style={{ width: 380 }}
    />
  );
}
```

## Copying the tracking number

The copy button uses the browser's clipboard on the web. On iOS and Android pass your clipboard library's function: `onCopyTracking={Clipboard.setStringAsync}` from `expo-clipboard`. `onTrackingPress` makes the number a link to the carrier.

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `current` | `string` \| `number` | — | The step reached, by key or index. |
| `steps` | `OrderStep[]` | Ordered → Delivered | `{ key, label, description?, time?, icon? }` |
| `status` | `'active'` \| `'delayed'` \| `'exception'` \| `'cancelled'` \| `'delivered'` | `'active'` | |
| `orientation` | `'horizontal'` \| `'vertical'` | `'horizontal'` | |
| `variant` | `'card'` \| `'plain'` | `'card'` | |
| `orderNumber` | `string` | — | |
| `eta` / `deliveredAt` | `Date` \| `string` | — | The headline. |
| `carrier` / `trackingNumber` | `string` | — | |
| `onCopyTracking` / `onTrackingPress` | | | |
| `events` | `{ id?, time, description, location? }[]` | — | Tracking history, newest first. |
| `eventsOpen` / `defaultEventsOpen` / `onEventsOpenChange` | `boolean` | `false` | |
| `actions` | `ReactNode` | — | Buttons under the tracker. |
| `locale` / `hour12` / `now` | | | |
| `loading` / `error` / `onRetry` | | | States. |
| `density` / `animate` / `labels` / `design` / `theme` / `style` | | | |
