At this point, I think it would be helpful for you to see how I structure my CSS files.
It’s actually very simple. First of all, I import Tailwind and Splendid Labs.
@layer reset, theme, base, utilities.base, components, utilities;
@import 'tailwindcss/theme.css' layer(theme);@import 'tailwindcss/utilities.css' layer(utilities);
/* Splendid Labz libraries */@import '@splendidlabz/styles';@import '@splendidlabz/styles/components';Then I created three folders: base, components, and pages
/* Base styles */@import './base/index.css';@import './components/index.css';@import './pages/index.css';Base
base includes files that are globally used across the entire stylesheet.
@import './variables.css'; /* global variables */@import './colors.css'; /* color variables only */@import './pigments.css';@import './fonts.css'; /* @fontface declarations*/@import './type.css'; /* font-family and type utilities */Components
components are, well, components. I don’t differentiate between components and utilities because I use Tailwind’s @utility to create components.
It doesn’t matter whether the styles are used once or many times. If I notice the extracted styles help me use the component in an easier way, I extract them and place them here.
Here’s an example for this site.
@import './breadcrumbs.css';@import './callout.css';@import './contentlist.css';@import './drawer.css';@import './lesson-drawer.css';@import './lesson-list.css';@import './main-nav.css';@import './mds-logo.css';@import './pigments.css';@import './popover.css';@import './product-tabs.css';@import './prose.css';@import './rainbowbox.css';@import './status.css';@import './demo.css';Pages
The final category is pages.
I don’t use this folder for most of my sites.
I only use this when I notice that certain styles of a component needs to change based on a page.
For example, the font-size and measure for a sales page, a blog page, and a documentation page can be quite different. If I have all three kinds of pages on a single project, I will use one as a default and create variants of the others using pages.
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson