Skip to content

Components Overview

The starlight-tags plugin exports several Astro components for displaying tags in your documentation pages. All components can be imported from starlight-tags/components.

ComponentPurpose
TagBadgeDisplay a single tag badge
TagsListDisplay a list of tags
PageTagsAuto-display tags for the current page
PageWithTagsWrapper that adds tags to content
TagSidebarSidebar widget for popular tags navigation
PrerequisiteChainDisplay prerequisite learning path
---
title: Authentication Guide
tags:
- authentication
- rest-api
---
import { PageTags, TagBadge, TagsList } from 'starlight-tags/components';
# Authentication Guide
<PageTags />
Content here...

The simplest way to show tags on a page:

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

Display a specific tag:

import { TagBadge } from 'starlight-tags/components';
<TagBadge tagId="authentication" />
<TagBadge tagId="rest-api" variant="outline" size="large" />

Display multiple tags:

import { TagsList } from 'starlight-tags/components';
<!-- Show all tags -->
<TagsList />
<!-- Show specific tags -->
<TagsList tagIds={['authentication', 'webhooks', 'rest-api']} />
<!-- With options -->
<TagsList layout="grid" showCount limit={6} />

Show learning path for a topic:

import { PrerequisiteChain } from 'starlight-tags/components';
<PrerequisiteChain tagId="oauth2" />

Each component accepts different props for customization:

PropDescription
tagId / tagIdsTag ID(s) to display (fetches data automatically)
variantVisual style: 'solid', 'outline', or 'ghost'
sizeSize: 'small', 'medium', or 'large'
showIconWhether to show tag icons
showCountWhether to show page counts

All tag components support three visual variants:

  • solid has a filled background with the tag color
  • outline has a border with transparent background
  • ghost has a subtle background tint

For advanced use cases (custom filtering, etc.), you can access tag data via middleware:

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