# Category filter chips

> React Native category filter chips that scroll sideways and reveal the next category on tap, filtering a list below, built with ChipGroup.

A row of category chips above a menu, like a food or shop app. There are more categories than fit, so the row scrolls; tap the last visible chip and the next one slides into view, so people find the rest without guessing.

```tsx live device
import { useState } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { ChipGroup, useTheme } from 'patine-ui';
import { Icon } from '@patine-ui/icons';

const CATEGORIES = [
  { label: 'All', value: 'all', icon: <Icon name="grid" size="sm" /> },
  { label: 'Breakfast', value: 'breakfast', icon: <Icon name="coffee" size="sm" /> },
  { label: 'Salads', value: 'salads' },
  { label: 'Pizza', value: 'pizza' },
  { label: 'Burgers', value: 'burgers' },
  { label: 'Sushi', value: 'sushi' },
  { label: 'Desserts', value: 'desserts' },
  { label: 'Drinks', value: 'drinks' },
];

const MENU = [
  { name: 'Croissant', category: 'breakfast', price: 4 },
  { name: 'Shakshuka', category: 'breakfast', price: 12 },
  { name: 'Greek salad', category: 'salads', price: 11 },
  { name: 'Margherita', category: 'pizza', price: 14 },
  { name: 'Smash burger', category: 'burgers', price: 15 },
  { name: 'Salmon roll', category: 'sushi', price: 13 },
  { name: 'Cheesecake', category: 'desserts', price: 8 },
  { name: 'Lemonade', category: 'drinks', price: 5 },
];

export default function Example() {
  const { colors } = useTheme();
  const [category, setCategory] = useState('all');
  const dishes = category === 'all' ? MENU : MENU.filter((d) => d.category === category);
  return (
    <View style={[styles.screen, { backgroundColor: colors.background }]}>
      <ChipGroup
        items={CATEGORIES}
        value={category}
        onValueChange={setCategory}
        accessibilityLabel="Categories"
      />
      {dishes.map((dish) => (
        <View key={dish.name} style={[styles.row, { borderColor: colors.border }]}>
          <Text style={[styles.dish, { color: colors.text }]}>{dish.name}</Text>
          <Text style={[styles.dish, { color: colors.textSecondary }]}>${dish.price}</Text>
        </View>
      ))}
    </View>
  );
}

const styles = StyleSheet.create({
  screen: { flex: 1, gap: 4, paddingVertical: 20 },
  row: {
    flexDirection: 'row',
    justifyContent: 'space-between',
    paddingVertical: 10,
    paddingHorizontal: 4,
    marginHorizontal: 16,
    borderBottomWidth: StyleSheet.hairlineWidth,
  },
  dish: { fontSize: 15 },
});
```

## How it works

- `variant="chips"` shows separate pills; leave it out for a segmented control (good for 2–5 options like a sort order). Both follow the [design](/docs/guides/designs): filled on iOS and the web, outlined with a ✓ on the chosen chip in Material.
- An item's `icon` (here from `@patine-ui/icons`) sits before its label; items without one are text only. For anything else, render the whole item with `renderItem`.
- The list is controlled: keep the category in state and filter with it.
- Tapping a chip whose neighbor is cut off scrolls that neighbor into view, plus a peek of the one after it.

## Components used

- [ChipGroup](/docs/components/chip-group): the categories, with `icon` on the first two
- [Patine Icons](/docs/components/icons)
