Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Utilities

classList

This function takes in an array of classes and returns a string of space separated entries that can be used for CSS classname assignments.

Params

classList : An array containing strings or <string,boolean> arrays

Returns

Returns a string of space separated entries that can be used for CSS classname assignments.

Examples

import { classes } from '@adobe/elsie/lib';
type ClassList = Array<string | [string, boolean] | undefined>;
const classList: ClassList = ['class-1', 'class-2', 'class-3'];
const result = classes(classList);
console.log(result); // "class-1 class-2 class-3"

You can use a <string,boolean> array to control whether a class should be included or omitted from the final classes list.

import { classes } from '@adobe/elsie/lib';
type ClassList = Array<string | [string, boolean] | undefined>;
const classList: ClassList = [
'class-1',
['class-2', true],
['class-3', false],
'class-4',
];
const result = classes(classList);
console.log(result); // "class-1 class-2 class-4"