Skip to content

PageTags

The PageTags component automatically displays tags from the current page’s frontmatter. It’s the easiest way to show tags on your documentation pages.

See live demo →

import { PageTags } from 'starlight-tags/components';
PropTypeDefaultDescription
layout'inline' | 'block''inline'Display layout
variant'solid' | 'outline' | 'ghost''outline'Badge visual style
size'small' | 'medium' | 'large''small'Badge size
showIconbooleantrueShow tag icons
labelstring | booleanundefinedPass true for localized default label, or a custom string

Simply drop the component into any MDX page that has tags in its frontmatter:

---
title: Configuration Guide
tags:
- configuration
- guide
- getting-started
---
import { PageTags } from 'starlight-tags/components';
# Configuration Guide
<PageTags />
Your content here...

Tags flow with surrounding content:

<PageTags layout="inline" />

Tags take full width with borders:

<PageTags layout="block" />

Add a text label before the tags. Use true for the localized default (“Tags:”) or pass a custom string:

{/* Use localized default label */}
<PageTags label={true} />
{/* Use custom label */}
<PageTags label="Topics:" />

Renders as: Topics: [tag1] [tag2] [tag3]

<PageTags size="small" />
<PageTags size="medium" />
<PageTags size="large" />
<PageTags variant="solid" />
<PageTags variant="outline" /> <!-- Default -->
<PageTags variant="ghost" />
<PageTags showIcon={false} />

Place the component where you want tags to appear:

---
title: Plugin Development Guide
tags: [plugins, guide]
---
import { PageTags } from 'starlight-tags/components';
<PageTags layout="block" />
# Plugin Development Guide
Content here...
---
title: Plugin Development Guide
tags: [plugins, guide]
---
import { PageTags } from 'starlight-tags/components';
# Plugin Development Guide
Content here...
---
<PageTags label="Tagged:" />
---
title: Plugin Development Guide
tags: [plugins, guide]
---
import { PageTags } from 'starlight-tags/components';
<PageTags layout="block" variant="ghost" />
# Plugin Development Guide
Content here...
---
<PageTags label="Related topics:" size="small" />
---
title: Advanced Plugin Development
description: Complete guide to building custom plugins
tags:
- plugins
- advanced
- guide
- components
---
import { PageTags } from 'starlight-tags/components';
<PageTags layout="block" variant="outline" size="medium" label="This guide covers:" />
# Advanced Plugin Development
In this guide, you'll learn how to build custom plugins...
## Prerequisites
Before starting, make sure you understand:
- Basic configuration
- Component fundamentals
## Getting Started
...
---
<PageTags label="Topics covered:" size="small" variant="ghost" />

The PageTags component:

  1. Reads the tags array from the current page’s frontmatter
  2. Checks the hideTags frontmatter property
  3. Fetches tag data from middleware (Astro.locals.starlightTags)
  4. Renders each tag using the TagBadge component

The component renders nothing if:

  • No tags are defined in the frontmatter
  • hideTags: true is set in the frontmatter

Use the hideTags frontmatter property to hide tags on specific pages while still associating the page with those tags:

---
title: Internal Configuration Reference
tags:
- configuration
- reference
hideTags: true
---
import { PageTags } from 'starlight-tags/components';
<PageTags /> <!-- Renders nothing because hideTags is true -->
This page is still listed on the /tags/configuration and /tags/reference pages,
but tags aren't displayed here.

This is useful when you want pages to appear in tag listings without displaying the tags on the page itself.

Wondering which component to use? Here’s a quick comparison:

FeaturePageTagsPageWithTags
Auto-reads frontmatterYesYes
Accepts tagIds propNoYes
Wraps contentNoYes (via slot)
Position controlManual placementtop / bottom / both
Separator lineNoYes (bottom position)
“Tags” titleNoOptional
Best forDrop-in tag displayLayout templates

Choose PageTags when you want:

  • A simple drop-in solution — just add <PageTags /> anywhere in your MDX
  • Full control over placement within your content
  • Automatic tag detection from frontmatter with no extra setup
<PageTags /> <!-- That's it! -->

Choose PageWithTags when you need:

  • Tags that frame your content at the top, bottom, or both
  • Consistent tag positioning across multiple pages
  • The ability to specify which tags to display via tagIds
<PageWithTags tags={customTags} position="both">
<YourContent />
</PageWithTags>