Skip to content
✨ Publier v1 is live — a polished docs platform built for the open web.
On this page

Component overrides

Replace a built-in component such as Tabs or CodeGroup with your own .astro file, by name, in publier.config.yaml.

Replace a built-in component with your own .astro file. Map the component’s name to a path relative to the project root under components: in publier.config.yaml. It needs @publier/shell 0.14.0 or later.

publier.config.yaml
components:
Tabs: src/components/MyTabs.astro
CodeGroup: src/components/MyCodeGroup.astro

Overridable today: Tabs and CodeGroup. More components become overridable as they move to open markup, so check this list when you upgrade.

Writing an override

Your file receives the props of the component it replaces. The types are TabsProps and CodeGroupProps, exported from @publier/shell/components. To keep the built-in behaviour and change only the wrapper, import the original and render it inside your markup:

src/components/MyTabs.astro
---
import type { TabsProps } from '@publier/shell/components';
import Default from '@publier/shell/components/tabs.astro';
type Props = TabsProps;
---
<div class="my-frame"><Default {...Astro.props}><slot /></Default></div>

Where an override applies

The override applies wherever you import the component from @publier/shell/components, MDX pages included. A direct import of @publier/shell/components/tabs.astro always gets the shipped component, which is how an override wraps it.

The build fails if a name under components: is not an overridable component, or if the path is absolute, leaves the project, does not end in .astro, or does not exist.

Changing or renaming a component’s props is a breaking change for sites that override it, and the changelog says so.