Milligram CSS Framework

1.4.1 · active · verified Sun Apr 19

Milligram is a minimalist CSS framework designed to provide a lightweight and clean starting point for web projects. Weighing in at only 2kb gzipped, it prioritizes performance and developer productivity by offering a basic set of styles with fewer properties to reset compared to larger UI frameworks. It focuses on core HTML elements like typography, forms, tables, buttons, and a simple grid system. The current stable version is 1.4.1, released in 2023, following a cadence of sporadic updates that address compatibility and add minor feature enhancements, such as responsive tables and new form input types. Its primary differentiation lies in its extreme minimalism, providing only essential styling without dictating a specific UI component library.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to include Milligram's CSS within a JavaScript application (e.g., using a bundler like Webpack) and how it styles common HTML elements within a React component.

// main.js or App.js (for a React/Vue/Angular project using a bundler)

// 1. Ensure normalize.css is included for consistent base styles.
//    You might already have this from a project setup tool.
import 'normalize.css';

// 2. Import Milligram's main CSS file.
//    This assumes you have installed it via npm/yarn: `npm install milligram`
import 'milligram/dist/milligram.min.css';

// Now, your application's components will automatically pick up Milligram's styles.
// For example, a simple React component demonstrating usage:

import React from 'react';

function App() {
  return (
    <div className="container" style={{maxWidth: '960px', margin: '0 auto', padding: '20px'}}>
      <h1>Welcome to My App</h1>
      <p>This paragraph is styled by Milligram. It's a lightweight and modern CSS framework.</p>

      <button className="button-primary">Click Me</button>
      <button>Learn More</button>

      <form>
        <fieldset>
          <label htmlFor="nameField">Your Name</label>
          <input type="text" placeholder="Jane Doe" id="nameField" />
          <label htmlFor="ageRange">Age Range</label>
          <select id="ageRange">
            <option value="0-18">0-18</option>
            <option value="19-35">19-35</option>
            <option value="36+">36+</option>
          </select>
          <input className="button-primary" type="submit" value="Submit" />
        </fieldset>
      </form>
    </div>
  );
}

export default App;

view raw JSON →