Getting Started

The utility-first CSS
framework for the browser.

Jetflow is a browser-native, atomic CSS framework. Drop in a single <script> tag, write utility classes in your HTML, and your styles are generated in real time — no build step, no configuration required to get started.

DISCLAIMER: Jetflow is an independent open-source project and is not affiliated with any otherJetflow-branded products.

What's new in v1.0.1?

Jetflow v1.0.1 brings massive performance upgrades via class caching and batched CSS insertions, infinitely chained variants, mandatory security validations for arbitrary values, and new unique features like Runtime Theme Switching and Scoped Mode.

01 / PERFORMANCE
Optimized DOM Engine
Tracks nodes via WeakSet, deduplicates CSS, caches parsed classes, and uses single batched style injections.
02 / SECURE
Strict Validation
Mandatory security checks block malicious inputs (e.g., urls, javascript) in arbitrary values entirely.
03 / DYNAMIC
Runtime Theming
Switch themes instantly with JavaScript without requiring a page reload.
04 / CHAINING
Infinite Variants
Robust class parser handles nested breakpoints, hover, focus states with precise CSS hierarchy.
Getting Started

Installation

Jetflow is designed to be added with a single HTML script tag. No package manager needed.

CDN (Recommended)

Add this tag to the <head> of your HTML before any content that uses utility classes:

index.html
<script src="https://cdn.jsdelivr.net/gh/JetflowJS/Jetflow@v1.0.1/jetflow.js"></script>

With a custom config

To use a configuration file, load it before the Jetflow script using a module script. Jetflow will automatically pick up the exported default config:

index.html
<!-- 1. Load your config first -->
<script type="module" src="jetflow.config.js"></script>

<!-- 2. Then load Jetflow -->
<script src="https://cdn.jsdelivr.net/gh/JetflowJS/Jetflow@v1.0.1/jetflow.js"></script>
Tip

Place the <script> in your <head>, not at the bottom of <body>. This ensures styles are applied before content is painted, preventing a flash of unstyled content.

Self-hosted

Download jetflow.min.js from the GitHub repository and host it alongside your project. Useful for offline use or environments with restricted network access.

index.html
<script src="/assets/jetflow.min.js"></script>
Getting Started

Quick Start

Here's everything you need to build a complete page with Jetflow in under a minute:

1
Add the script tag
Include Jetflow in your HTML <head> via CDN.
2
Write utility classes
Use atomic classes directly on your HTML elements — no class definitions needed.
3
Open in browser
Jetflow runs entirely in the browser. Just open your HTML file — no build step required.
index.html
<!DOCTYPE html>
<html>
<head>
  <script src="https://cdn.jsdelivr.net/gh/JetflowJS/Jetflow@v1.0.1/jetflow.js"></script>
</head>
<body>

  <!-- Flexbox card with dark mode support -->
  <div class="flex-center min-h-screen bg-gray-50 dark:bg-gray-900">
    <div class="flex flex-col gap-4 p-8 rounded-xl border
             border-gray-200 bg-white shadow-lg
             dark:border-slate-700 dark:bg-slate-900
             max-w-sm w-full">
      <h1 class="text-2xl font-bold text-gray-900 dark:text-white">
        Hello, Jetflow!
      </h1>
      <p class="text-sm text-gray-500 leading-relaxed">
        Utility-first CSS with zero build step.
      </p>
      <button class="flex-center gap-2 rounded-md bg-orange-500
               px-4 py-2 text-sm font-semibold text-white
               transition hover:bg-orange-600">
        Get Started
      </button>
    </div>
  </div>

</body>
</html>
Getting Started

Configuration

Jetflow works without any configuration. But when you need custom colors, component shortcuts, or extended spacing — create a jetflow.config.js file and export a default config object.

jetflow.config.js
export default {
  darkMode: "media",     // "class" | "media" | "both"
  reset: true,           // inject CSS reset

  theme: {
    colors: {
      brand: {
        light: "#d9efff",
        mid:   "#1479c9",
        dark:  "#0d4f83",
      }
    },
    spacing: {
      18: "4.5rem",
      128: "32rem"
    },
    fontSize: {
      "huge": "5rem"
    },
    screens: {
      sm: "640px",
      md: "768px",
      lg: "1024px"
    }
  },

  apply: {
    ".btn-primary": "flex-center gap-2 rounded-md bg-brand-mid px-4 py-2 text-sm text-white shadow-sm transition hover:bg-brand-dark",
    ".card":        "box rounded-lg p-6 shadow-md dark:border-slate-700 dark:bg-slate-900",
  },

  safelist:["hidden", "md:flex", "hover:bg-brand-dark"]
};
Core Concepts

Utility Classes

Jetflow provides 500+ atomic utility classes. Each class maps to a single CSS declaration. You compose them directly in your HTML — no custom CSS needed for most layouts. Internally, utilities are mapped directly as functions linking them natively to configuration tokens.

example.html
<!-- Each class = one CSS property -->
<div class="flex items-center justify-between gap-4 p-6 rounded-lg border border-gray-200">

  <span class="text-sm font-semibold text-gray-900">Label</span>

  <button class="px-4 py-2 rounded-md bg-blue-500 text-white text-sm
           transition hover:bg-blue-600 focus:outline-none focus:ring-2">
    Action
  </button>

</div>

Chained Variants (v1.0.1)

Jetflow v1.0.1 introduces robust chained variants with strict ordering (media → selector → pseudo). You can stack variants infinitely:

example.html
<!-- Applies blue background only on medium screens, on hover, when focused -->
<div class="md:hover:focus:bg-blue-500"></div>

Variant prefixes

Jetflow classes support a range of modifier prefixes to apply styles conditionally:

Prefix Applies when Example
hover: Mouse hover hover:bg-gray-100
focus: Keyboard / click focus focus:ring-2
active: Element is pressed active:scale-95
dark: Dark mode active dark:bg-slate-900
sm: md: lg: xl: 2xl: Viewport ≥ breakpoint md:flex-row
group-hover: Parent .group is hovered group-hover:opacity-100
Core Concepts

Dark Mode

Jetflow supports three dark mode strategies, configured via darkMode in your config. All three modes use the dark: prefix on any utility class.

"class"Class-based
Dark mode activates when a .dark class is present on a parent element (typically <html> or <body>). Toggle it with JavaScript.
"media"System preference
Uses the prefers-color-scheme: dark media query. Follows the user's OS preference automatically. (Set as default in v1.0.1 documentation)
"both"Class + media
Supports both strategies simultaneously. Class toggle takes precedence over system preference.
Core Concepts

Responsive Design

Jetflow uses a mobile-first breakpoint system. Unprefixed utilities apply at all sizes; prefixed utilities apply from that breakpoint upward.

Prefix Min-width Target
— (none) 0px All screens (mobile-first default)
sm: 640px Small tablets and up
md: 768px Tablets and up
lg: 1024px Laptops and up
xl: 1280px Desktops and up
Core Concepts

Arbitrary Values

Need a one-off value that isn't in the default scale? Use bracket notation to pass any CSS value directly — no config changes needed.

example.html
<!-- Any safe CSS unit works -->
<div class="p-[13px] w-[calc(100%-2rem)] bg-[#1a1a1a]"></div>

<!-- With variants -->
<div class="md:text-[22px] hover:bg-[rgba(255,95,21,0.12)]"></div>

<!-- Shorthand padding (top/bottom left/right) -->
<div class="p-[8px_16px]"></div>
Core Concepts

Security new

Security is a mandatory priority in Jetflow v1.0.1. All arbitrary values are subjected to strict regex validation before being injected into the DOM.

Allowed Values
Hex colors (#fff), rgb/rgba, numbers, and standard CSS units (px, rem, %, etc.).
Blocked Values
url(), javascript:, expression(), and @import are strictly forbidden.
Safe Execution

If an invalid or unsafe value is detected, Jetflow will silently ignore the class. We NEVER inject raw values without validation to prevent CSS injection attacks.

Core Concepts

Scoped Mode new

Jetflow v1.0.1 introduces Scoped Mode, allowing you to restrict utility classes so they only apply inside a designated container. This ensures that utility frameworks don't pollute styling in complex macro environments.

example.html
<!-- Styles prefixed globally will only apply inside this scoped wrapper -->
<div class="jf-scope-widget bg-white p-4">
  <p class="text-blue-500 font-bold">Scoped content</p>
</div>
Utilities Reference

Layout

Display

blockinline-blockinline flexinline-flexgrid inline-gridhiddencontents

Flexbox

flex-rowflex-colflex-wrapflex-nowrap items-startitems-centeritems-enditems-stretch justify-startjustify-centerjustify-betweenjustify-endjustify-around flex-1flex-noneflex-autoflex-shrink-0 flex-centerflex-between

Grid

grid-cols-1grid-cols-2grid-cols-3grid-cols-4grid-cols-6grid-cols-12 col-span-1col-span-2col-span-full grid-rows-1grid-rows-2grid-rows-3 place-items-centerplace-items-startplace-content-center grid-center

Gap

gap-0gap-1gap-2gap-3gap-4gap-5gap-6gap-8gap-10gap-12 gap-x-4gap-x-6gap-y-4gap-y-6

Sizing

w-fullw-screenw-auto w-1/2w-1/3w-2/3w-1/4w-3/4 w-32w-48w-64w-96 h-autoh-fullh-screen h-8h-12h-16h-32h-64 max-w-smmax-w-mdmax-w-lgmax-w-xlmax-w-2xlmax-w-none min-h-screenmin-w-0

Position

staticrelativeabsolutefixedsticky inset-0top-0bottom-0left-0right-0 z-0z-10z-20z-50z-auto
Utilities Reference

Spacing

Jetflow uses a 4px base spacing scale. Each step corresponds to n × 4px (e.g., p-4 = 16px, m-8 = 32px).

Padding

p-0p-1p-2p-3p-4p-5p-6p-8p-10p-12p-16 px-2px-4px-6px-8 py-2py-4py-6py-8 pt-4pr-4pb-4pl-4

Margin

m-0m-automx-automy-auto m-2m-4m-6m-8 mt-4mr-4mb-4ml-4 -mt-4-mb-4
Utilities Reference

Typography

Font size

Class Size Line-height
text-xs 0.75rem 1rem
text-sm 0.875rem 1.25rem
text-base 1rem 1.5rem
text-lg 1.125rem 1.75rem
text-xl 1.25rem 1.75rem
text-2xl 1.5rem 2rem
text-3xl 1.875rem 2.25rem
text-4xl 2.25rem 2.5rem
text-5xl 3rem 1
text-6xl 3.75rem 1

Font weight

font-thinfont-lightfont-normal font-mediumfont-semiboldfont-boldfont-extrabold text-bold

Alignment, decoration & more

text-lefttext-centertext-righttext-justify uppercaselowercasecapitalizenormal-case italicnot-italic underlineline-throughno-underline tracking-tighttracking-widetracking-wider leading-tightleading-normalleading-relaxedleading-loose truncatewhitespace-nowrapbreak-all
Utilities Reference

Colors

Jetflow ships with a full default palette (slate, gray, zinc, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose). Each shade runs from 50 to 950.

Text color

text-whitetext-black text-gray-500text-gray-700text-gray-900 text-blue-500text-red-500text-green-500 text-muted

Background color

bg-whitebg-blackbg-transparent bg-gray-50bg-gray-100bg-gray-900 bg-slate-800bg-slate-900 bg-blue-500bg-red-500bg-green-500

Custom colors via config

jetflow.config.js
export default {
  theme: {
    extend: {
      colors: {
        // Adds: bg-brand-mid, text-brand-dark, etc.
        brand: {
          light: "#d9efff",
          mid:   "#1479c9",
          dark:  "#0d4f83",
          50:    "#eef8ff",
          500:   "#1479c9",
          700:   "#0d4f83",
        }
      }
    }
  }
};

After defining these tokens, use them anywhere: bg-brand-mid, text-brand-dark, border-brand-500, ring-brand-mid, and so on.

Utilities Reference

Borders & Radius

Border width

borderborder-0border-2border-4border-8 border-tborder-rborder-bborder-l border-xborder-y

Border color

border-gray-200border-gray-400border-whiteborder-black border-slate-700border-blue-500

Border radius

rounded-nonerounded-smroundedrounded-md rounded-lgrounded-xlrounded-2xlrounded-3xlrounded-full rounded-t-lgrounded-b-lg
Utilities Reference

Shadows & Rings

Box shadow

shadow-noneshadow-smshadow shadow-mdshadow-lgshadow-xlshadow-2xlshadow-inner

Ring (focus outline)

Rings are composable box-shadow utilities designed for focus states. They stack cleanly with other shadow utilities.

ring-0ring-1ring-2ring-4 ring-blue-500ring-brand-mid ring-offset-0ring-offset-2ring-offset-4
example.html
<button class="rounded-md shadow-md
         focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2
         hover:shadow-lg transition">
  Focusable button
</button>
Utilities Reference

Transforms

Jetflow's transform utilities are powered by CSS custom properties and compose cleanly — multiple transform functions don't overwrite each other.

scale-90scale-95scale-100scale-105scale-110scale-125scale-150 rotate-0rotate-1rotate-3rotate-6rotate-12rotate-45rotate-90rotate-180-rotate-12 translate-x-0translate-x-2translate-x-4-translate-x-full translate-y-0translate-y-2-translate-y-1 skew-x-3skew-y-3

Transform origin

origin-centerorigin-toporigin-bottomorigin-leftorigin-rightorigin-top-left
Utilities Reference

Effects & Filters

Opacity & visibility

opacity-0opacity-25opacity-50opacity-75opacity-90opacity-100 invisiblevisible pointer-events-nonepointer-events-auto

Transitions

transitiontransition-alltransition-colorstransition-opacitytransition-transform duration-75duration-100duration-150duration-200duration-300duration-500 ease-inease-outease-in-outease-linear

Filters

blur-smblurblur-mdblur-lgblur-xl brightness-50brightness-75brightness-100brightness-125 grayscalegrayscale-0 invertinvert-0 backdrop-blurbackdrop-blur-md
Advanced

Apply & Components

The apply config key lets you create named CSS selectors that expand to a string of Jetflow utilities. Think of it as a shortcut for commonly repeated patterns — without writing any CSS.

jetflow.config.js
export default {
  apply: {
    // Primary button
    ".btn-primary": "flex-center gap-2 rounded-md bg-brand-mid
                      px-4 py-2 text-sm text-bold text-white shadow-sm
                      transition hover:bg-brand-dark
                      focus:outline-none focus:ring-2 focus:ring-brand-mid focus:ring-offset-2",

    // Secondary button
    ".btn-secondary": "flex-center gap-2 rounded-md border border-gray-300
                        bg-white px-4 py-2 text-sm text-bold text-slate-800
                        transition hover:bg-gray-50
                        dark:border-slate-600 dark:bg-slate-900 dark:text-white",

    // Card
    ".card": "box rounded-lg p-6 shadow-md
              dark:border-slate-700 dark:bg-slate-900",

    // Notice/alert
    ".notice": "rounded-md border border-amber-200 bg-amber-50
                 p-[8px_16px] text-sm text-amber-900"
  }
};

Now use these class names directly in your HTML:

index.html
<button class="btn-primary">Save Changes</button>
<button class="btn-secondary">Cancel</button>

<div class="card">
  <h2 class="text-lg font-semibold">Title</h2>
  <p class="text-sm text-gray-500">Card content here.</p>
</div>

<div class="notice">⚠ Session expires in 5 minutes.</div>
Note

The apply strings are still Jetflow utility classes under the hood — they support responsive prefixes, dark mode, and arbitrary values just like any other class.

Advanced

Custom Utilities

The utilities config key registers new atomic utility names that expand to other Jetflow classes. Unlike apply, these become first-class utilities — they support variants like hover:, dark:, and breakpoints.

jetflow.config.js
export default {
  utilities: {
    // Aliases that expand to class strings
    "flex-center":  "flex items-center justify-center",
    "flex-between": "flex items-center justify-between",
    "flex-around":  "flex items-center justify-around",
    "text-bold":    "font-bold",
    "box":          "block rounded-md border border-gray-200 bg-white p-4",

    // Raw CSS object (for properties with no Jetflow equivalent)
    "text-balance": {
      "text-wrap": "balance"
    }
  }
};

The built-in custom utilities — flex-center, flex-between, text-bold, box — are pre-registered by Jetflow and can be used without any config.

flex-centerflex-between flex-aroundflex-evenly grid-centertext-bold text-mutedbox box-dark
Advanced

Theming & Tokens

Jetflow's theme system works on a merge principle. Use theme.extend to add tokens on top of the defaults, or theme directly to replace entire categories.

jetflow.config.js
export default {
  theme: {
    extend: {
      // Add custom color tokens
      colors: {
        brand: { mid: "#1479c9", dark: "#0d4f83" }
      },

      // Extend the spacing scale
      spacing: {
        18: "4.5rem",   // adds p-18, m-18, gap-18…
        128: "32rem"    // adds w-128, h-128…
      },

      // Add border radius tokens
      borderRadius: {
        "4xl": "2rem"     // adds rounded-4xl
      }
    }
  }
};
Tip

Use theme.extend to preserve Jetflow's default tokens (all 300+ colors, full spacing scale, etc.) while adding your own. Using theme directly will replace the entire category.

Advanced

Plugins API

Plugins let you extend Jetflow programmatically. Pass an array of plugin functions in your config — each receives the Jetflow API and can register new utilities, components, or inject raw CSS.

jetflow.config.js
function myPlugin({ addUtility, addComponent, addBase }) {
  // Register a new utility
  addUtility("visually-hidden", {
    position: "absolute",
    width:    "1px",
    height:   "1px",
    overflow: "hidden",
    clip:     "rect(0,0,0,0)",
    whiteSpace: "nowrap"
  });

  // Register a component class
  addComponent(".badge", "inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium");

  // Inject base CSS
  addBase({ "::selection": { background: "#FF5F15", color: "#fff" } });
}

export default {
  plugins: [myPlugin]
};
Advanced

DOM Engine & Performance

Jetflow v1.0.1 features a completely rewritten rendering engine built for extreme performance. It automatically watches for new nodes added to the DOM after initial load via a strictly optimized MutationObserver.

  • Single Initialization: Scans the DOM once at startup and tracks processed elements using a WeakSet.
  • Optimized Observer: The MutationObserver processes only new or modified nodes, completely avoiding repeated DOM scanning.
  • Caching & Deduplication: Parsed classes are mapped and cached. All generated CSS rules are automatically deduplicated.
  • Batched Output: Multiple dynamically generated styles are batched into a single <style> tag insertion to minimize browser repaints.
mutationDebouncems (default: 16)
Debounce delay between DOM changes and style re-generation. Lower values are more responsive; higher values are better for burst insertions (e.g., rendering long lists).
autoStartboolean (default: true)
Whether Jetflow starts observing on script load. Set to false to control initialization manually via JetFlow.start().
safeliststring[]
Classes that are always generated, even if not found in the DOM. Useful for classes added dynamically via JavaScript that the observer might miss.
example.js
// Dynamically added elements are styled automatically
const card = document.createElement("div");
card.className = "flex flex-col gap-4 p-6 rounded-lg border shadow-md";
document.body.appendChild(card);
// ↑ Jetflow detects this and processes it without re-scanning old nodes
Reference

Runtime API

Jetflow exposes a global JetFlow object you can use to control the runtime programmatically.

Method Description
JetFlow.start() Begin DOM observation and style generation. Called automatically unless autoStart: false.
JetFlow.stop() Stop the MutationObserver. Existing styles are preserved.
JetFlow.refresh() Re-scan the full DOM and regenerate all styles. Useful after bulk DOM manipulations.
JetFlow.configure(config) Merge additional configuration at runtime. Triggers a full refresh.
JetFlow.setTheme(theme) Dynamically update theme tokens and CSS variables at runtime without reloading the page.
JetFlow.inspect(element) Development tool to log parsed classes and generated CSS for a specific element to the console.
JetFlow.addClass(cls) Force-generate CSS for a class string, even if not in the DOM.
JetFlow.version Returns the current Jetflow version string.
app.js
// Stop and restart observation
JetFlow.stop();
// ... heavy DOM manipulation ...
JetFlow.refresh();

// Inspect parsed elements in development
JetFlow.inspect(document.querySelector(".my-btn"));

// Add classes that exist only in JS strings
JetFlow.addClass("bg-red-500 text-white px-4 py-2 rounded");

// Dynamically update the application theme without reload
JetFlow.setTheme({
  colors: { brand: "#10b981" }
});

console.log(JetFlow.version); // "1.0.0"
Reference

Config Reference

All available options for jetflow.config.js:

darkModestring
Dark mode strategy. One of "class", "media", or "both". Default: "media".
resetboolean
Inject a minimal CSS reset (box-sizing, margin, padding). Default: true.
autoStartboolean
Start the MutationObserver automatically. Default: true.
debugboolean
Log internal operations to the console. Default: false.
importantboolean
Add !important to all generated declarations. Default: false.
mutationDebouncenumber
Milliseconds to debounce DOM change events. Default: 16.
theme.screensobject
Breakpoint definitions. Maps prefix names to min-width values. Default includes sm/md/lg/xl/2xl.
containersobject
Container max-width tokens. Maps size names to rem values.
theme.extendobject
Extend the default theme. Accepts colors, spacing, borderRadius, fontFamily, and more.
applyobject
CSS selector → utility string map. Generates component-style classes.
utilitiesobject
Register custom atomic utility names. Values can be class strings or raw CSS property objects.
safeliststring[]
Classes to always generate, regardless of DOM presence.
pluginsfunction[]
Array of plugin functions. Each receives { addUtility, addComponent, addBase }.
Reference

Changelog

v1.0.1Minor Release
  • Medium-risk vulnerability fix.
Stay updated

Watch the GitHub repository ↗ for release notes and new version announcements.

On this page
Introduction Installation CDN Self-hosted Quick Start Configuration Utility Classes Dark Mode Responsive Arbitrary Values Security Scoped Mode Layout Spacing Typography Colors Borders & Radius Shadows & Rings Transforms Effects & Filters Apply & Components Custom Utilities Theming Plugins DOM Engine Runtime API Config Reference Changelog