Mixins / API

foldkit-mixins/theme

foldkit-mixins/theme: the root export's Theme plus the page-level pieces. root and scoped turn tokens into unlayered :root and selector rules for Style.stylesheet; make is a theme of typed knob values, and standard every shipped token with a theme's knobs; schemeScript and chooseScheme keep a reader's light or dark choice, and knobScript and chooseKnobs the knob values of a theme they made.

Namespaces

COLOR_SCHEME_HINT_HEADERSThe response headers that make a browser send Sec-CH-Prefers-Color-Scheme from its first request: Accept-CH opts in, Critical-CH has the browser retry the…
KnobKnobs: the typed inputs a theme sets. Each knob is a Schema for the value a theme writes, the CSS variables that value writes, and what those variables hold…
KnobsThe knobs a theme sets: Knobs.standard, every knob the shipped tokens read.
Theme
ThemesThemes installed by name: Themes.make({ iris, cobalt }, { initial: 'iris' }); Themes.apply shows one, Themes.choose shows and keeps it, and Themes.script…
ThemeValue

Functions

breakpointWidthsEach breakpoint query's min-width in pixels (rem at 16), so CSS and the Model agree on what md means. A query that is not a plain min-width is refused: it…
chooseKnobsApplies theme's knobs to selector and keeps them under key for the next visit, as a Command's effect: the knobs that differ from base, so the base theme…
chooseSchemeApplies scheme to the root element and keeps it under key for the next visit, as a Command's effect. 'system' removes both. Storage that throws still…
composeThemes merged at definition time, later tokens winning within a group.
concentricA control's corner, concentric with the nearest container that nests (a card, a dialog, a toast) and kept between min and max: a deep inset would square it…
containerFluidProgresscontainerFluidRatio() at the theme's strength, for --fk-fluid-progress on a container's content.
containerFluidRatioThe theme's range measured on the nearest inline-size container.
currentSchemeThe scheme the root element shows now: what schemeScript or chooseScheme applied.
define
fluidRatioThe ratio for a checked px range; see fluidRatioOf.
fluidTypemin at the small viewport, max at the large one, by the theme's fluid strength: calc(min + (max - min) * var(--fk-fluid-progress)). A still theme…
inContainerThe same breakpoints measured on a named container rather than the window: Theme.inContainer('page', Theme.tokens.breakpoint) gives md as '@container page…
knobScriptThe text of a <script> for the document's head: it applies the knobs kept under key to selector, so a reader who made a theme never sees the default for a…
ladderA control's dimension on the size ladder: name's default end blended toward its compact one by the step knob, and spacing multiplied by density. The blend…
lightDarkA token that follows the user's color scheme with CSS light-dark(): no JavaScript and no Model field. A theme the user chooses is the other case, and…
nestedThe radius of a rounded surface inset in another, so their corners are concentric: the outer radius less the inset between them and the outer surface's…
nestsWhat a container that pads its children publishes for nested() and concentric(): its corner inside its border, the inset to them, and the corner a control…
raiseAn element offset levels above the raised element holding it, or the page: popovers and menus are 2, dialogs 4. Paint it with raisedSurface.
raisedSurfaceThe background of a raised element at its level, from the palette's base surface. In a light scheme the first two steps go toward white and the rest stay…
refThe theme's tokens as references: Theme.ref(theme).surface.overt is var(--fk-surface-overt), and a group or name the theme lacks is a type error. Only the…
roleText in role: its size and leading on the size ladder, read on the element like ladder, so a compact region's text steps down with its controls. A display,…
root
schemeChangesThe scheme another tab chose, each time it does: what its chooseScheme kept under key, with a removed key or anything else read as 'system', as schemeScript…
schemeOfHintThe scheme a Sec-CH-Prefers-Color-Scheme request header reports, for a server that builds the Model per request, or none for an absent or unknown value. The…
schemeScriptThe text of a <script> for the document's head, before any stylesheet draws: it applies the scheme kept under key, so a reader who chose dark never sees one…
scopedToken overrides under selector: a named theme the Model selects with a root attribute (:root[data-theme="ocean"]), or a scheme the user chose…
themeChangesThe theme another tab chose, each time it does: what its chooseTheme kept under key, with a name no theme has, a removed key and anything else read as the…
variables

Values

KNOBS_FORMATThe kept entry's format. Raise it when a knob is renamed or its variable changes meaning, and an entry kept by an older build is ignored rather than applied…
KNOBS_KEYThe storage key kept knobs live under, unless one is given.
SCHEME_KEYThe storage key a chosen scheme is kept under, unless one is given.
THEME_KEYThe storage key a chosen theme's name is kept under, unless one is given.
tokens
VAR_PREFIX

Interfaces

ChoiceA knob that is one of its options, each in full, as write gives a chosen one.
KnobOfA knob of Value writing the variables Names. write gives those a value sets (a light-only value leaves the dark one out); unset gives every one, as no theme…
KnobsChoiceA theme's knobs to apply, and the theme the page's stylesheet already declares.
KnobsPlaceWhere kept knobs are kept, and the elements they apply to.
KnobThemeA theme: the knobs it may set, the values it sets, and what it is called in a list.
RootOptions
SchemedA knob per scheme, and each half as a knob of its own: its range, its title.
ThemeNamesWhat the functions here need of a set of named themes: its names and where the active one is shown.
ThemesOfA set of named themes, one of them shown until the Model chooses another.
ViewportThe smallest and largest viewport a fluid value spans, in px.

Types

ChromeIcon
ControlHow a knob is drawn as a control: a range for a number, a choice of options, a font stack.
FluidRoleA role that may grow with fluid type; the interface roles stay on the control ladder.
FluidTypeOptions
KnobAtThe knob of S at P.
KnobSetKnobs grouped one level deep: { shape: { radius: Knob.number(...) } }.
OverridesSome of a theme's tokens, by the theme's own group and token names.
Palette
PathOfOne knob of S, by its group and name: shape.radius.
Refsvar(--fk-group-name) for every token, by the theme's own group and token names.
RoleA role of the type scale.
RungA dimension on the size ladder, by its default end's name.
SchemeWhat a reader may choose: a scheme, or the operating system's.
Standard
StandardTokensEvery shipped token: the scales, the palette, and the knobs they read.
ThemeTokens
Tokens
ValueOfThe value a theme writes to K.
ValuesValues for some of S's knobs, by group and name.
VariablesA knob's variables, by the name after --fk-knob-, each a CSS value.