Enter a search term above to see results...
On This Page
CSS Helpers
CSS helpers provide utilities for working with CSS classes and styles in templates.
Functions
classes
Joins CSS classes, optionally adding a space after the final class name.
Template Syntax
Parameters
Name | Type | Default | Description |
---|---|---|---|
classNames | array | Array of class names | |
spaceAfter | boolean | true | Whether to add a space after the final class name |
Returns
string
- Joined class names.
Example
classIf
Conditionally applies a CSS class.
Template Syntax
Parameters
Name | Type | Default | Description |
---|---|---|---|
expr | boolean | Condition to evaluate | |
trueClass | string | ” | Class to apply if condition is true |
falseClass | string | ” | Class to apply if condition is false |
Returns
string
- The resulting class name with a trailing space.
Example
classMap
Applies multiple CSS classes based on conditions.
Template Syntax
Parameters
Name | Type | Description |
---|---|---|
classObj | object | Object with class names as keys and conditions as values |
Returns
string
- Resulting class names with a trailing space.
Example
activeIf
Adds ‘active’ class if expression is truthy.
Template Syntax
Parameters
Name | Type | Description |
---|---|---|
expr | boolean | Condition to evaluate |
Returns
string
- ‘active ’ if condition is true, otherwise an empty string.
Example
selectedIf
Adds ‘selected’ class if expression is truthy.
Template Syntax
Parameters
Name | Type | Description |
---|---|---|
expr | boolean | Condition to evaluate |
Returns
string
- ‘selected ’ if condition is true, otherwise an empty string.
Example
disabledIf
Adds ‘disabled’ class if expression is truthy.
Template Syntax
Parameters
Name | Type | Description |
---|---|---|
expr | boolean | Condition to evaluate |
Returns
string
- ‘disabled ’ if condition is true, otherwise an empty string.
Example
checkedIf
Adds ‘checked’ class if expression is truthy.
Template Syntax
Parameters
Name | Type | Description |
---|---|---|
expr | boolean | Condition to evaluate |
Returns
string
- ‘checked ’ if condition is true, otherwise an empty string.