Skip to content
DocPensieve
0.2.0-beta.1

Theme

To learn how to use it, see Themes. This page lists what exists.

The options

theme: {
  framework: 'tailwind',
  darkMode: 'class',
  tokens: { '--dp-accent': 'oklch(55% 0.2 250)' },
  css: '.dp-article h2 { letter-spacing: -0.01em; }',
  source: '@import "tailwindcss";',
},
FieldDefaultEffect
framework'tailwind''tailwind' or 'custom'
darkMode'class''class': the reader's system, unless a class on <html> decides. 'dark' or 'light' sets that class
tokensRedefined --dp-* tokens, merged with the provider's
css''CSS appended to the produced stylesheet
source@import "tailwindcss";Stylesheet handed to the utility compiler

source only concerns the tailwind provider: it is the entry stylesheet it compiles. Replacing it lets you add directives — a @theme block, for instance — without leaving the mechanism. @plugin directives are not supported yet and stop the build.

The tokens

Fifteen tokens, which both providers define and the components read. A redefined token propagates everywhere, without any component having to know.

TokenRole
--dp-bgPage background
--dp-bg-softBackground of recessed areas — gauge tracks, hovers
--dp-textBody text
--dp-text-softSecondary text — captions, card footers
--dp-borderVisible borders
--dp-ruleDiscreet rules — tree separators
--dp-accentAccent colour — links, fills
--dp-accent-softAccent background — banners
--dp-shadowColour of drop shadows
--dp-radiusCorner rounding
--dp-fontFont family of the text
--dp-font-monoMonospaced family — code, trees
--dp-content-widthReading width. none by default
--dp-sidebar-widthMenu column
--dp-toc-widthTable of contents column

Some components add their own, documented on their page: --dp-skill-size for a circle gauge, --dp-skill-color for the tint of a gauge, --dp-logo-icon-size for an icon.

The slots

The templates write no class. They ask for the class of each slot, and the theme answers. A provider only redefines what it changes; everything else keeps the dp-* class below.

SlotDefault classWhere
skipdp-skipSkip link to the content
headerdp-headerSite header
branddp-brandProject name, in the header
brandLogodp-brand-logoLogo beside the project name
versionsdp-versionsVersion switcher
versionsListdp-versions-listOpen list of the switcher
shelldp-shellMenu / content / table of contents grid
shellWidedp-shell dp-shell--wideThe same, without menu or table of contents
sidebardp-sidebarMenu column
navdp-navNavigation list
navItemdp-nav-itemNavigation entry
navItemParentdp-nav-item--parentEntry that holds a section
navLinkdp-nav-linkNavigation link
navLabeldp-nav-labelSection label, not clickable
noticedp-noticeBanner of the versions that are not the current
skillIcondp-skill-iconIcon before the name of a gauge
maindp-mainMain area
articledp-articlePage content
tocdp-tocTable of contents column
tocTitledp-toc-titleTitle of the table of contents
tocListdp-toc-listList of the table of contents
tocItemdp-toc-itemEntry of the table of contents
footerdp-footerPage footer
scrollTopdp-scroll-topBack-to-top button
scrollTopIcondp-scroll-top-iconArrow of that button
searchdp-searchSearch field of the header

A slot can carry variants, suffixed --variant: column gives dp-column--span-8, skill gives dp-skill--circle.

How a slot is rendered

Always in triple braces, in the templates:

<nav class="{{{cls.sidebar}}}">

Double braces would escape the content, and a utility class such as aria-[current=page] would become aria-[current&#x3D;page] — a silent selector, without the slightest error.

The stylesheets

The delivered stylesheet is assembled from four pieces, in this order:

StylesheetContent
structure.cssGrid, sticky columns, accessibility. Shared by all
prose.cssTypography of the content
a skin or a bridgecustom.css, or tailwind-bridge.css
the components' oneThe dp-* rules of the shipped components

Then comes what the project adds: theme.css, then every .css file of its theme/ folder, in name order.

The layout is never duplicated in a provider: it lives in structure.css, which both share. A provider only takes care of the styling.

Layer order

Under the tailwind theme, the stylesheet declares its layers in this order:

@layer theme, base, components, utilities;

Component rules live in components, below the utilities. A className set at use therefore always wins, whatever the place of the rule in the file.

The custom theme has no utility layer: its stylesheets are in no layer, and therefore come before the component rules, which stay in the components layer.

What theme.css and the theme/ folder add is in no layer: without a layer, a rule wins over all those that have one. That is what lets you write a fix there without worrying about specificity.