Skip to content
Cookbookv0.34.2
Color scheme
Contrast
Color scheme
Contrast

Customization rules

Read this guide before changing a Cookbook site’s appearance. It applies to the site’s configuration and its custom components.

Read the configuration first

Inspect docs.config.ts, tasty.config.ts (when the project has adopted style linting), and the components you are changing. Reuse the site’s existing semantic colors, tokens, presets, responsive states, and named sub-elements. Do not invent configuration names. Consult the complete component anatomy reference before overriding a built-in component.

Choose the customization surface

Change Supported surface
Brand and semantic colors theme.brand and the supported theme.palette inputs
Shared dimensions and spacing theme.tokens
Font loading and family roles theme.fonts
Font delivery and caching theme.fontLoading
Typography theme.presets
Responsive conditions theme.states
Glaze adaptation theme.glaze and theme.contrastLevel
Custom units and reusable style bundles theme.units and theme.recipes
Existing component appearance Partial Tasty objects in theme.styles.<Name>
Custom component appearance defineComponent() and theme.customStyles.<Name>
Markup or behavior components.overrides with an owned Astro component

Prefer configuration changes when the markup and behavior already fit. Supply only the properties you want to change; Cookbook merges them into its complete base styles. Do not copy the default style tree, add a second stylesheet, or use !important. The base SiteTitle preset is a state map with a mobile value, so this override sets both states:

import { defineDocsConfig } from "@tenphi/cookbook/config";

export default defineDocsConfig({
  theme: {
    styles: {
      Header: {
        SiteTitle: { preset: { "": "h4 / strong", "!@md": "h5 / strong" } },
      },
    },
  },
});

Keep styling on the server

Tasty and Glaze run during build/server rendering. The browser receives extracted CSS; never initialize their configuration or ship their runtime in client scripts or hydrated islands. Use server-rendered styled components with small client scripts for behavior, or pass already-styled static markup into a client island. Cookbook rejects browser imports of its styling API, Tasty, and Glaze, including transitive dependencies.

Write styles through Cookbook

Import defineComponent, tasty, useGlobalStyles, resolveComponentStyles, and mergeStyles from @tenphi/cookbook/styling as needed. Cookbook supplies the configured runtime and extracts static CSS; installing another Tasty integration or calling upstream configure() is unnecessary. Shared settings belong in docs.config.ts.

  • Express styles with Tasty. Do not add CSS files, CSS modules, Astro <style> blocks, inline style attributes, or imported component styles to customize the documentation interface. The isolated content of Preview is a separate demonstration surface.
  • Model descendants and pseudo-elements as named sub-elements inside the owning style object. Keep their selectors and base styles together instead of spreading component anatomy across unrelated global rules.
  • Use semantic color tokens such as #text, #surface, and #accent-text in component styles. Configure Glaze color declarations through theme.brand and theme.palette so Glaze can resolve every scheme and contrast mode. Declare any new semantic color role in theme.palette before using its #name token. Do not hard-code component colors.
  • Apply semantic typography with preset, for example "small" or "h2 / strong". Do not reconstruct presets from individual font tokens or wire modifier internals such as $bold-font-weight yourself.
  • Use defineComponent(name, options) for customizable component roots. For global style trees, pass resolveComponentStyles(name, baseStyles) to useGlobalStyles(). Both read partial overrides from theme.customStyles. Document each custom component’s name and complete named sub-element list.
  • When replacing a component, own its markup and behavior. Keep keyboard access, focus, semantics, responsive behavior, and appearance modes intact.

The custom component examples show both a component root and a global style tree using these APIs.

Read the underlying references

Cookbook’s rules govern its integration and supported customization surfaces. Use the upstream references for syntax and color behavior. Upstream examples may configure standalone applications or other frameworks; keep Cookbook’s imports, configuration, and rendering setup when adapting them.

Documentation in the installed package

The public @tenphi/cookbook package includes this guide and the rest of the Cookbook documentation in docs/, indexed by docs/llms.txt. Its docs/upstream/ directory contains generated Tasty and Glaze documentation snapshots, their READMEs, and licenses. docs/upstream/manifest.json records the source package versions and release references. These match the dependencies used to build that Cookbook release; consumer dependency overrides can change the installed runtime independently.

In the packaged copies, links to available upstream reference pages point to these local snapshots. The Markdown references work offline. Each Glaze guide prints the code of the examples that render live on the Glaze website, with tables of the colors they resolve to, and links to its page there. Links to source code and artwork absent from the npm packages point to their upstream release and still need internet access. The published website keeps its online links.

Start at node_modules/@tenphi/cookbook/docs/agents.md: it names the page for each task. What is installed shows how to find these docs when the package manager installs Cookbook elsewhere. The snapshots are generated during Cookbook’s build and packaging, with no network fetch or consumer installation hook.

Guide coding agents explicitly

Having documentation installed does not ensure an agent reads it. Sites from the project creator have this in their AGENTS.md. In a project you set up yourself, add the validate script that CLI commands lists, and a short instruction to its agent guidance, adjusting the path for the app that depends on Cookbook:

Before changing this Cookbook site, read
node_modules/@tenphi/cookbook/docs/agents.md and the page it names for the
task. Before customizing styles, read customization-rules.md there and follow
its linked Tasty and Glaze references. Inspect docs.config.ts (and
tasty.config.ts, if present) first.
Use Cookbook's public styling APIs, semantic palette tokens, typography
presets, and partial component overrides. After changes, run the project's
validate script, and its style lint if it has one.

With harnesspm, the project gets Cookbook’s rule and the index of these docs in its agent instructions instead, at the installed version, together with Tasty and Glaze tools that read the site’s theme and Tasty lint tools.

Check the result

Build the site’s tasty.config.ts with createValidationConfig(docs.theme), so the lint rules know your theme’s palette colors, tokens, and other names. Linting custom styles sets up ESLint or oxlint.

Run the site’s validate script, and its style lint if it has one. The linter checks supported Tasty rules in your component modules; it does not check theme.styles values, enforce every architectural rule above, or inspect arbitrary CSS. Review custom components at mobile and desktop sizes, with keyboard navigation, in light and dark schemes, and with normal and high contrast.