EmeraldCSS v2 Documentation
A utility first css-framework with comprehensive container system and 12-column grid.
Quick Tip:This page is a perfect example of how to build beautiful interfaces using only EmeraldCSS v2 utility classes!
About `emerald-v2.css`
- File Size: 27.0 KB (normal), 5.6 KB (gzipped)
- Lines of Code: 1001 lines
- CSS Reset: Minimal reset with box-sizing, margin, padding, and list styling
- Variables: 100+ CSS custom properties
- Utility Classes: 200+ utility classes for layout, typography, colors, and components
Benefits
- Zero custom CSS - Pure utility-first approach
- Responsive design - Built-in responsive classes
- Grid system - 12-column grid with responsive breakpoints
- Framework validation - Proves completeness of EmeraldCSS v2, comparable to bootsrap and tailwind
Page Structure
EmeraldCSS v2 follows a semantic HTML structure that's compatible with Tabler and Bootstrap patterns.
Semantic HTML Structure
<main>
<header> <!-- Navigation header (white background) -->
<nav>
<a href="#">Brand</a>
<ul>
<li><a href="#">Link</a></li>
</ul>
</nav>
</header>
<div> <!-- Page wrapper (light gray background) -->
<section> <!-- Page header (content header) -->
<h1>Page Title</h1>
</section>
<section> <!-- Page body (main content) -->
<p>Content goes here</p>
</section>
</div>
</main>
Framework Comparison
Tabler Structure (Class-based)
<div class="page">
<div class="navbar">
<div class="container">
<a class="navbar-brand">Brand</a>
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link">Link</a></li>
</ul>
</div>
</div>
<div class="page-wrapper">
<div class="page-header">
<div class="container">
<div class="row">
<div class="col">
<h1 class="page-title">Page Title</h1>
</div>
</div>
</div>
</div>
<div class="page-body">
<div class="container">
<div class="row">
<div class="col-12">
<p>Content goes here</p>
</div>
</div>
</div>
</div>
</div>
</div>
Bootstrap Structure
.container→.row→.col.navbar(separate from main content)
EmeraldCSS v2 Structure (Two Forms)
Form 1: Tabler-like with Classes
<main class="page">
<header class="navbar">
<div class="container">
<a class="navbar-brand">Brand</a>
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link">Link</a></li>
</ul>
</div>
</header>
<div class="page-wrapper">
<section class="page-header">
<div class="container">
<h1>Page Title</h1>
</div>
</section>
<section class="page-body">
<div class="container">
<p>Content goes here</p>
</div>
</section>
</div>
</main>
Form 2: Semantic Class-less Structure
<main>
<header>
<div class="container">
<a>Brand</a>
<nav>
<ul>
<li><a>Link</a></li>
</ul>
</nav>
</div>
</header>
<div>
<section>
<div class="container">
<h1>Page Title</h1>
</div>
</section>
<section>
<div class="container">
<p>Content goes here</p>
</div>
</section>
</div>
</main>
Structure Breakdown
- Main Container:
main(ormain.page) - Navigation:
header(orheader.navbar) - Page Wrapper:
div(ordiv.page-wrapper) - Page Header:
section:first-child(orsection.page-header) - Page Body:
section:not(:first-child)(orsection.page-body)
CSS Selector Logic
main > header- Navigation header stylingmain > div- Page wrapper (light gray background)main > div > section:first-child- Page header (content header)main > div > section:not(:first-child)- Page body (main content)
Color Scheme
- Navigation Header: White background with border-bottom
- Page Wrapper: Light gray background (
var(--color-light)) - Page Header: Transparent background
- Page Body: Transparent background
Spacing
- Page Header: Margin-top only (
var(--rem-8)) - Page Body: Margin top and bottom (
var(--rem-8))
Root Variables
EmeraldCSS v2 uses CSS custom properties (variables) for consistent theming and easy customization.
Total Variables: 49 variables across 6 sub-sections
- Colors: 13 variables
- Typography: 7 variables
- Fonts: 4 variables
- Spacing: 10 variables
- Border Radius: 4 variables
- Percentages: 12 variables
- Breakpoints: 7 variables
Color Variables (13 variables)
--color-primary: #0969da- GitHub blue, primary brand color--color-secondary: #6f42c1- Purple, secondary brand color--color-success: #1a7f37- Green, success states--color-danger: #cf222e- Red, error states--color-warning: #9a6700- Orange, warning states--color-info: #17a2b8- Teal, informational states (Tabler-inspired)--color-azure: #4299e1- Azure blue, additional accent color--color-muted: #656d76- Gray, secondary text--color-dark: #1f2328- Dark gray, primary text--color-light: #f6f8fa- Light gray, backgrounds--color-white: #ffffff- Pure white--color-border-1: #e1e4e8- Light gray, borders
CSS Reset
EmeraldCSS v2 includes a minimal CSS reset that normalizes browser defaults while preserving useful styling.
Reset Features
- Box-sizing: Border-box for all elements
- Margin/Padding: Reset to 0 for consistent spacing
- List Styling: Proper bullet points and indentation
- Minimal Approach: Only resets what's necessary
List Demo
Unordered List
- First item with proper bullet point
- Second item with spacing
- Third item with consistent styling
Ordered List
- First numbered item
- Second numbered item
- Third numbered item
Base Styles
EmeraldCSS v2 provides consistent base styles for HTML elements.
Total Rules: 2 base style rules (html, body)
Font Family Fallback Chain
The --font-family variable uses a comprehensive fallback chain:
- -apple-system - Apple's system font (San Francisco on macOS/iOS)
- BlinkMacSystemFont - Chrome's system font on macOS
- 'Segoe UI' - Microsoft's system font (Windows 10+)
- 'Noto Sans' - Google's web font (cross-platform)
- 'Helvetica Neue' - Apple's Helvetica variant
- Helvetica - Classic Helvetica
- Arial - Universal fallback
- sans-serif - Generic sans-serif fallback
Font Demo
System Font Stack: This text uses the complete font fallback chain. On macOS, it will use San Francisco (-apple-system). On Windows, it will use Segoe UI. On other systems, it will fall back to Noto Sans, Helvetica, or Arial.
Typography
EmeraldCSS v2 provides a comprehensive typography system with consistent font sizes, weights, and line heights.
Heading 1 - Main Title
Heading 2 - Section Title
Heading 3 - Subsection
Heading 4 - Minor Heading
Heading 5 - Small Heading
Heading 6 - Smallest Heading
This is a paragraph with bold text and italic text. It demonstrates the default body text styling with proper line height and spacing.
This is muted text for secondary information or less important content.
This is small text for captions, footnotes, or fine print.Text Utilities
EmeraldCSS v2 provides text utility classes for font-sizes and font weights.
font-size
font-weight
Color System
EmeraldCSS v2 features a modular color system with semantic tokens and an efficient generic palette system that reduces file size while providing maximum flexibility.
Semantic Colors
Core semantic colors for consistent UI patterns across all applications.
Generic Color Palette System
EmeraldCSS v2 uses a revolutionary generic color palette system that reduces file size by 22% while providing maximum flexibility. Instead of including all color palettes in the main CSS, you can load only the palette you need.
How It Works
The system uses generic variable names (--color-50 to --color-900) that work with any palette. The main CSS includes a default blue palette, and additional palettes override these variables when loaded.
Default Blue Palette (Material Design)
Complete Material Design blue palette with 14 shades from lightest to darkest:
Palette Override System
Load additional palettes by including them after the main CSS file. Each palette file is only ~500 bytes:
<!-- Default Blue Palette (included in main CSS) -->
<link rel="stylesheet" href="/emerald-v2.css">
<!-- Override with Red Palette -->
<link rel="stylesheet" href="/palettes/emerald-palette-red.css">
<!-- Override with Purple Palette -->
<link rel="stylesheet" href="/palettes/emerald-palette-purple.css">
<!-- Override with Green Palette -->
<link rel="stylesheet" href="/palettes/emerald-palette-green.css">
Available Palettes (29 Total)
Complete Material Design color palette collection plus popular brand palettes - each palette includes 14 shades (50-900 + A100-A700) plus brand-specific body backgrounds and semantic colors:
Blue (Default)
Included in main CSS
Red
emerald-palette-red.css
Pink
emerald-palette-pink.css
Purple
emerald-palette-purple.css
Deep Purple
emerald-palette-deep-purple.css
Indigo
emerald-palette-indigo.css
Light Blue
emerald-palette-light-blue.css
Cyan
emerald-palette-cyan.css
Teal
emerald-palette-teal.css
Green
emerald-palette-green.css
Light Green
emerald-palette-light-green.css
Lime
emerald-palette-lime.css
Yellow
emerald-palette-yellow.css
Amber
emerald-palette-amber.css
Orange
emerald-palette-orange.css
Deep Orange
emerald-palette-deep-orange.css
Brown
emerald-palette-brown.css
Grey
emerald-palette-grey.css
Blue Grey
emerald-palette-blue-grey.css
Brand Palettes
Popular brand color palettes with authentic brand colors and matching body backgrounds:
GitHub
emerald-palette-github.css
GitHub Dark
emerald-palette-github-dark.css
Azure
emerald-palette-azure.css
YouTube
emerald-palette-youtube.css
emerald-palette-twitter.css
emerald-palette-instagram.css
Apple
emerald-palette-apple.css
Tabler
emerald-palette-tabler.css
emerald-palette-facebook.css
emerald-palette-linkedin.css
emerald-palette-google.css
Generic Utility Classes
All palettes use the same utility class names, making it easy to switch between palettes:
Background Colors
.bg-50 to .bg-900 and .bg-A100 to .bg-A700
Text Colors
.text-50 to .text-900 and .text-A100 to .text-A700
Usage Examples
<!-- These classes work with any palette -->
<div class="bg-500 text-white">Primary Color</div>
<div class="bg-100 text-900">Light Background</div>
<div class="bg-A200 text-white">Accent Color</div>
File Size Benefits
- Main CSS: 27.0KB raw, 5.6KB gzipped (22% smaller than traditional approach)
- Palette Files: ~500 bytes each (only load what you need)
- Total Savings: 6KB raw, 1KB gzipped compared to including all palettes
- Modular: Load only the palette you need for your project
Container System
EmeraldCSS v2 provides responsive containers with different max-widths and breakpoints.
12-Column Grid System
EmeraldCSS v2 includes a Bootstrap-like 12-column grid system with responsive breakpoints.
Flexbox Utilities
Comprehensive flexbox utilities for layout control.
Flex Direction
Justify Content
Spacing Utilities
EmeraldCSS v2 provides comprehensive spacing utilities for margins and padding using CSS variables.
Margin Utilities
All Sides (m-0 to m-4)
Horizontal (mx-0 to mx-4)
Vertical (my-0 to my-4)
Individual Sides
Padding Utilities
All Sides (p-0 to p-4)
Horizontal (px-0 to px-4)
Vertical (py-0 to py-4)
Individual Sides
Spacing Scale
- 0: 0 (no spacing)
- 1: 0.25rem (4px)
- 2: 0.5rem (8px)
- 3: 0.75rem (12px)
- 4: 1rem (16px)
Total Utilities: 60 spacing utility classes (30 margin + 30 padding)
Form Controls
EmeraldCSS v2 provides comprehensive form styling with utility classes for all form elements.
Form Elements Comparison
Without Form Classes
Radio option 2
With Form Classes
Button Styles
Button Variants
Button Outlines
Button Sizes
Button States
Form Layout Examples
Horizontal Form
Form Validation States
Form Utility Classes
.form-control- Styles text inputs, textareas, and select elements.form-select- Styles select dropdowns.form-check- Container for checkboxes and radio buttons.form-check-input- Styles checkbox and radio inputs.form-check-label- Styles labels for checkboxes and radios.form-switch- Creates toggle switch appearance.form-label- Styles form labels.col-form-label- Styles labels in horizontal forms.is-valid- Applies valid state styling.is-invalid- Applies invalid state styling.valid-feedback- Styles success messages.invalid-feedback- Styles error messages
Navigation
EmeraldCSS v2 provides navigation components using the grid and flexbox utilities.
Framework Comparison
How EmeraldCSS v2 compares to Bootstrap and Tabler CSS frameworks.
Feature Comparison
- Container: Responsive containers (
.container,.container-sm,.container-md,.container-lg,.container-xl) with CSS variables vs Bootstrap's responsive containers - Grid System: 12-column grid with CSS variables and responsive breakpoints vs Bootstrap's standard grid
- Flexbox:
.d-flex,.flex-1,.justify-content-*,.align-items-*vs Bootstrap's flexbox utilities - Gap Utilities:
.gap-1to.gap-8with responsive variants (.gap-sm-*,.gap-md-*,.gap-lg-*) - Colors: CSS custom properties with semantic tokens and modular palette system vs theme colors
- Typography: CSS custom properties for all values with utility classes vs utility-only approach
- Cards:
.card(minimal, consistent) with semantic HTML support vs comprehensive card systems - Responsive: Mobile-first with CSS variables and responsive utilities vs mobile-first approach
- Spacing: Comprehensive margin/padding utilities (
.m-0to.m-4,.p-0to.p-4) with directional variants - Components: Form controls, buttons, modals with CSS variables vs pre-styled components