🚀 Ship faster with premium components 🚀
Search documentation v1.0.0

Chapters

Present overviews in a grouped, thematic format

Source Report Issue

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.

  1. 01
  2. 02
  3. 03

Getting Started

5 lessons
Kickstart your journey with Astro by understanding the project structure, setup process, and development workflow essentials.
  • 01 Getting Started
    See examples 1min read
  • 02 Setting up Astro
    3min read
  • 03 Creating your first page
  • 04 Astro project structure
    5min read
  • 05 Running your dev server
    2min read

Layouts & Components

4 lessons
Learn how to build reusable layouts and components in Astro using the power of islands architecture and scoped styles.
  • 01 Creating a layout component
  • 02 SEO integration
    7min read
  • 03 Slot usage in Astro components
    4min read
  • 04 Styling components
    5min read

Data & Integrations

4 lessons
Understand how to fetch, transform, and display data in Astro projects, and learn how to integrate with third-party services and APIs.
  • 01 Fetching remote data
    5min read
  • 02 Using CMS content (e.g. Sanity, Contentful)
    6min read
  • 03 Integrating Markdown & MDX
    4min read
  • 04 Working with environment variables
    3min read
For demonstration purposes, the Chapters component is displayed within a scroll container.
Unlock code
How to use the Chapters component in Astro
---
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:

For a smooth scrolling experience, make sure you have 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:

  1. 01
  2. 02
  3. 03

Getting Started

5 lessons
Kickstart your journey with Astro by understanding the project structure, setup process, and development workflow essentials.
  • 01 Getting Started
    See examples 1min read
  • 02 Setting up Astro
    3min read
  • 03 Creating your first page
  • 04 Astro project structure
    5min read
  • 05 Running your dev server
    2min read

Layouts & Components

4 lessons
Learn how to build reusable layouts and components in Astro using the power of islands architecture and scoped styles.
  • 01 Creating a layout component
  • 02 SEO integration
    7min read
  • 03 Slot usage in Astro components
    4min read
  • 04 Styling components
    5min read

Data & Integrations

4 lessons
Understand how to fetch, transform, and display data in Astro projects, and learn how to integrate with third-party services and APIs.
  • 01 Fetching remote data
    5min read
  • 02 Using CMS content (e.g. Sanity, Contentful)
    6min read
  • 03 Integrating Markdown & MDX
    4min read
  • 04 Working with environment variables
    3min 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:

  1. 01
  2. 02
  3. 03

Getting Started

5 lessons
Kickstart your journey with Astro by understanding the project structure, setup process, and development workflow essentials.
  • 01 Getting Started
    See examples 1min read
  • 02 Setting up Astro
    3min read
  • 03 Creating your first page
  • 04 Astro project structure
    5min read
  • 05 Running your dev server
    2min read

Layouts & Components

4 lessons
Learn how to build reusable layouts and components in Astro using the power of islands architecture and scoped styles.
  • 01 Creating a layout component
  • 02 SEO integration
    7min read
  • 03 Slot usage in Astro components
    4min read
  • 04 Styling components
    5min read

Data & Integrations

4 lessons
Understand how to fetch, transform, and display data in Astro projects, and learn how to integrate with third-party services and APIs.
  • 01 Fetching remote data
    5min read
  • 02 Using CMS content (e.g. Sanity, Contentful)
    6min read
  • 03 Integrating Markdown & MDX
    4min read
  • 04 Working with environment variables
    3min read

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.

  1. 01
  2. 02
  3. 03

Getting Started

5 lessons
Kickstart your journey with Astro by understanding the project structure, setup process, and development workflow essentials.
  • 01 Getting Started
    See examples 1min read
  • 02 Setting up Astro
    3min read
  • 03 Creating your first page
  • 04 Astro project structure
    5min read
  • 05 Running your dev server
    2min read

Layouts & Components

4 lessons
Learn how to build reusable layouts and components in Astro using the power of islands architecture and scoped styles.
  • 01 Creating a layout component
  • 02 SEO integration
    7min read
  • 03 Slot usage in Astro components
    4min read
  • 04 Styling components
    5min read

Data & Integrations

4 lessons
Understand how to fetch, transform, and display data in Astro projects, and learn how to integrate with third-party services and APIs.
  • 01 Fetching remote data
    5min read
  • 02 Using CMS content (e.g. Sanity, Contentful)
    6min read
  • 03 Integrating Markdown & MDX
    4min read
  • 04 Working with environment variables
    3min read
Unlock code
Navigation top offset set to 100px
<Chapters
chapters={[ ... ]}
navTopOffset={100}
/>

API

Unlock code
Component API reference
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)[]
}
Please see the documentation of the Overview component for the OverviewProps type.
PropPurpose
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.