Navigation

Directives

Scanning

Include or exclude source files and specific class names.

On this page

File policy chooses where to read candidates; candidate policy chooses which complete class strings remain eligible. These directives do not change the parser or turn arbitrary source text into valid utilities. See Scanning class names for configuration and troubleshooting, and Extraction for supported source syntax and lifecycle.

File selection and candidate selection are different filters

Excluding draft.html stops its flex candidate from entering this source scope. Blocklisting hidden removes a candidate after collection; safelisting block adds an explicit candidate.

Text description
  1. @source includes the HTML files, and @source not excludes draft.html. Only main.html contributes its grid and hidden class strings.
  2. @safelist "block" adds a complete candidate independently of a source file.
  3. @blocklist "hidden" removes that candidate. The resulting eligible set is grid and block; flex never entered this scope.
  4. File and candidate policies are distinct. Eligibility is not proof that an arbitrary class string is valid; normal matching and diagnostics still apply.

@source

Ordinary application sources use the integrations' and CLI's default discovery. Add explicit exceptions when needed:

@source "../content/**/*.mdx";

@source not

Exclude matching files from the source set:

@source not "../content/drafts/**";

Brace groups such as {a,b} expand to separate patterns; one pattern may contain at most 64 brace groups and expand to at most 1,024 patterns.

Includes are combined as a union, then all excludes are subtracted. Every relative pattern resolves from the stylesheet that declares it, including bare src/**, ./src/**, imported files, and @source not. A reference does not contribute scanning sources.

File-resolving APIs require a declaring file or explicit base file. Source-only directive inspection can return unresolved metadata; it must not invent a filesystem base. The scanner's programmatic cwd option retains its existing meaning for scanner options supplied directly through that API.

@safelist

Add complete class candidates that cannot appear literally in scanned source:

@safelist "(opacity:1)";@safelist "bg-blue-60@dark";

Candidates use the same matching and diagnostic policy as discovered classes. Keep dynamic alternatives bounded and explicit.

To retain named animation definitions without generating a class or animation declaration, use the explicit keyframe target:

@safelist keyframes "fade" "pop";

Each quoted string is one complete CSS animation name. Names are case-sensitive and support CSS escapes; a space inside a string is part of its name. There is no wildcard expansion or class splitting. Missing names, unquoted names, commas and nested safelist directives are errors. A name absent from the complete import/reference graph produces a warning. Safelists merge within each entry's graph and are withdrawn when their source or directive is removed. @reference does not import safelist roots. There is no keyframe blocklist or separate keyframe prune/preserve target.

@blocklist

Remove unwanted complete candidates with exact strings or * and ? wildcard patterns:

@blocklist "debug-*";@blocklist "example-token";

The stylesheet grammar does not interpret slash-delimited patterns as regular expressions. Wildcard policy belongs in the blocklist; a safelist supplies complete classes.