Blades CSS

repository·main·Indexed 43 days ago

https://github.com/anyblades/blades

A minimal CSS framework for semantic HTML and an actively maintained successor to Pico CSS. Version 3.0.0 provides lightweight components, float labels, breakout containers, and a standalone mode for use with other frameworks like Tailwind or Bootstrap.

Tokens
1.7K
Snippets
11
Records
12
Agent score
57%

What's inside Blades

  1. What is Blades CSS?

    main

    Blades is a minimal CSS framework designed for semantic HTML. It is a fully compatible and actively maintained successor to Pico CSS.

    Key features include:

    • Float labels for form inputs.
    • Breakout containers for layout control.
    • Modern helpers that are opt-out by design.
    • Standalone mode: Allows you to use Blades' utility and component styles alongside other frameworks like Tailwind or Bootstrap without inheriting Pico CSS base styles.
  2. Install Blades with NPM

    main

    To use Blades in a modern web development workflow, install the package via npm. After installation, you can import the full framework or just the standalone version into your CSS files.

    npm install @anyblades/blades

    To use the full framework (includes Pico CSS base styles):

    @import "@anyblades/blades";

    To use the standalone version (includes Blades helpers but excludes the Pico CSS base styles, useful when using Tailwind or Bootstrap):

    @import "@anyblades/blades/standalone";
  3. Install Blades via CDN

    main

    You can use Blades directly in your HTML by linking to the minified CSS file hosted on JSDelivr. This is the quickest way to get started without managing local files or npm packages.

    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@anyblades/blades@3/css/blades.min.css"/>
  4. Install Blades CSS v3

    main

    Blades CSS v3 is a semantic HTML styling framework built on top of Pico CSS. It can be integrated into projects via manual installation, CDN, or NPM. The core framework is composed of Pico CSS and the blades.standalone styles.

    /* Note: The actual installation commands (NPM, CDN, etc.) are defined in the project README/documentation. This CSS file serves as the main entrypoint that imports Pico CSS and standalone Blades styles. */
  5. Starter HTML template for Blades

    main

    Use this minimal HTML structure to ensure proper compatibility with Blades, including the recommended meta tags for color schemes and viewport settings.

    <!doctype html>
    <html lang="en">
      <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <meta name="color-scheme" content="light dark" />
        <link rel="stylesheet" href="css/blades.css" />
        <title>Hello world!</title>
      </head>
      <body>
        <main class="container">
          <h1>Hello world!</h1>
        </main>
      </body>
    </html>
  6. Style button teasers with `a[role="button"]`

    main

    You can create "teaser" style links by using an <a> tag with role="button" that contains a heading element (h1 through h6). This automatically applies specific layout styles: text alignment to start, a 1px top and left border, and a negative margin to offset the layout.

    <a href="#" role="button" class="outline">
      <h4>Teaser Title</h4>
      <p>Teaser description text.</p>
    </a>
  7. Use Blades with Pico CSS

    main
    Blades provides a compatibility layer for users of Pico CSS. You can integrate Blades styles into your Pico CSS project by importing the src/pico.css file. This file acts as an entry point that imports the necessary Pico-specific Blades styles via @import "./pico/_index";.
    @import "./pico/_index";
  8. Show or hide `.opt`ional content based on screen size

    main

    The .opt class is used for optional content that should be hidden on smaller screens. When an element has the .opt class (and does not have a class named .does-not-exist), it will be set to display: none on viewports narrower than 1024px.

    <div class="opt">
      This content is hidden on mobile/tablet devices (width < 1024px).
    </div>
  9. Import the float label form pattern styles

    main

    To use the float label form pattern in your project, import the main CSS entrypoint. This file aggregates the core logic and the theme definitions. Ensure that both _float-label.core and _float-label.theme are available in your stylesheet resolution path.

    @import "./_float-label.core";
    @import "./_float-label.theme";
  10. Apply special styling to GitHub favicons

    main

    The ninja add-ons include a selector for GitHub favicons. If an <img> tag has a src attribute containing the query string ?domain=github.com&, it will automatically receive a 50% border-radius (making it circular). Additionally, in dark mode (prefers-color-scheme: dark), the image will have a filter: invert(1) applied.

    <img src="https://github.com/favicon.ico?domain=github.com&" alt="GitHub">
  11. Use `sup` and `sub` for hierarchical headings

    main

    Blades CSS provides experimental ninja add-ons to create structured heading hierarchies using <sup> and <sub> elements with inline styles.

    • <sup> (Superheadings): When used with a style attribute, it renders as a block-level element with reduced font size (min 50% or 0.75rem), increased letter spacing, and uppercase transformation. This is ideal for parent page titles or category labels.
    • <sub> (Subheadings): When used with a style attribute, it renders as a block-level element with a lighter font weight (300) and 75% opacity. If placed directly inside an <h1> element, the font size is automatically scaled to 50%.
    <article>
      <h1>
        <sup style="">Parent Page Title</sup>
        <sub style="">Subtitle Content</sub>
      </h1>
    </article>