---
url: /reference/packages/regex/src/namespaces/CssdocLocalPatterns/variables/CLASS_REF.md
---
# 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](https://github.com/thedannywahl/cssdoc/blob/main/packages/regex/src/tiers/cssdoc-local.ts#L33)

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"
```
