Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Break CSS into smaller, focused files
Each module does one thing well
Reuse modules across projects
Easy to find and update styles
Prevents CSS from becoming messy
Essential for large projects
Each module handles one thing
buttons.css only contains button stylesUse the same module anywhere
card.css works on any pageModules don't depend on each other
Changing buttons doesn't break formsEverything for one component in one file
modal.css has all modal styles/* main.css - Import order matters! */
/* Base styles first */
@import './base/reset.css';
@import './base/typography.css';
@import './base/colors.css';
/* Layout styles */
@import './layout/grid.css';
@import './layout/header.css';
@import './layout/footer.css';
/* Components */
@import './components/button.css';
@import './components/card.css';
@import './components/form.css';
@import './components/modal.css';
/* Utilities last (highest specificity) */
@import './utilities/spacing.css';
@import './utilities/text.css';/* Button Module - All button styles in one file */
/* Base button */
.button {
display: inline-block;
padding: 12px 24px;
font-size: 16px;
font-weight: 600;
text-align: center;
text-decoration: none;
border: none;
border-radius: 6px;
cursor: pointer;
transition: all 0.2s ease;
}
/* Button sizes */
.button--small {
padding: 8px 16px;
font-size: 14px;
}
.button--large {
padding: 16px 32px;
font-size: 18px;
}
/* Button colors */
.button--primary {
background: #3b82f6;
color: white;
}
.button--primary:hover {
background: #2563eb;
}
.button--secondary {
background: #6b7280;
color: white;
}
.button--secondary:hover {
background: #4b5563;
}
.button--success {
background: #10b981;
color: white;
}
.button--success:hover {
background: #059669;
}
/* Button states */
.button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.button--loading {
position: relative;
color: transparent;
}
.button--loading::after {
content: '';
position: absolute;
width: 16px;
height: 16px;
top: 50%;
left: 50%;
margin-left: -8px;
margin-top: -8px;
border: 2px solid white;
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}<div class="demo">
<h2>Button Module in Action</h2>
<div class="section">
<h3>Primary Buttons</h3>
<button class="button button--primary">Default</button>
<button class="button button--primary button--small">Small</button>
<button class="button button--primary button--large">Large</button>
</div>
<div class="section">
<h3>Button Colors</h3>
<button class="button button--primary">Primary</button>
<button class="button button--secondary">Secondary</button>
<button class="button button--success">Success</button>
</div>
<div class="section">
<h3>Button States</h3>
<button class="button button--primary">Normal</button>
<button class="button button--primary" disabled>Disabled</button>
<button class="button button--primary button--loading">Loading</button>
</div>
</div>Loading preview...
Need to change button styles? Go straight to button.css. No hunting through a 5,000-line file!
Need buttons on a new project? Copy button.css and you're done. No copying half a stylesheet!
Updating card.css won't accidentally break your buttons. Each module is independent!
Multiple developers can work on different modules without conflicts. No more merge nightmares!
Each UI component should have its own CSS file. Don't mix button and card styles in one file.
If a module gets too big (>200 lines), split it into smaller modules. Break form.css intoinput.css, select.css, checkbox.css.
Name files after what they style: button.css, navigation.css, modal.css. Not styles2.css or new-css.css.
Always import in this order: Reset → Base → Layout → Components → Utilities. This prevents specificity issues.
Add comments at the top of each module explaining what it does and how to use it. Your future self will thank you!
Building reusable UI components
Websites with hundreds of pages
Multiple developers working together
Consistent UI across products
button.css - keep each module focusedbutton.css shouldn't need card.cssCSS Preprocessors: Sass, Less, PostCSS make imports and organization easier
CSS Modules: React/Vue/Angular can scope CSS to components automatically
Build Tools: Webpack, Vite, Parcel bundle multiple CSS files into one
Frameworks: Bootstrap, Tailwind, Material UI are examples of modular CSS