File size: 1,748 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Category Pill Navigation

This component can be used to display a set of categories or tags as pills in an horizontal way. Each pill accepts a link, and the whole navigation bar can be scrolled.

## How to use

```js
import { Icon, starEmpty as iconStar, category as iconCategory } from '@wordpress/icons';
import { CategoryPillNavigation } from 'calypso/components/category-pill-navigation';

function render() {
	return (
		<CategoryPillNavigation
			categories={ Array.from( { length: 15 }, ( _, i ) => ( {
				id: `category-${ i }`,
				label: `Category ${ i + 1 }`,
				link: '#',
			} ) ) }
			selectedCategory="category-2"
			buttons={ [
				{
					id: 'discover',
					icon: <Icon icon={ iconStar } size={ 30 } />,
					label: 'Discover',
					link: '/',
				},
				{
					id: 'all',
					icon: <Icon icon={ iconCategory } size={ 26 } />,
					label: 'All categories',
					link: '/',
				},
			] }
		/>
	);
}
```

## Props

Below is a list of supported props.

### `categories`
An array of objects, each representing a navigation link:

```
{
	id: string; // Is used for highlighting the active item
	label?: string; // The text displayed on the link
	link: string; // The URL that the link points to
}[]
```


### `selectedCategoryId`

Type: `string`

This property should match the `id` of one of the items in the `categories` array to indicate the currently active category.

### `buttons`
An optional array of additional link objects to prepend to the main list of links:
```
{
	id: string; // The identifier of the button, typically used for click tracking
	icon: string; // The icon displayed before the label
	label: string; // The text displayed on the link
	link: string; // The URL that the link points to
}[] | undefined
```