Skip to content

Variable: CLASS_REF ​

ts
const CLASS_REF: Regex<"\\.(?:-)?(?<className>[A-Za-z_][\\w]*?)(?=-(?!\\.)|\\.($)", {
  flags: "gu";
  names: {
     className: string;
  };
}>;

Defined in: packages/regex/src/tiers/cssdoc-local.ts:33

CSS Class Reference Pattern Matches all CSS class selectors in a selector string. Used in scoped-part scan and base class inference.

Matches both regular classes (.button) and modifier classes (.-active, .-size-lg). For chained modifiers, captures only the base part (before the value separator -).

Example ​

ts
// Returns all matches via exec or matchAll
const matches = [...".button.-active.-size-lg".matchAll(CLASS_REF)];
// matches[0]?.groups?.className === "button"
// matches[1]?.groups?.className === "active"
// matches[2]?.groups?.className === "size"

Released under the MIT License