Configuration
Configure starlight-copy-button in your astro.config.mjs file:
import starlight from '@astrojs/starlight';import { defineConfig } from 'astro/config';import starlightCopyButton from 'starlight-copy-button';
export default defineConfig({ integrations: [ starlight({ title: 'My Docs', plugins: [ starlightCopyButton({ includeTitle: true, titleLevel: 1, label: 'Copy page', successLabel: 'Copied!', errorLabel: 'Could not copy', stateDuration: 2800, }), ], }), ],});Options
Section titled “Options”includeTitle
Section titled “includeTitle”Type: boolean
Default: true
Add the page title as a Markdown heading at the top of copied output.
titleLevel
Section titled “titleLevel”Type: 1 | 2 | 3 | 4 | 5 | 6
Default: 1
Heading level to use when includeTitle is enabled.
Type: string
Default: 'Copy page'
Idle button label.
successLabel
Section titled “successLabel”Type: string
Default: 'Copied!'
Label shown after successful copy.
errorLabel
Section titled “errorLabel”Type: string
Default: 'Copy failed'
Label shown if clipboard access fails.
stateDuration
Section titled “stateDuration”Type: number
Default: 2200
How long to show success/error state labels before resetting.
Minimum: 400 ms.
iconOnly
Section titled “iconOnly”Type: boolean
Default: false
Render an icon-only button.