Reusable Astro components for MDX content.
Prosefly natively supports these components in its visual editor, so authors can create and edit content with Prosefly components visually.
Install the package in an Astro v7 project:
pnpm add @prosefly/astro-componentsIf your site renders .mdx pages, make sure MDX is configured in Astro first.
Dahlia and
Lotus projects already include MDX,
the shared integration, icon preloading, and their docs shell.
---
import { Callout } from '@prosefly/astro-components';
---
<Callout type="tip" title="Reusable">
Package components use Prosefly CSS custom properties with built-in fallbacks.
</Callout>Full documentation is available at astro-components.prosefly.dev.
For a standalone Astro site, the shared integration configures icon preloading, the shared Markdown transforms, and image-gallery assets together:
import { defineConfig } from 'astro/config';
import proseflyComponents from '@prosefly/astro-components/integration';
export default defineConfig({
integrations: [proseflyComponents({
icons: { preload: ['lucide:star'] },
})],
});The main entry exports:
AccordionItemandAccordionsBadgeCalloutCardandCardGridFileTreeIconImageGalleryStepsTabItemandTabs
The @prosefly/astro-components/integration entry exports the proseflyComponents()
Astro integration and its ComponentsIntegrationOptions type.
The markdown entry exports:
rehypeMermaidremarkImageGalleryremarkPackageManagerTabs
Use the @prosefly/astro-components/integration entry for the usual setup. The
standalone @prosefly/astro-components/icon entry remains available when a
project wants only Iconify preloading without Markdown transforms or the full
Dahlia or
Lotus theme:
import { defineConfig } from 'astro/config';
import proseflyIcon from '@prosefly/astro-components/icon';
export default defineConfig({
integrations: [
proseflyIcon({
preload: ['lucide:star', 'simple-icons:github'],
}),
],
});The integration can scan src/**/*.astro, src/**/*.md, and src/**/*.mdx
for static icon usage. Set scan: false to disable that behavior or apiBase
to point at an internal Iconify-compatible endpoint.
Use @prosefly/astro-components/integration for the normal Markdown setup. It
enables image galleries in .mdx files; ordinary .md files are unchanged.
The @prosefly/astro-components/markdown entry remains available for advanced
MDX processor composition:
import { defineConfig } from 'astro/config';
import { rehypeMermaid, remarkImageGallery, remarkPackageManagerTabs, unified } from '@prosefly/astro-components/markdown';
export default defineConfig({
markdown: {
syntaxHighlight: {
type: 'shiki',
excludeLangs: ['math', 'mermaid'],
},
processor: unified({
remarkPlugins: [remarkImageGallery, remarkPackageManagerTabs],
rehypePlugins: [rehypeMermaid],
}),
},
});remarkPackageManagerTabs recognizes common npm commands and can generate
tabs for Node and Python package managers. remarkImageGallery is an MDX-only
transform that preserves the original image nodes for Astro optimization and
renders the ImageGallery component with page-owned CSS and runtime. No manual
asset imports are required. rehypeMermaid renders mermaid code blocks as
static SVG; direct use requires excluding mermaid from Astro syntax
highlighting. Dahlia and Lotus enable these transforms through the shared
integration by default.
Expressive Code is intentionally separate from proseflyComponents(). Install
astro-expressive-code and register
expressiveCodeHeaderIcons() in its plugins option:
import astroExpressiveCode from 'astro-expressive-code';
import { expressiveCodeHeaderIcons } from '@prosefly/astro-components/expressive-code';
export default {
integrations: [
astroExpressiveCode({
plugins: [expressiveCodeHeaderIcons()],
}),
],
};Pass { apiBase: 'https://example.com' } to use an Iconify-compatible endpoint
for code-header icons. Dahlia and Lotus already configure this plugin; do not
register it a second time in those themes. See the
Expressive Code guide
for standalone and combined examples.
The /expressive-code entry publicly exports only
expressiveCodeHeaderIcons and the ExpressiveCodeHeaderIconsOptions type.
The icon and language-label helpers used by the plugin are internal.
Consumers can theme the components with --pf-* custom properties:
--pf-text-strong--pf-text--pf-text-muted--pf-background--pf-surface--pf-accent--pf-accent-soft--pf-accent-contrast--pf-{info|success|warning|danger}--pf-{info|success|warning|danger}-soft--pf-{info|success|warning|danger}-ink--pf-{info|success|warning|danger}-contrast--pf-callout-{note|tip|warning|danger}-{color|ink|bg}--pf-border-subtle--pf-font-sans--pf-font-mono--pf-radius-sm--pf-radius-md--pf-radius-lg--pf-radius-full