Skip to main content

Working CSS Classes

The @archibald/client package offers a set of utility functions to work with CSS class names.

classNamesHelper

This function takes array of classes and returns a concatenated string.

import { classNamesHelper } from '@archibald/client';

const cssClassNames = classNamesHelper(PARAMENTERS);

Parameters

NameTypeDescription
classNames(string | boolean | number | null | undefined)[]A list with class names that should be concatenated.

Example

import { classNamesHelper } from '@archibald/client';

const cssClassNames = classNamesHelper(['main', 'secondary']);

// Result: main secondary

createBEMSelector

This function creates a BEM selector.

import { createBEMSelector } from '@archibald/client';

const cssClassNames = createBEMSelector(PARAMENTERS);

Parameters

NameTypeDescriptionDefault
basestringThe name of the class.
bemArgumentsBemArgumentListA list with modifiers.
includeBaseClassbooleanIndicates if the class name should be included in the return.false

Example

import { createBEMSelector } from '@archibald/client';

const cssClassNames = createBEMSelector('main', { element: ['big', 'small'], modifier: ['red', 'blue'] }, true);

// Result: main main__big main__small main--red main--blue