Aller au contenu

TagsList

Ce contenu n’est pas encore disponible dans votre langue.

The TagsList component renders a collection of tags with customizable layouts and sorting options.

See live demo →

import { TagsList } from 'starlight-tags/components';
PropTypeDefaultDescription
tagIdsstring[]-Specific tag IDs to display
tagsProcessedTag[]-Pre-fetched tag objects (for advanced use)
limitnumber-Maximum number of tags to show
titlestringundefinedOptional heading above tags
showCountbooleanfalseShow page counts on badges
layout'inline' | 'grid' | 'list''inline'Layout style
variant'solid' | 'outline' | 'ghost''solid'Badge visual style
sortBy'name' | 'count''name'Sort order

Show all tags:

import { TagsList } from 'starlight-tags/components';
<TagsList />

That’s it! The component fetches all tags automatically.

Display only specific tags by ID:

<TagsList tagIds={['authentication', 'rest-api', 'webhooks']} />

Show only a certain number of tags:

<TagsList limit={6} />

Tags flow horizontally and wrap:

<TagsList layout="inline" />

Tags in a responsive grid:

<TagsList layout="grid" />

Tags stacked vertically:

<TagsList layout="list" />

Add a heading above the tags:

<TagsList title="Related Topics" />

Alphabetical order:

<TagsList sortBy="name" />

Most used tags first:

<TagsList sortBy="count" />

Show how many pages use each tag:

<TagsList showCount />
<TagsList variant="solid" />
<TagsList variant="outline" />
<TagsList variant="ghost" />
<TagsList
title="Popular Topics"
layout="grid"
sortBy="count"
showCount
variant="outline"
limit={6}
/>
<TagsList
tagIds={['stable', 'beta', 'deprecated']}
title="API Status"
variant="outline"
/>
<TagsList
tagIds={['sdk-python', 'sdk-node', 'sdk-go']}
title="Available SDKs"
showCount
/>

For advanced filtering or custom data sources:

---
import { TagsList } from 'starlight-tags/components';
const { allTagsSorted } = Astro.locals.starlightTags;
// Custom filtering
const popularTags = allTagsSorted.filter(tag => tag.count >= 3);
---
<TagsList tags={popularTags} title="Popular Tags" />