Module style

Module style 

Source
Expand description

What can reach a class=, enumerated.

docs/104-styling-and-the-component-library.md §104.4:

The compiler already knows every string that can reach a class= attribute, across imported modules, because it resolved them. […] Exact extraction. No false positives (a def truncate is a definition, not a token), no false negatives across a module boundary, and no configuration.

That is the claim; this is the analysis behind it. It answers two questions about a program and neither of them is about Tailwind: which class names can this page carry, and where does the program build one the compiler cannot know. The first is what a stylesheet emitter needs (§8.5.4’s next styling item). The second is what makes the first honest, because a scanner that silently misses a name produces a page missing a rule, which is the failure §104.3 measured in Tailwind’s own scanner over this tree.

§Why a list is the shape that can be enumerated

class=["btn", "primary" if hot else "plain"] has four leaves and every one is a literal, so the set is {btn, primary, plain} and the analysis is a fold over the tree. class="btn " + variant has one leaf that is a value, and no analysis recovers what it can hold. The two are the same page and only one of them can be styled without a safelist, which is the whole reason beck_macro’s ui: lowering learned to take a list.

So this module refuses rather than guesses, and says which of the two a program wrote. A refusal here is not an error: nothing is rejected, and the caller decides what to do with a site it cannot enumerate. beck explain style prints them, and the emitter that follows will need a deliberate escape hatch for the genuine cases (§104.4’s @style(dynamic)), which is a decision rather than a default.

Structs§

Dynamic
One class= the analysis could not work out, and why.
Named
One literal class token, where it was written.
Rule
One utility’s CSS: where it sits, what it selects, and what it declares.
Styles
Every class a program’s pages can carry, and every place one could not be worked out.

Enums§

Because
Why a class expression could not be enumerated.

Functions§

check_classes
Warn about a class that is one slip away from a utility.
classes
Enumerate every class a program’s class= attributes can carry.
enumerate
Every closed utility name this table knows, and every variant that can go in front of one.
is_utility
Whether this class is a Tailwind utility Beck knows.
nearest_utility
The utility nearest a name, and how far away it is.
properties
Every registered custom property the utilities use, and what each is.
rule
The rule for one class, or None if it is not a utility this knows.
stylesheet
The stylesheet a program’s pages need, and nothing else.
supports
The condition guarding the sheet’s fallback for browsers with no registered custom properties.
theme
One theme token’s value, or None if the theme does not define it.
theme_tokens
Every token the theme defines, so the gate can hold each to Tailwind’s own value.