Docs kit
Docs primitives
Components for developer documentation sites, from the page shell and navigation to code tabs, callouts and prose typography.
This site is built with these primitives. The kit covers DocsShell (header, sidebar, page index and a mobile Sheet menu), DocsNav, TableOfContents, DocsSearch, CodeTabs, Callout, Steps, LinkCard, CardGrid, MethodBadge and the ca-prose typography.
<script>
import { DocsShell } from "@codeatlasdev/ui";
</script>
<DocsShell
{sections} active="guide" {groups} {pathname} {headings}
searchIndex={() => fetch("/search.json").then((r) => r.json())}
onnavigate={(href) => (location.href = href)}
>
{#snippet brand()}<Logo /> Acme Docs{/snippet}
<article class="ca-prose">...</article>
</DocsShell>
DocsShell is a full-page frame, so it is not embedded here. The page you are reading is the reference integration: see SiteDocsShell.svelte in the site/ workspace. On desktop (1024px and up) it is a sticky glass header over a three-column grid: sidebar, content and a “On this page” rail from 1280px. Below 1024px it becomes one compact header, the menu opens a bottom Sheet and the page index turns into an inline disclosure. Cmd+K, Ctrl+K and / open the search.
ca-prose, Callout and Steps
Wrap rendered markdown in .ca-prose. Callout is an Alert vocabulary (note, tip, caution, danger); keep two per page. Steps turns an ordered list into a numbered rail.
Prerequisites
You need an API key and a connected session. The x-api-key header
identifies the organization and x-instance picks the session.
Authentication
The x-api-key header
Send the key in the x-api-key header on every request.
Tip
Caution
Create a session
POST /sessionsreturns the sessionid.Connect with a QR code
Scan it from Linked devices in the mobile app.
Send a message
| Field | Type | Description |
|---|---|---|
to | string | Number with country code, no symbols. Example: 5511999990000 |
text | string | Message body, up to 4096 characters. |
Code
CodeTabs
Language tabs with a copy button. Groups that share a sync key follow each other and persist the choice in localStorage. Highlighting stays with you: wrap each block in .ca-code.
curl -X POST https://api.example.com/messages/text \
-H "x-api-key: YOUR_API_KEY" \
-H "x-instance: my-session" \
-d '{"to":"5511999990000","text":"Hello"}'await fetch("https://api.example.com/messages/text", {
method: "POST",
headers: { "x-api-key": process.env.API_KEY, "x-instance": "my-session" },
body: JSON.stringify({ to: "5511999990000", text: "Hello" }),
});curl https://api.example.com/sessions -H "x-api-key: YOUR_API_KEY"await fetch("https://api.example.com/sessions", { headers: { "x-api-key": KEY } });Code
LinkCard, CardGrid and MethodBadge
Code
DocsNav and TableOfContents
The sidebar tree and the page index. The inline variant is shown; DocsShell uses the rail variant on desktop.
On this page Prerequisites
Code
DocsSearch
Full-text search. A dialog on desktop and a full-height sheet with a 16px input on phones. Pass entries or an async loader.
Code
DocsShell
| Prop | Type | Default | Description |
|---|---|---|---|
sections | DocsSection[] | – | { id, label, href } entries shown as header tabs and in the mobile Sheet. |
active | string | – | id of the current section. |
groups | DocsNavGroup[] | [] | Sidebar tree of the current section. Empty hides the sidebar and the page index. |
pathname | string | – | Current path, used to mark aria-current in the tree. |
headings | DocsHeading[] | [] | Page index: a rail from 1280px and an inline disclosure below. |
searchIndex | DocsSearchEntry[] | () => Promise<DocsSearchEntry[]> | – | Required. Entries, or a lazy loader called on first open. |
onnavigate | (href: string) => void | – | Required. Called when a search result is picked (pass goto). |
brandHref | string | '/' | Link target of the brand. |
brandLabel | string | – | Accessible label of the brand link. |
brand | Snippet | – | Required. Brand mark and name inside the header link. |
actions | Snippet | – | Extra header actions on the right. Keep to one or two icon buttons. |
menuFooter | Snippet | – | Content below the sidebar tree in the mobile Sheet, such as external links. |
children | Snippet | – | Required. Page content. |
DocsNav
| Prop | Type | Default | Description |
|---|---|---|---|
groups | DocsNavGroup[] | – | Labelled groups of { href, title, badge? } links. |
pathname | string | – | Current path, marks the current page with aria-current. |
label | string | – | Accessible label of the nav landmark. |
onNavigate | () => void | – | Called after a link is followed, to close the mobile Sheet. |
TableOfContents
| Prop | Type | Default | Description |
|---|---|---|---|
headings | DocsHeading[] | – | { id, text, depth: 2 | 3 } entries. Renders nothing for fewer than 2 headings. |
variant | 'rail' | 'inline' | 'rail' | A sticky list, or a collapsible disclosure that shows the current section. |
label | string | – | Accessible label of the nav landmark. |
class | string | '' | Extra CSS classes. |
DocsSearch
| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Bindable open state. |
index | DocsSearchEntry[] | () => Promise<DocsSearchEntry[]> | – | Required. Entries, or a loader called once on first open. |
onselect | (href: string) => void | – | Required. Called with the picked result's href. |
placeholder | string | – | Input placeholder. Defaults to the localized string. |
hint | string | – | Footer hint text. Defaults to the localized string. |
Prose blocks
| Prop | Type | Default | Description |
|---|---|---|---|
CodeTabs.sync | string | 'lang' | Groups with the same key follow the chosen label. An empty string disables sync. |
CodeTab.label | string | – | Tab text and sync key, for example 'cURL' or 'Node.js'. |
Callout.type | 'note' | 'tip' | 'caution' | 'danger' | 'note' | Maps to Alert severity (info, success, warning, error). |
Callout.title | string | – | Overrides the default localized title. |
Steps | Snippet | – | Wraps an ordered list; each top-level item becomes a numbered step. |
LinkCard.title / description / href | string | – | Whole-card link. title and href are required; the minimum height is 44px. |
CardGrid | Snippet | – | Responsive auto-fill grid for LinkCard: 16rem minimum, one column on phones. |
MethodBadge.method | string | – | HTTP method label: GET, POST, PUT, PATCH or DELETE. |
MethodBadge.variant | 'pill' | 'plain' | 'pill' | plain drops the tinted pill, for tight lists like a sidebar. |