[ITCSS_PREFIX]-[BLOCK_NAME]__[ELEMENT_NAME]--[MODIFIER_NAME]
.ITCSS file organization helps to leverage and control cascade features while avoiding the use of !important
. Prefixing class names helps to identify where files are located and the level of importance in the class name. See assets/src/scss/app.scss
for further clarification.
Class names should be prefixed with an ITCSS identifier, which is determined by file structure:
o-
: Objectsc-
: Componentsu-
: UtilitiesThere are additional prefixes in use that are not relevant to ITCSS structure, but help maintain decriptive naming:
f-
: Font styleComponent wrapper elements are given class names according to their Component name. Child element class names then use the component name as a base, followed by a general description of the element. These are joined with two underscores (__
)
Example, where a component is named “Some Component”:
<section class="c-some-component">
...
<h2 class="some-component__title ...">
<ul class="some-component__items">
<li class="some-component__item">
...
If an element has variations, the variation is appended to the class name with two hyphens (--
).
Example, where a component is named “Some Button”:
<button class="some-button some-button--alert">
Javascript classes are prepened with js-
. These class names should never be used for style, and only act as selectors for javascript actions.
Class names should be relevant to javascript action, such as js-open-modal
.