Skip to content
svedocs

Components

Look up props, responsibilities, and headless controllers for replaceable svedocs theme components.

The svedocs theme is split into replaceable Svelte components and reusable headless controllers. This page documents the contracts for the navbar, article layout, search dialog, Ask AI panel, table of contents, footer, and floating page tools.

Import paths

TypeScript
import { DocsApp, Navbar, Article, SearchDialog } from 'svedocs/theme';import { createSearchController, createAskAiController } from 'svedocs/theme/headless';import type { SvedocsThemeComponentMap, SvedocsNavbarProps, SvedocsArticleProps} from 'svedocs/theme/types';

svedocs/theme exports the default components and also re-exports the headless helpers and public types. Prefer svedocs/theme/headless and svedocs/theme/types in theme packages when you want small, explicit imports.

Component map

Register build-time replacements in the Vite plugin:

TypeScriptvite.config.ts
svedocs({ theme: { components: { Navbar: '$lib/theme/Navbar.svelte', Article: '$lib/theme/Article.svelte', Search: '$lib/theme/Search.svelte', AskAi: '$lib/theme/AskAi.svelte' } }});

Generated routes import virtual:svedocs/theme-components and pass the map to DocsApp. You can also pass a map manually:

Svelte
<DocsApp page={data.page} pages={data.pages} tree={data.tree} search={data.search} config={data.config} components={contentComponents} layouts={layouts} themeComponents={{ Navbar: CustomNavbar }} loadSearch={loadSearch}/>

The map type is:

KeyDefault componentProps type
RootRootLayoutSvedocsRootProps
LayoutLayoutShellSvedocsLayoutShellProps
DocsDocsLayoutSvedocsDocsLayoutProps
DocsShellDocsShellSvedocsDocsShellProps
PagePageLayoutSvedocsPageLayoutProps
PageShellPageShellSvedocsPageShellProps
HomeHomePageSvedocsHomeLayoutProps
ErrorErrorPageSvedocsErrorProps
BrandBrandSvedocsBrandProps
TopNavTopNavSvedocsTopNavProps
HeaderNavbarSvedocsHeaderProps
NavbarNavbarSvedocsNavbarProps
MobileNavMobileNavSvedocsMobileNavProps
SocialNavSocialNavSvedocsSocialNavProps
SidebarSidebarTreeSvedocsSidebarProps
ArticleArticleSvedocsArticleProps
TocTableOfContentsSvedocsTocProps
SearchSearchDialogSvedocsSearchProps
AskAiAskAiPanelSvedocsAskAiProps
FooterFooterSvedocsFooterProps
FooterLinksFooterLinksSvedocsFooterLinksProps
ThemeToggleThemeToggleSvedocsThemeToggleProps
PageToolsPageToolsSvedocsPageToolsProps
RenderErrorRenderErrorSvedocsRenderErrorProps

Shared context

Most shell components receive SvedocsThemeContext.

FieldDescription
configResolved svedocs.config.ts.
pageCurrent page when one is available.
pagesFull page manifest.
treeNavigation tree for the current docs scope.
searchSearch records already loaded into the route.
loadSearchLazy search-record loader, usually from virtual:svedocs/search-loader.
searchScopeRuntime search filter derived from search.scope and the current locale.
aiScopeRuntime Ask AI filter derived from ai.scope and the current locale.
surfacehome or reading.
isDocsPageWhether the current page is a docs article.
activeNavHrefNormalized active top-nav href.
localeCurrent resolved locale config, including hreflang and dir when configured.
localeCodeStable locale code used by search, AI, and stored scopes.
languageTagBCP 47 tag used by HTML and locale-sensitive formatting.
messagesFully merged messages for the current locale.
tLocale-aware translator with {value} interpolation.

Create the same object in custom shells with createThemeContext.

DocsApp

DocsApp is the complete route renderer. Use it when you want svedocs to connect routing, metadata, layouts, slots, and replacement components.

PropTypeNotes
pageSvedocsPageRequired current page.
configSvedocsResolvedConfigRequired resolved config.
pagesSvedocsPage[]Optional, defaults to [].
treeSvedocsTreeItem[]Optional, defaults to [].
searchSvedocsSearchRecord[]Optional, defaults to [].
componentsRecord<string, Component>Compiled .svx / .mdx page components.
layoutsRecord<string, Component>Named single-page layouts.
themeComponentsPartial<SvedocsThemeComponentMap>Component overrides.
loadSearchSvedocsRecordLoaderLazy search-record loader.

Slots: background, landing, home-hero-visual, home-features, and doc-header.

Root

Root handles document metadata, the theme initialization script, route hydration state, scrollbar visibility, and the shared background slot. Its default visual shell is Layout.

PropNotes
configRequired resolved config.
page, pages, tree, search, loadSearchInputs used to create SvedocsThemeContext.
mobileTree, mobileCurrentPathMobile docs navigation data.
hasBackgroundSlotForces or disables rendering of the background slot.
themeComponentsPassed through to nested replaceable components.

The default root renders <slot /> as the page body and <slot name="background" /> as a decorative layer.

Layouts

Docs, Page, Home, and Error are the page-level layouts used by DocsApp and generated routes. Replace them when you want to keep framework routing, metadata, and content loading but provide a new page shell. Error renders SvelteKit error pages with the same themed root, header, footer, search, theme mode, and noindex metadata; generated templates include src/routes/+error.svelte.

ComponentNotes
DocsDocs article shell with sidebar, article, and ToC.
PageStandalone page shell.
HomeHome page shell and feature entry points.
ErrorReceives status, message, error, path, config, manifest data, search, and themeComponents.

Docs, Page, and Home receive the current page, pages, tree, search, config, loadSearch, page content, and themeComponents so replacement layouts can reuse the same navigation and runtime data as the bundled theme.

Basic Layout Components

Layout, DocsShell, and PageShell are lower-level visual layout components. Replace them when your theme only needs a different outer frame or content geometry while preserving the default page-level behavior.

ComponentNotes
LayoutSite frame inside Root: skip link, header, background slot, default slot, Ask AI, page tools, and footer.
DocsShellDocumentation content geometry: sidebar, article region, and ToC.
PageShellStandalone page body and error page body. Supports variant="page" and variant="error".

Layout receives SvedocsLayoutShellProps, including context, themeStyle, mobile-nav state, themeComponents, and mobile callbacks. If you replace it, keep rendering the default slot, the background slot when hasBackgroundSlot is true, and the header/footer or your own equivalents.

DocsShell receives page, navigationTree, content, context, tocController, hasDocHeaderSlot, and themeComponents. The default shell still delegates to replaceable Sidebar, Article, and Toc.

PageShell receives optional page, variant, title, description, kicker, content, html, status, path, and actions. The default Page and Error components both use it, so replacing PageShell updates normal standalone pages and the default error page together.

Navbar renders brand, primary navigation, search, locale/version switcher, social links, theme toggle, and mobile navigation. Header is an alias replacement point for Navbar, and the default navbar composes Brand, TopNav, SocialNav, Search, ThemeToggle, and MobileNav.

PropNotes
contextRequired SvedocsThemeContext.
mobileTree, mobileCurrentPathDocs tree and current path for the mobile menu.
mobileMenuId, mobileMenuOpenAccessibility state managed by Root.
themeComponentsUsed by the default navbar to render custom Search, ThemeToggle, and MobileNav.
onToggleMobileMenu, onCloseMobileMenuCallbacks from the mobile-nav controller.

Minimum custom navbar:

Sveltesrc/lib/theme/Navbar.svelte
<script lang="ts"> import type { SvedocsNavbarProps } from 'svedocs/theme/types'; export let context: SvedocsNavbarProps['context'];</script><header> <a href={context.config.theme.brand.href}>{context.config.theme.brand.label}</a></header>

MobileNav

MobileNav renders the docs navigation inside the responsive topbar menu.

PropNotes
itemsSvedocsTreeItem[], defaults to [].
currentPathRoute path used for active link state.
themeComponentsAllows the default mobile nav to reuse a custom Sidebar.

Use it when mobile navigation differs from the desktop sidebar.

Sidebar renders recursive docs navigation.

PropNotes
itemsSvedocsTreeItem[], defaults to [].
currentPathCurrent route path.
depthNesting depth for recursive rendering.

Custom sidebars should preserve normal links and aria-current="page" on the active item.

Article

Article renders the documentation article header, prose body, edit link, last-updated metadata, and prev/next navigation.

PropNotes
pageRequired current page.
contentCompiled Svelte content component for .svx / .mdx; fallback is page.html.
contextOptional SvedocsThemeContext.
hasDocHeaderSlotForces or disables the doc-header slot branch.
themeComponentsPassed through so the default article can use a custom RenderError.

The default article exposes a doc-header slot with page and breadcrumbs. If you replace the component, keep rendering either content or page.html, and keep stable article landmarks for accessibility.

Svelte
<script lang="ts"> import type { SvedocsArticleProps } from 'svedocs/theme/types'; export let page: SvedocsArticleProps['page']; export let content: SvedocsArticleProps['content'];</script><article> <h1>{page.title}</h1> {#if content}<svelte:component this={content} />{:else}{@html page.html}{/if}</article>

Toc

Toc renders page headings and tracks the active heading.

PropNotes
pageRequired current page with headings.
controllerOptional SvedocsTocController; DocsLayout passes a shared controller.

Use createTocController({ page }) in a custom layout when the ToC and article body need to share active-heading state.

RenderError

RenderError is the default error boundary UI for rendering failures inside the theme. The bundled DocsApp, Root, Error, Docs, Layout, DocsShell, PageShell, Home, and Article components catch local render errors with <svelte:boundary> and render this component instead of taking down the whole route.

PropNotes
errorUnknown thrown value from the boundary.
resetOptional Svelte boundary reset callback.
title, message, labelUser-facing copy for the failed area.
variantlayout, article, content, navigation, tools, section, or a custom string.
pageCurrent page when available.
contextOptional SvedocsThemeContext.
treeOptional navigation tree used for a docs-home action.

Replace RenderError when your theme needs different recovery actions, logging, telemetry, or copy. Keep failures contained: an article error should leave the header and sidebar visible, while a sidebar or ToC error should not hide the article.

Search renders the search trigger and dialog. The behavior lives in createSearchController.

PropNotes
recordsInitial local records.
loadRecordsLazy record loader.
scopeLocale/kind filter.
providerlocal, local-json, or a hosted provider id.
endpointSearch route, defaults to /api/search.
buildModeedge, static, spa, or a custom string.
controllerOptional shared SvedocsSearchController.
Svelte
<script lang="ts"> import { createSearchController } from 'svedocs/theme/headless'; import type { SvedocsSearchProps } from 'svedocs/theme/types'; export let records: SvedocsSearchProps['records'] = []; export let loadRecords: SvedocsSearchProps['loadRecords']; export let scope: SvedocsSearchProps['scope'] = {}; const search = createSearchController({ records, loadRecords, scope });</script><button type="button" on:click={search.show}>Search</button>

The default search also listens for window event svedocs:open-search.

AskAi

AskAi renders the Ask AI panel. The behavior lives in createAskAiController.

PropNotes
configRequired resolved config; config.ai.enabled controls availability.
recordsInitial local search records for fallback answers.
loadRecordsLazy record loader.
scopeLocale/kind filter.
endpointAsk route, defaults to /api/ask.
buildModeRuntime mode; non-edge builds use local fallback behavior.
controllerOptional shared SvedocsAskAiController.
Svelte
<script lang="ts"> import { createAskAiController } from 'svedocs/theme/headless'; import type { SvedocsAskAiProps } from 'svedocs/theme/types'; export let config: SvedocsAskAiProps['config']; const ask = createAskAiController({ config });</script><button type="button" on:click={ask.show}>{config.ai.label}</button>

The default panel accepts JSON responses and text/event-stream deltas. It also listens for window event svedocs:open-ai.

Footer renders global footer text and links from config.theme.footer.

PropNotes
contextRequired SvedocsThemeContext.

The default footer hides on docs article pages and composes FooterLinks. A custom footer can choose a different rule by reading context.isDocsPage and context.surface.

ThemeToggle

ThemeToggle reads and writes document.documentElement.dataset.theme, updates color-scheme, and stores the selected mode in localStorage.

PropNotes
defaultModelight, dark, or system; defaults to system.

Use createThemeModeController(defaultMode) for custom toggles.

PageTools

PageTools renders floating article tools: Ask AI and back-to-top.

PropNotes
configRequired resolved config.
controllerOptional SvedocsPageToolsController.

Use createPageToolsController(config) when you want the same scroll state and svedocs:open-ai event without the default floating toolbar.

Headless helpers

Use LocalizedLink with a SvedocsThemeContext when a custom Svelte component needs the same current-locale and default-locale link resolution as Markdown and the default navigation.

HelperUse it for
createThemeContext(input)Build the shared context object for custom roots/layouts.
createSearchController(options)Query state, local/remote search, active result state, and lazy record loading.
createAskAiController(options)Panel state, messages, JSON/SSE requests, and local fallback answers.
createTocController({ page })Active heading and indicator position.
createThemeModeController(defaultMode)Light/dark mode state, persistence, and system sync.
createMobileNavController()Mobile menu open/close and Escape handling.
createPageToolsController(config)Floating tool visibility, Ask AI trigger, and back-to-top behavior.
copyTextToClipboard(source)Raw clipboard helper.
copyCodeToClipboard(button, source, copiedLabel?, idleLabel?)Default code-copy button state helper.

Styling contract

Default components use sd-* classes and data-theme-component attributes. Custom components do not need to reuse those classes. Markdown and code output still includes structural sd-* classes so a custom theme can style prose without taking the bundled styles.css.

CSS options:

ImportWhat it gives you
svedocs/theme/styles.cssFull default theme.
svedocs/theme/base.cssMinimal reset, accessibility helpers, and prose/code structure.
No theme CSSComplete style ownership by your app or theme package.