Skip to content

Using Components

Standard text is great, but sometimes you need more. We have built-in components for better layout, navigation, and visualization.

Perfect for “How-to” guides. Automatically numbers your H3 or H4 headings and connects them with a line.

import Steps from '../../../../components/content/Steps.astro';
<Steps>
### Step 1: Open the menu
Click the button...
### Step 2: Select option
Choose the third item...
</Steps>

Preview:

Click the button…

Choose the third item…

Better than plain links for navigation hubs.

import LinkCard from '../../../../../../components/content/LinkCard.astro';
<LinkCard
title="Go to Google Drive"
description="Access our shared file repository."
href="https://drive.google.com"
/>

Preview:

Organize content into switchable tabs.

import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs>
<TabItem label="Windows">Press Ctrl + C</TabItem>
<TabItem label="Mac">Press Cmd + C</TabItem>
</Tabs>

Preview:

Press Ctrl + C

Show project structures clearly.

import { FileTree } from '@astrojs/starlight/components';
<FileTree>
- src/
- components/
- pages/
- package.json
</FileTree>

Preview:

  • Directorysrc/
    • Directorycomponents/
    • Directorypages/
  • package.json

Group multiple cards together.

import { Card, CardGrid } from '@astrojs/starlight/components';
<CardGrid>
<Card title="Feature A" icon="star">Details here...</Card>
<Card title="Feature B" icon="moon">Details here...</Card>
</CardGrid>

Preview:

Feature A

Details here…

Feature B

Details here…

You must use a .mdx file extension (not .md) to use components.

  1. Import the component at the top of your file (under the frontmatter).
  2. Use the tag where you want it to appear.
---
title: "My Page"
---
import Steps from '../../../../components/content/Steps.astro';
# My Page
Follow these steps:
<Steps>
...
</Steps>