Questions tagged [itcss]

A sane, scalable, managed CSS architecture for large UI projects.

ITCSS (Inverted Triangle architecture for CSS) is a css architecture introduced in late 2014 by Harry Roberts (CSS Wizardry).

It's based on the assumption that:

Managing CSS at scale is hard; and a lot harder than it should be. ITCSS is a simple, effective, and as-yet unpublished methodology to help manage, maintain, and scale CSS projects of all sizes.

ITCSS exploits the cascading property of CSS taking advantage of a sane selector specificity order.

ITCSS can be used with preprocessors or without them and is compatible with CSS methodologies like BEM, SMACSS or OOCSS.


Concept and ITCSS Fundamentals

One of the key principles of ITCSS is that it separates your CSS codebase to several sections (called layers), which take form of the inverted triangle:

enter image description here

Those layers are as follows:

  • Settings – used with preprocessors and contain font, colors definitions, etc.
  • Tools – globally used mixins and functions. It’s important not to output any CSS in the first 2 layers.
  • Generic – reset and/or normalize styles, box-sizing definition, etc. This is the first layer which generates actual CSS.
  • Elements – styling for bare HTML elements (like H1, A, etc.). These come with default styling from the browser so we can redefine them here.
  • Objects – class-based selectors which define undecorated design patterns, for example media object known from OOCSS
  • Components – specific UI components. This is where majority of our work takes place and our UI components are often composed of Objects and Components
  • Trumps – utilities and helper classes with ability to override anything which goes before in the triangle, eg. hide helper class

The triangle also shows how styles represented by selectors are ordered in the resulting CSS: from generic styles to explicit ones, from low-specificity selectors to more specific ones (but still not too specific, IDs are not allowed) and from far reaching to localized ones:

enter image description here

Such CSS organization should help you avoid Specificity Wars and is represented by a healthy specificity graph.


Resources and Credits

A complete video presentation from Harry Roberts could be viewed online as a video or as slides. Additionally, there is a comprehensive summary, written by Lubos Kmetko, which was used as a standing point for writing the current tag info.

10 questions
3
votes
1 answer

ITCSS: where to put CSS animations?

I'm using ITCSS for my latest project. The layers of the triangle are the follows: Settings — used with preprocessors and contain font, colors definitions, etc. In this layer is common define the variables that can customize the template. Tools —…
sidonaldson
  • 24,431
  • 10
  • 56
  • 61
3
votes
1 answer

Separating structure and skin with ITCSS, BEM, and OOCSS

I am creating a stylesheet inspired by ITCSS, BEM, and OOCSS and am unsure how to separate structure properties from cosmetics properties. An example as I understand ITCSS and OOCSS: //First the structure. Button is an object (ITCSS) .o-btn { …
Ismael Ordás
  • 370
  • 4
  • 12
2
votes
1 answer

How to manage specificity issues using ITCSS and having forms?

I have a large project, structuring its CSS architecture via ITCSS. All in all, I love it. However, I have one issue when styling forms. I've styled different form elements in my elements layer: in forms.scss: input[type="text"],…
user4455199
2
votes
1 answer

How to include external libraries inside ITCSS project?

I have this structure inside my main.scss: //******** ITCSS layers :: https://www.xfive.co/blog/itcss-scalable-maintainable-css-architecture/ //** 1. Settings – used with preprocessors and contain font, colors definitions, etc. //** 2. Tools –…
Stefano Vollono
  • 103
  • 1
  • 9
1
vote
1 answer

ITCSS - Where put classes specific for a page

I'm using ITCSS to structure my styles. Now I have a page with an image where I need that its max-height would be 512px. This property is specific for the image in that page, so using ITCSS where should I put this property? The image has the class…
Mintendo
  • 557
  • 1
  • 8
  • 24
0
votes
1 answer

CSS Project Structure

I'm a little bit lost with my CSS project structure. My project is huge, so after researching, I decided to go with ITCSS Structure, it was all good until I reached ,,Components Layer'' What I did: I broke my components folder into sub-folders as…
0
votes
1 answer

BEMIT: Use helpers all the time vs. extend them in components vs. repeat them in components?

I'm using the BEMIT (BEM + ITCSS) methodology in a project. BEMIT allows you to use helpers ("utilities") such as .u-hidden to hide an element. I have a system where any numeric value (font-size, margin, padding, etc.) can only be a multiple of a…
Sarah Dayan
  • 448
  • 3
  • 9
0
votes
1 answer

Why css object should start with prefix o- and component starts with c-?

Is there any reason why in css naming convention, some object preferably start with prefix o- and component starts with c- ? I know o- will stand for object and c- stand for component, but why don't we just ignore that rules? For example c-btn, why…
csldry
  • 1
  • 1
0
votes
2 answers

Is there any way to only render the template/content of my Angular component?

I want to have a clean HTML, only the component content and not the container, because I want to use ITCSS and RSCSS methodologies. So, thinking that I have 2 components: app-simple-card and app-superior-header; I want have the following…
klauskpm
  • 2,965
  • 2
  • 18
  • 29
0
votes
1 answer

In ITCSS what approach would you use to style a 2 and 3 column layout?

I have a medium sized web project that's growing. Here's what my ITCSS architecture looks like: Settings ...... global vars, config switches, brand colors. Tools ......... default mixins and functions, 3rd party tools. Generic ....... ground-zero…
phteven
  • 1,383
  • 2
  • 16
  • 29