Getting Started
This package exposes a dropdown menu component meant to be used as a custom topic list for the Starlight Sidebar Topics plugin.
Prerequisites
You will need to have a Starlight website set up. If you don’t have one yet, you can follow the “Getting Started” guide in the Starlight docs to create one.
You will also need to have the Starlight Sidebar Topics plugin installed and configured. If you don’t have it set up yet, you can follow the “Getting Started” guide in the Starlight Sidebar Topics docs.
Installation
-
Starlight Sidebar Topics Dropdown is a Starlight component. Install it using your favorite package manager:
Terminal window npm i starlight-sidebar-topics-dropdownTerminal window pnpm add starlight-sidebar-topics-dropdownTerminal window yarn add starlight-sidebar-topics-dropdownTerminal window ni starlight-sidebar-topics-dropdown -
To replace the topic list built-in with the Starlight Sidebar Topics plugin by the dropdown menu provided by this package, configure a component override in the
astro.config.mjs
file for the<Sidebar>
component:astro.config.mjs // @ts-checkimport starlight from '@astrojs/starlight'import { defineConfig } from 'astro/config'import starlightSidebarTopics from 'starlight-sidebar-topics'export default defineConfig({integrations: [starlight({plugins: [starlightSidebarTopics([// Your Starlight Sidebar Topics configuration here.]),],components: {// Override the default `Sidebar` component with a custom one.Sidebar: './src/components/Sidebar.astro',},title: 'My Docs',}),],}) -
Create an Astro component to replace the default Starlight
<Sidebar>
component with which will render the topic list dropdown menu and re-use the default Starlight sidebar:src/components/Sidebar.astro ---import Default from '@astrojs/starlight/components/Sidebar.astro';import TopicsDropdown from 'starlight-sidebar-topics-dropdown/TopicsDropdown.astro';---{/* Render the topics dropdown menu. */}<TopicsDropdown />{/* Render the default sidebar. */}<Default><slot /></Default> -
Start the development server to preview the changes.
You can also render the dropdown menu in a different location in your website by overriding different components. Lean more about overriding components in the Starlight docs.