Convert Figma logo to code with AI

picturepan2 logospectre

Spectre.css - A Lightweight, Responsive and Modern CSS Framework

11,315
807
11,315
194

Top Related Projects

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

49,128

Modern CSS framework based on Flexbox

A utility-first CSS framework for rapid UI development.

Materialize, a CSS Framework based on Material Design

18,271

A lightweight and modular front-end framework for developing fast and powerful web interfaces

10,193

A minimalist CSS framework.

Quick Overview

Spectre.css is a lightweight, responsive, and modern CSS framework for faster and extensible development. It's designed to be clean, simple, and flexible, making it suitable for both small projects and large-scale applications.

Pros

  • Lightweight and minimal, with a small file size
  • Flexbox-based grid system for easy and responsive layouts
  • Customizable with Sass variables and mixins
  • No JavaScript dependencies, making it fast and simple to use

Cons

  • Limited pre-built components compared to larger frameworks
  • Less extensive documentation compared to more established frameworks
  • Smaller community and ecosystem compared to popular alternatives
  • May require more custom styling for complex designs

Code Examples

  1. Basic grid layout:
<div class="container">
  <div class="columns">
    <div class="column col-6">Column 1</div>
    <div class="column col-6">Column 2</div>
  </div>
</div>
  1. Creating a button:
<button class="btn btn-primary">Primary Button</button>
<button class="btn btn-secondary">Secondary Button</button>
  1. Form input with label:
<div class="form-group">
  <label class="form-label" for="input-example">Name</label>
  <input class="form-input" type="text" id="input-example" placeholder="Name">
</div>
  1. Responsive navigation menu:
<header class="navbar">
  <section class="navbar-section">
    <a href="#" class="navbar-brand mr-2">Brand</a>
    <a href="#" class="btn btn-link">Home</a>
    <a href="#" class="btn btn-link">About</a>
  </section>
</header>

Getting Started

To use Spectre.css in your project, you can either download the CSS file or use a CDN. Here's how to include it using a CDN:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Spectre.css Project</title>
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css">
</head>
<body>
    <!-- Your content here -->
</body>
</html>

After including the CSS files, you can start using Spectre.css classes in your HTML elements to create responsive layouts and styled components.

Competitor Comparisons

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

Pros of Bootstrap

  • Extensive documentation and large community support
  • Comprehensive set of UI components and utilities
  • Robust grid system for responsive layouts

Cons of Bootstrap

  • Larger file size, potentially impacting page load times
  • More opinionated design, requiring more customization to avoid "Bootstrap look"
  • Steeper learning curve due to its extensive feature set

Code Comparison

Bootstrap:

<div class="container">
  <div class="row">
    <div class="col-md-6">Column 1</div>
    <div class="col-md-6">Column 2</div>
  </div>
</div>

Spectre:

<div class="container">
  <div class="columns">
    <div class="column col-6">Column 1</div>
    <div class="column col-6">Column 2</div>
  </div>
</div>

Both frameworks use a similar approach for grid systems, but Spectre's syntax is slightly more concise. Bootstrap offers more granular control with its responsive classes, while Spectre aims for simplicity.

Bootstrap is a more comprehensive framework with a wider range of components and utilities, making it suitable for larger projects. Spectre, on the other hand, is lightweight and focuses on simplicity, making it ideal for smaller projects or when a minimal footprint is crucial.

49,128

Modern CSS framework based on Flexbox

Pros of Bulma

  • More comprehensive component library with a wider range of UI elements
  • Larger community and ecosystem, resulting in more resources and third-party extensions
  • Modular architecture allowing for easy customization and partial imports

Cons of Bulma

  • Larger file size, which may impact page load times for smaller projects
  • Steeper learning curve due to more complex class naming conventions
  • Less focus on minimalism, which may lead to more opinionated designs

Code Comparison

Bulma button example:

<button class="button is-primary is-large">
  Large button
</button>

Spectre button example:

<button class="btn btn-primary btn-lg">
  Large button
</button>

Both frameworks use similar class-based approaches, but Bulma's naming convention is slightly more verbose. Spectre's classes are more concise, which may lead to cleaner HTML markup in some cases.

Bulma and Spectre are both modern CSS frameworks that aim to simplify web development. While Bulma offers a more extensive set of components and a larger ecosystem, Spectre focuses on simplicity and a smaller footprint. The choice between the two depends on project requirements, desired customization level, and personal preference for syntax and design philosophy.

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • Highly customizable with a utility-first approach
  • Extensive documentation and large community support
  • Responsive design out of the box with mobile-first classes

Cons of Tailwind CSS

  • Steeper learning curve due to numerous utility classes
  • Potentially larger file sizes if not properly optimized
  • Can lead to cluttered HTML with many classes in a single element

Code Comparison

Tailwind CSS:

<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
  Button
</button>

Spectre:

<button class="btn btn-primary">
  Button
</button>

Summary

Tailwind CSS offers more flexibility and customization options, making it suitable for complex projects with unique design requirements. It has a larger community and more frequent updates. However, it can be more challenging to learn and may require additional setup for optimal performance.

Spectre, on the other hand, provides a simpler, more traditional approach to CSS frameworks. It has a smaller footprint and is easier to get started with, but may be less flexible for highly customized designs. Spectre is a good choice for smaller projects or when rapid development is prioritized over extensive customization.

Materialize, a CSS Framework based on Material Design

Pros of Materialize

  • More comprehensive component library with advanced features like parallax and pushpin
  • Stronger community support and wider adoption
  • Built-in JavaScript functionality for interactive components

Cons of Materialize

  • Larger file size and potentially slower load times
  • More opinionated design, which may require more customization
  • Steeper learning curve due to its extensive features

Code Comparison

Materialize (JavaScript initialization):

document.addEventListener('DOMContentLoaded', function() {
  var elems = document.querySelectorAll('.sidenav');
  var instances = M.Sidenav.init(elems, options);
});

Spectre (HTML only):

<ul class="nav">
  <li class="nav-item">
    <a href="#">Home</a>
  </li>
  <li class="nav-item">
    <a href="#">About</a>
  </li>
</ul>

Summary

Materialize offers a more feature-rich framework with built-in JavaScript functionality, making it suitable for complex projects. However, this comes at the cost of larger file sizes and a steeper learning curve. Spectre, on the other hand, provides a lightweight and simple CSS-only framework, which is easier to learn and implement but may require additional JavaScript for interactive components.

18,271

A lightweight and modular front-end framework for developing fast and powerful web interfaces

Pros of UIkit

  • More comprehensive component library with a wider range of UI elements
  • Extensive documentation and examples for easier implementation
  • Active development and regular updates

Cons of UIkit

  • Larger file size, potentially impacting page load times
  • Steeper learning curve due to its extensive features
  • More opinionated design, which may require more customization

Code Comparison

UIkit:

<div class="uk-card uk-card-default">
    <div class="uk-card-header">
        <h3 class="uk-card-title">Title</h3>
    </div>
    <div class="uk-card-body">
        <p>Content</p>
    </div>
</div>

Spectre:

<div class="card">
    <div class="card-header">
        <div class="card-title h5">Title</div>
    </div>
    <div class="card-body">
        <p>Content</p>
    </div>
</div>

Both frameworks offer similar card components, but UIkit provides more built-in styling options and a slightly different class structure. Spectre's approach is more minimalistic, which may be preferable for simpler projects or those requiring less customization.

10,193

A minimalist CSS framework.

Pros of Milligram

  • Extremely lightweight (2kb gzipped) compared to Spectre's larger footprint
  • Simpler and more minimalistic design, easier for beginners
  • Faster loading times due to smaller file size

Cons of Milligram

  • Less comprehensive component library than Spectre
  • Fewer customization options and variables
  • Limited browser support compared to Spectre's wider compatibility

Code Comparison

Milligram:

.button,
button,
input[type='button'],
input[type='reset'],
input[type='submit'] {
  background-color: #9b4dca;
  border: 0.1rem solid #9b4dca;
  border-radius: .4rem;
  color: #fff;
  cursor: pointer;
}

Spectre:

.btn {
  -webkit-appearance: none;
  border: .1rem solid #5755d9;
  border-radius: .1rem;
  color: #5755d9;
  cursor: pointer;
  display: inline-block;
  font-size: .8rem;
  height: 1.8rem;
  line-height: 1.2rem;
  outline: none;
  padding: .25rem .4rem;
  text-align: center;
  text-decoration: none;
  transition: background .2s, border .2s, box-shadow .2s, color .2s;
  vertical-align: middle;
  white-space: nowrap;
}

Both frameworks provide clean and readable CSS, but Spectre offers more detailed styling and customization options out of the box.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Spectre.css

Reviewed by Hound

Spectre.css is a lightweight, responsive and modern CSS framework.

  • Lightweight (~10KB gzipped) starting point for your projects
  • Flexbox-based, responsive and mobile-friendly layout
  • Elegantly designed and developed elements and components

Spectre is a side project based on years of CSS development work on a large web service project. Spectre only includes modern base styles, responsive layout system, CSS components and utilities, and it can be modified for your project with Sass/Scss compiler.

Spectre.css is completely free to use. If you enjoy it, please consider donating via Paypal or via Patreon for the further development. ♥

Getting started

There are 5 ways to get started with Spectre CSS framework in your projects. You can either manually install or use NPM, Yarn and Bower.

Install manually

Download the compiled and minified Spectre CSS files. And include spectre.css located in /docs/dist in your website or Web app <head> part.

<link rel="stylesheet" href="spectre.min.css">

Install from CDN

Alternatively, you can use the unpkg or cdnjs CDN to load compiled Spectre.css.

<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">

Install with NPM

$ npm install spectre.css --save

Install with Yarn

$ yarn add spectre.css

Install with Bower

$ bower install spectre.css --save

Compiling custom version

You can compile your custom version of Spectre.css. Read the documentation.

Documentation and examples

Elements

Layout

Components

Utilities

  • Utilities - colors, display, divider, loading, position, shapes and text utilities

Experimentals

Browser support

Spectre uses Autoprefixer to make most styles compatible with earlier browsers and Normalize.css for CSS resets. Spectre is designed for modern browsers. For best compatibility, these browsers are recommended:

  • Chrome (LAST 4)
  • Microsoft Edge (LAST 4)
  • Firefox (EXTENDED SUPPORT RELEASE)
  • Safari (LAST 4)
  • Opera (LAST 4)
  • Internet Explorer 10+

Spectre supports Internet Explorer 10+, but some HTML5 and CSS3 features are not perfectly supported by Internet Explorer.

Designed and built with ♥ by Yan Zhu. Feel free to submit a pull request. Help is always appreciated.

NPM DownloadsLast 30 Days