Skip to content

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

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.

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

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

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"