Using the theme
How to change what a component draws, and the four places it goes wrong. For the model behind these rules, see Overview. For the mapping and the exceptions, see Reference.
Telling whether a colour is from the system
One question settles it: can you name the token this resolves to? If getting there takes more than one hop, the answer is no.
Is it a stock family? A name like red-500 or gray-300 belongs to the framework's own palette. It paints, and it paints a colour nobody here chose.
Is it a step the system defines? The ramps stop where they stop, and a step past the end still paints. This is the third way a class can fail silently, after the two tokens already names.
Does it arrive through somebody else's variable? A semantic name from the library underneath reaches a Caido value through a chain the system does not control. It stops resolving the moment that chain is removed.
Replacing a preset step with a token
Read the job the step is doing on the property it sits on, then pick the token for that job. Do not translate by lightness, and do not translate the same number the same way twice.
The darkest step of the preset's own ramp becomes fg-strong when it is a foreground and surface-page when it is a background. Reference carries the full ladder.
Never hand-writing a light and dark pair
A token already holds both values, so a pair written by hand applies the system's inversion a second time.
Do
<template>
<div class="bg-surface-page text-fg-default" />
</template>One name, both appearances, and nothing to keep in step.
Do not
<template>
<div class="bg-surface-0 dark:bg-surface-900 text-fg-default" />
</template>Two names for one job, inverted twice, agreeing only because dark is the default.
The variant and the token read different attributes, so the halves agree by coincidence rather than by construction. Keep the half that is correct when the appearance is dark, since dark is the default, and delete the variant.
TIP
The exception is a pair that expresses maximum contrast against whatever the appearance is, rather than one job at two lightnesses. The ordinary rule inverts its meaning, and only measuring tells the two apart.
Putting text on a fill
The ladder that maps a preset step to a text token is about weight. It says nothing about what the text is sitting on, and a fill is not a surface.
Do
The fill's own foreground, computed against that exact fill and nothing else.
Do not
A foreground from the surface ladder, measured against a surface this text is nowhere near.
Colour owns the reasoning. A fill takes the foreground the pairings table measured against that same fill, which is not always the one whose name matches. fg-on-danger is measured against the strong danger fill and not against the plain one, where it lands at 3.77 against a floor of 4.5.
Reaching a token where a class cannot
A keyframe declaration cannot be a utility class, so an animated colour reads the custom property directly. That is a fourth member of the small set tokens already allows, not a new permission.
Everywhere else, write the class.
Focusing a control that hides its input
A checkbox, a radio and a toggle put keyboard focus on a transparent input, so the ordinary rule outlines an element nobody can see. Draw the indicator on that input's siblings instead, with the same geometry as the ordinary rule, and write it in the consumer's stylesheet rather than in the preset.
Raising a difference against the package
The preset ships from its own repository, so a difference in it is filed there rather than painted over locally.
A local override is a workaround with a deletion date. Name the release that removes it, in a comment beside the override, or it becomes permanent by default.