Skip to main content
Apply a CSS class only when a condition is true, using the same data as Template Variables. Use it to style state (resolved, dark mode, unread, …) without writing a new wireframe.

Syntax

  • class-name: the class to apply, in single quotes.
  • template-variable: the variable to evaluate, in curly braces.
  • operator: ===, !==, >, >=, <, <=; combine conditions with && and ||.
  • value: what to compare against, in single quotes for strings.
A boolean variable needs no operator: 'is-dark': {darkMode}.

Example

Multiple classes and the shorthand form

Separate several classes with commas. For a single class driven by one boolean, velt-class-<name> is shorter.
Your classes land on the element alongside Velt’s own. Velt’s runtime styles are high-specificity, so a rule that overrides Velt’s styling still needs !important: see Override classes.
  • Many states already have a Velt class you can target directly, no directive needed: CSS classes.
  • Hide the element entirely instead of restyling it: Conditional Templates.