TagsList
Esta página aún no está disponible en tu idioma.
The TagsList component renders a collection of tags with customizable layouts and sorting options.
Import
Section titled “Import”import { TagsList } from 'starlight-tags/components';| Prop | Type | Default | Description |
|---|---|---|---|
tagIds | string[] | - | Specific tag IDs to display |
tags | ProcessedTag[] | - | Pre-fetched tag objects (for advanced use) |
limit | number | - | Maximum number of tags to show |
title | string | undefined | Optional heading above tags |
showCount | boolean | false | Show 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 |
Basic Usage
Section titled “Basic Usage”Show all tags:
import { TagsList } from 'starlight-tags/components';
<TagsList />That’s it! The component fetches all tags automatically.
Specific Tags
Section titled “Specific Tags”Display only specific tags by ID:
<TagsList tagIds={['authentication', 'rest-api', 'webhooks']} />Limiting Results
Section titled “Limiting Results”Show only a certain number of tags:
<TagsList limit={6} />Layouts
Section titled “Layouts”Inline (Default)
Section titled “Inline (Default)”Tags flow horizontally and wrap:
<TagsList layout="inline" />Tags in a responsive grid:
<TagsList layout="grid" />Tags stacked vertically:
<TagsList layout="list" />With Title
Section titled “With Title”Add a heading above the tags:
<TagsList title="Related Topics" />Sorting
Section titled “Sorting”By Name (Default)
Section titled “By Name (Default)”Alphabetical order:
<TagsList sortBy="name" />By Count
Section titled “By Count”Most used tags first:
<TagsList sortBy="count" />With Counts
Section titled “With Counts”Show how many pages use each tag:
<TagsList showCount />Style Variants
Section titled “Style Variants”<TagsList variant="solid" /><TagsList variant="outline" /><TagsList variant="ghost" />Combined Options
Section titled “Combined Options”<TagsList title="Popular Topics" layout="grid" sortBy="count" showCount variant="outline" limit={6}/>Grouped Examples
Section titled “Grouped Examples”Status Tags
Section titled “Status Tags”<TagsList tagIds={['stable', 'beta', 'deprecated']} title="API Status" variant="outline"/>SDK Options
Section titled “SDK Options”<TagsList tagIds={['sdk-python', 'sdk-node', 'sdk-go']} title="Available SDKs" showCount/>Advanced: Pre-fetched Tags
Section titled “Advanced: Pre-fetched Tags”For advanced filtering or custom data sources:
---import { TagsList } from 'starlight-tags/components';
const { allTagsSorted } = Astro.locals.starlightTags;// Custom filteringconst popularTags = allTagsSorted.filter(tag => tag.count >= 3);---
<TagsList tags={popularTags} title="Popular Tags" />