# React Native Activity Feed (Pro)

> A React Native activity feed for iOS, Android and the web: who did what and when, grouped by day, relative times, filter chips, unread dots with Mark all as read, quoted comments, Load more, and tappable names. Accessible, animated, themeable.

# Activity feed Pro

What happened, newest first: who did what to what, and when, as GitHub, Linear and Notion show it. Entries are headed by day, filtered by kind with chips, show unread dots with Mark all as read, quote comments, and page in older activity with Load more. Each entry is read as one sentence ("Maya commented on Q3 roadmap, 12 minutes ago"), and names and targets can be links.

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

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

const minutesAgo = (m) => new Date(Date.now() - m * 60000);
const activity = [
  { id: '1', actor: { name: 'Maya Cohen' }, action: 'commented on', target: 'Q3 roadmap', timestamp: minutesAgo(12), icon: 'message', content: 'Love the new onboarding flow. Can we ship the checklist first?', unread: true },
  { id: '2', actor: { name: 'Omer Levi', avatar: 'https://i.pravatar.cc/80?img=12' }, action: 'merged', target: 'PR #418', timestamp: minutesAgo(45), icon: 'checkCircle', color: 'success', meta: 'in patine/ui' },
  { id: '3', action: 'Deploy to production finished', timestamp: minutesAgo(90), icon: 'rocket', color: 'success' },
  { id: '4', actor: { name: 'Dana Mizrahi' }, action: 'assigned you', target: 'Fix flaky date test', timestamp: minutesAgo(1560), icon: 'userPlus' },
];

export default function Example() {
  return <ActivityFeed items={activity} title="Activity" onMarkAllRead={() => {}} style={{ width: 420 }} />;
}
```

## Example: a deal's history

A CRM's deal page: every email, call and stage change on one timeline, grouped by day. Pressing an entry opens it in the panel below.

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

const hoursAgo = (h: number) => new Date(Date.now() - h * 3600000);
const HISTORY = [
  { id: '1', actor: { name: 'You' }, action: 'moved the deal to', target: 'Negotiation', timestamp: hoursAgo(1), icon: 'arrowRight', color: 'success', content: 'Budget confirmed at €48k for year one.' },
  { id: '2', actor: { name: 'Ruth Adler' }, action: 'replied to', target: 'Proposal v2', timestamp: hoursAgo(3), icon: 'mail', content: 'Legal is reviewing the DPA. Can we keep the 30-day pilot?' },
  { id: '3', actor: { name: 'You' }, action: 'logged a call with', target: 'Ruth Adler', timestamp: hoursAgo(27), icon: 'phone', meta: '24 min' },
  { id: '4', actor: { name: 'Sam Okafor' }, action: 'sent', target: 'Proposal v2', timestamp: hoursAgo(50), icon: 'fileText' },
  { id: '5', action: 'Deal created from the website form', timestamp: hoursAgo(170), icon: 'plus' },
];

export default function Example() {
  const [open, setOpen] = useState<(typeof HISTORY)[number] | null>(null);
  return (
    <View style={{ width: '100%', maxWidth: 480, gap: 12 }}>
      <ActivityFeed items={HISTORY} title="Northwind · €48k" onItemPress={setOpen} />
      {open ? (
        <Box border radius="lg" padding="md" gap="xs">
          <Text weight="semibold">{[open.actor?.name, open.action, open.target].filter(Boolean).join(' ')}</Text>
          <Text color="textSecondary">{open.content ?? open.meta ?? 'No notes on this entry.'}</Text>
        </Box>
      ) : null}
    </View>
  );
}
```

## Entries

Each item is `{ id, actor?, action, target?, timestamp, icon?, color?, type?, content?, unread?, meta? }`. With an `actor` the entry shows their avatar with the `icon` badged on it; without one (a deploy, a payment) it shows the icon in a tinted circle. A string `content` is quoted under the sentence, cut after `contentLines`; any node is drawn as it is.

## Filters, unread and paging

`filters` shows chips above the feed; an entry shows under a filter when its `type` matches, and the first filter (usually `'all'`) shows everything. `filter` and `onFilterChange` control it. While anything is `unread`, the title shows the count and `onMarkAllRead` adds Mark all as read. `hasMore` with `onLoadMore` (and `loadingMore`) pages in older activity.

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

const minutesAgo = (m) => new Date(Date.now() - m * 60000);
const start = [
  { id: '1', actor: { name: 'Maya Cohen' }, action: 'commented on', target: 'Pricing page', timestamp: minutesAgo(3), icon: 'message', type: 'comment', unread: true },
  { id: '2', actor: { name: 'Omer Levi' }, action: 'pushed 3 commits to', target: 'main', timestamp: minutesAgo(20), icon: 'code', type: 'code', unread: true },
  { id: '3', actor: { name: 'Noa Peretz' }, action: 'invited', target: 'Avi', timestamp: minutesAgo(200), icon: 'userPlus', type: 'team' },
];
const filters = [
  { value: 'all', label: 'All' },
  { value: 'comment', label: 'Comments' },
  { value: 'code', label: 'Code' },
  { value: 'team', label: 'Team' },
];

export default function Example() {
  const [items, setItems] = React.useState(start);
  const [loading, setLoading] = React.useState(false);
  const loadMore = () => {
    setLoading(true);
    setTimeout(() => {
      setItems((list) => [...list, { id: String(list.length + 1), actor: { name: 'Dana Mizrahi' }, action: 'closed', target: `Issue #${300 + list.length}`, timestamp: minutesAgo(1500 + list.length * 60), icon: 'checkCircle', type: 'code' }]);
      setLoading(false);
    }, 800);
  };
  return (
    <ActivityFeed
      items={items}
      title="Team activity"
      filters={filters}
      onMarkAllRead={() => setItems((list) => list.map((i) => ({ ...i, unread: false })))}
      hasMore={items.length < 7}
      loadingMore={loading}
      onLoadMore={loadMore}
      onActorPress={(item) => alert(item.actor.name)}
      style={{ width: 440 }}
    />
  );
}
```

## Variants

`variant` is `'timeline'` (avatars joined by a line), `'list'` (rows split by hairlines) or `'cards'`. `groupByDay={false}` drops the day headings, and `timeFormat` shows `'relative'` (default), `'time'` or `'datetime'` times.

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

const minutesAgo = (m) => new Date(Date.now() - m * 60000);
const payments = [
  { id: '1', action: 'Payment received from', target: 'Acme Inc.', timestamp: minutesAgo(8), icon: 'dollar', color: 'success', meta: '$1,200.00' },
  { id: '2', action: 'Invoice sent to', target: 'Globex', timestamp: minutesAgo(64), icon: 'invoice', meta: 'INV-0042' },
  { id: '3', action: 'Payment failed for', target: 'Initech', timestamp: minutesAgo(180), icon: 'alert', color: 'danger', meta: 'Card declined' },
];

export default function Example() {
  return (
    <View style={{ flexDirection: 'row', gap: 24, flexWrap: 'wrap' }}>
      <ActivityFeed items={payments} variant="list" groupByDay={false} style={{ width: 340 }} />
      <ActivityFeed items={payments} variant="cards" timeFormat="time" groupByDay={false} density="compact" style={{ width: 340 }} />
    </View>
  );
}
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `ActivityItem[]` | — | `{ id, actor?: { name, avatar? }, action, target?, timestamp, icon?, color?, type?, content?, unread?, meta? }` |
| `variant` | `'timeline'` \| `'list'` \| `'cards'` | `'timeline'` | |
| `title` | `string` | — | A title with the unread count. |
| `groupByDay` | `boolean` | `true` | |
| `timeFormat` | `'relative'` \| `'time'` \| `'datetime'` | `'relative'` | |
| `locale` / `hour12` / `now` | | | |
| `filters` / `filter` / `defaultFilter` / `onFilterChange` | | | Filter chips by `type`. |
| `contentLines` | `number` | `3` | |
| `onItemPress` / `onActorPress` / `onTargetPress` | `(item) => void` | — | |
| `onMarkAllRead` | `() => void` | — | |
| `hasMore` / `loadingMore` / `onLoadMore` | | | Load more. |
| `renderItem` | `(info) => ReactNode` | — | |
| `loading` / `error` / `onRetry` / `emptyTitle` / `emptyDescription` / `renderEmpty` | | | States. |
| `density` / `animate` / `labels` / `design` / `theme` / `accessibilityLabel` / `style` | | | |
