Skip to main content

Function: cssClasses()

cssClasses(component, classRules, includeComponentClassName): string

Defined in: packages/react-page-renderer/src/componentHelpers.ts:97

Generate a string of CSS classes from the properties of the passed-in object that resolve to true.

Parameters

component

The component requiring the composition of the CSS class names.

AbstractComponent | AbstractPureComponent

classRules

CSS classes in a string separated by whitespace, or a map of CSS class names to boolean values. The CSS class name will be included in the result only if the value is true.

string | string[] | {}

includeComponentClassName

boolean

Returns

string

String of CSS classes that had their property resolved to true.

Examples

this.cssClasses('my-class my-class-modifier', true);
this.cssClasses({
'my-class': true,
'my-class-modifier': this.props.modifier
}, true);