var()

The CSS function that reads a custom property, with an optional fallback: var(--brand, #2563eb).

In more detail

If the named property is not defined where the element sits, the browser uses the fallback instead. Components should always give one, so they still look sensible when a host application forgets to define a token. Tailwind version 4 utilities use var() to point at theme variables.

Example

In the browser: If the property is not set the fallback is used. If the property is set but its value is invalid for where it is used, the declaration falls back to the property's inherited or initial value instead, not to the var() fallback.

Related terms

Taught in

References