Chapters
Present overviews in a grouped, thematic format
Use the Chapters
component to display content in a structured sequential order. You can theme different sections with colors, images and icons. It comes with a side navigation that updates on scroll. Use for online courses or tutorials, documentation, roadmaps, or walkthroughs.

Getting Started
5 lessons- 01 Getting StartedSee examples 1min read
- 02 Setting up Astro3min read
- 03 Creating your first pageDownload template 4min read
- 04 Astro project structure5min read
- 05 Running your dev server2min read

Layouts & Components
4 lessons- 01 Creating a layout componentUse starter layout 6min read
- 02 SEO integration7min read
- 03 Slot usage in Astro components4min read
- 04 Styling components5min read

Data & Integrations
4 lessons- 01 Fetching remote data5min read
- 02 Using CMS content (e.g. Sanity, Contentful)6min read
- 03 Integrating Markdown & MDX4min read
- 04 Working with environment variables3min read
Chapters
component is displayed within a scroll container. ---import rocket from './icons/rocket.svg?raw'
const chapters = [ { title: 'Getting Started', icon: rocket, subText: '{0} lessons', description: 'Kickstart your journey with Astro...', color: 'var(--w-color-info)', img: { src: '/img/getting-started.png', alt: 'Getting Started', height: 300, width: 300 }, items: [ { text: 'Getting Started', subText: '1min read', buttons: [{ text: 'See examples', href: '/examples' }] }, { text: 'Setting up Astro', subText: '3min read' }, { ... }, { ... }, { ... } ] }, { ... }, { ... }]---
<Chapters chapters={chapters} />
The Chapters
component only needs a chapters
prop that describes how each chapter should be displayed. It expects an array of objects with only two properties; title
and items
, however, the following properties helps you customize your sections in many different ways:
title
: A title is required for each chapter.icon
: You can optionally set an icon that is displayed under the title of a chapter.subText
: Additional text that is displayed next to the icon. You can use the{0}
placeholder key if you want to dynamically inject the number of items into your text.description
: Sets a description under the title. This property supports the use of HTML elements.color
: When set, it’ll set the color of the item indexes, adds a faint gradient as a background, and also sets the color of the navigation.img
: Displays an image next to the chapter items.items
: Sets the chapter items. You can use the props of anOverview
component to create your items.
scroll-behavior
set to smooth
on your container’s CSS. Chapter Images
Chapter images are optional. When no image is set, the content takes up the available full width:
Getting Started
5 lessons- 01 Getting StartedSee examples 1min read
- 02 Setting up Astro3min read
- 03 Creating your first pageDownload template 4min read
- 04 Astro project structure5min read
- 05 Running your dev server2min read
Layouts & Components
4 lessons- 01 Creating a layout componentUse starter layout 6min read
- 02 SEO integration7min read
- 03 Slot usage in Astro components4min read
- 04 Styling components5min read
Data & Integrations
4 lessons- 01 Fetching remote data5min read
- 02 Using CMS content (e.g. Sanity, Contentful)6min read
- 03 Integrating Markdown & MDX4min read
- 04 Working with environment variables3min read
Colors
Colors are also optional. If you don’t set chapters.color
, no gradient will be set, and the active menu will use a default white color, while the item numbers will use a muted color:
Getting Started
5 lessons- 01 Getting StartedSee examples 1min read
- 02 Setting up Astro3min read
- 03 Creating your first pageDownload template 4min read
- 04 Astro project structure5min read
- 05 Running your dev server2min read
Layouts & Components
4 lessons- 01 Creating a layout componentUse starter layout 6min read
- 02 SEO integration7min read
- 03 Slot usage in Astro components4min read
- 04 Styling components5min read
Data & Integrations
4 lessons- 01 Fetching remote data5min read
- 02 Using CMS content (e.g. Sanity, Contentful)6min read
- 03 Integrating Markdown & MDX4min read
- 04 Working with environment variables3min read
Navigation Offset
If you use the Chapters
component as a direct child of your body
where you also have a fixed menu, you might want to configure the top positioning of the side navigation. For this, you can use the navTopOffset
prop. By default, this is set to 50px, but you can easily configure the default value through the module.scss
file.

Getting Started
5 lessons- 01 Getting StartedSee examples 1min read
- 02 Setting up Astro3min read
- 03 Creating your first pageDownload template 4min read
- 04 Astro project structure5min read
- 05 Running your dev server2min read

Layouts & Components
4 lessons- 01 Creating a layout componentUse starter layout 6min read
- 02 SEO integration7min read
- 03 Slot usage in Astro components4min read
- 04 Styling components5min read

Data & Integrations
4 lessons- 01 Fetching remote data5min read
- 02 Using CMS content (e.g. Sanity, Contentful)6min read
- 03 Integrating Markdown & MDX4min read
- 04 Working with environment variables3min read
<Chapters chapters={[ ... ]} navTopOffset={100}/>
API
type ChaptersProps = { className?: string navTopOffset?: number chapters: ({ id?: string title: string icon?: string subText?: string description?: string items: OverviewProps['items'] img?: { src: string alt: string width: number height: number lazy?: boolean } } & OverviewProps)[]}
Overview
component for the OverviewProps
type. Prop | Purpose |
---|---|
navTopOffset | Sets the top offset of the navigation bar. |
chapters.id | Sets an id for the chapter used as a scroll anchor. If not set, defaults to the chapter's title. |
chapters.title | Sets the title of the chapter. |
chapters.icon | Sets an icon for the chapter under its title. |
chapters.subText | Sets additional text next to the icon. |
chapters.description | Sets a description under the sub-text. Supports HTML formatting. |
chapters.items | Sets the chapter items using an Overview component. |
chapters.img.src | Sets an image for the chapter. |
chapters.img.alt | Sets an alternate text for the image. |
chapters.img.width | Sets the width of the image. |
chapters.img.height | Sets the height of the image. |
chapters.img.lazy | Set to true to enable lazy loading for the image. |
className | Pass additional CSS classes for the Chapters component. |