Installation

Two ways to add KataCSS to your project. One script tag or one import.

Category
Getting Started
Difficulty
Beginner
Time
2 min
Author
Saumya Agrawal

CDN

Drop this in your code. That's the entire setup.

$ <script src="https://cdn.jsdelivr.net/npm/kata-css@latest/dist/kata.js"></script>

npm

01
Install
Add the package to your project.
02
Import
One import in your JS entry file.
03
Done
Styles apply automatically on DOMContentLoaded.
bash
npm install kata-css
js
import "kata-css";  // self-executes on DOMContentLoaded

Usage

Write kata-* classes on any element. They become inline styles on load.

html
<h1 class="kata-text-3xl kata-font-bold kata-text-blue-500">
  Hello, KataCSS
</h1>

<div class="kata-flex kata-gap-4 kata-p-6 kata-bg-kata-chai-matcha kata-rounded-lg">
  <p class="kata-text-white kata-font-medium">Works on load</p>
</div>
Unknown classes log a warning in the console: [kata-css] Unknown class: "kata-[class]"

How it works

KataCSS is a runtime engine. No compiler, no build step, no CSSOM manipulation.

Runtime

Execution flow

KataCSS listens for DOMContentLoaded. Once the DOM is ready, it scans every element with a class attribute, finds anything starting with kata-, looks it up in a key-value map, writes the CSS as an inline style attribute, and removes the original class.

flow
Browser parses HTML
  → script registers DOMContentLoaded listener
  → DOM finishes loading
  → KataCSS scans all [class] elements
  → finds kata-* classes 
  → looks up classMap
  → writes inline style attribute
  → removes kata-* class from classList

Extending

js — classMap.js
// src/classMap.js — add any key you want
classMap["kata-bg-brand"]   = "background-color: #FF6B35;";
classMap["kata-text-brand"] = "color: #FF6B35;";
    

Spacing

All spacing utilities use i × 0.25rem. Scale runs 0-96.

Formula
i × 0.25rem
Scale
0 – 96
kata-p-4
= 1rem / 16px
kata-p-8
= 2rem / 32px

Padding

ClassCSSExample
kata-p-{n}padding: n×0.25remkata-p-4 → 1rem
kata-px-{n}padding-left + rightkata-px-6 → 1.5rem
kata-py-{n}padding-top + bottomkata-py-2 → 0.5rem
kata-pt/pb/pl/pr-{n}individual sideskata-pt-3 → 0.75rem

Margin

ClassCSS
kata-m-{n}margin: n×0.25rem
kata-mx-{n} / kata-mx-automargin-left + right
kata-my-{n}margin-top + bottom
kata-mt/mb/ml/mr-{n}individual sides
kata-m-automargin: auto

Gap

ClassCSS
kata-gap-{n}gap: n×0.25rem
kata-gap-x-{n}column-gap: n×0.25rem
kata-gap-y-{n}row-gap: n×0.25rem

Layout & Display

Display, box-sizing, and overflow utilities.

ClassCSS
kata-blockdisplay: block
kata-inline / kata-inline-blockdisplay: inline / inline-block
kata-flex / kata-inline-flexdisplay: flex / inline-flex
kata-grid / kata-inline-griddisplay: grid / inline-grid
kata-hiddendisplay: none
kata-contentsdisplay: contents
kata-box-border / kata-box-contentbox-sizing

Flexbox

Direction, wrapping, justification, and alignment.

Direction & wrap

ClassCSS
kata-flex-row / colflex-direction: row / column
kata-flex-row-reverse / col-reverseflex-direction reversed
kata-flex-wrap / nowrap / wrap-reverseflex-wrap

Justify & align

ClassCSS
kata-justify-start / center / endjustify-content
kata-justify-between / around / evenlyjustify-content
kata-items-start / center / endalign-items
kata-items-baseline / stretchalign-items

Position & Z-index

Position type, inset values (0–96 scale), and z-index (0–96).

ClassCSS
kata-static / relative / absolute / fixed / stickyposition
kata-inset-0 / kata-inset-autotop/right/bottom/left: 0 / auto
kata-top/right/bottom/left-{0–96}inset side: n×0.25rem
kata-top/right/bottom/left-autoinset side: auto
kata-z-{0–96}z-index: n
kata-z-autoz-index: auto

Width & Height

Numeric scale 0–96 (×0.25rem) plus named values.

Width

ClassCSS
kata-w-{0–96}width: n×0.25rem
kata-w-auto / full / half / screenauto / 100% / 50% / 100vw
kata-w-min / max / fitmin/max/fit-content

Height

ClassCSS
kata-h-{0–96}height: n×0.25rem
kata-h-auto / full / half / screenauto / 100% / 50% / 100vh
kata-h-min / max / fitmin/max/fit-content

Typography

Font family, size (with line-height), weight, style, alignment, leading, and tracking.

Font family

ClassCSS
kata-font-sansui-sans-serif, system-ui, -apple-system, sans-serif
kata-font-serifui-serif, Georgia, Cambria, serif
kata-font-monoui-monospace, Cascadia Code, Courier New, monospace

Font size

ClassSizeLine height
kata-text-xs0.75rem1rem
kata-text-sm0.875rem1.25rem
kata-text-base1rem1.5rem
kata-text-lg1.125rem1.75rem
kata-text-xl1.25rem1.75rem
kata-text-2xl1.5rem2rem
kata-text-3xl1.875rem2.25rem
kata-text-4xl2.25rem2.5rem
kata-text-5xl / 6xl3rem / 3.75rem1

Weight, style & other

ClassCSS
kata-font-thin / extralight / light / normal / medium / semibold / bold / extrabold / blackfont-weight: 100 → 900
kata-italic / kata-not-italicfont-style
kata-text-left / center / right / justify / start / endtext-align
kata-leading-none / tight / snug / normal / relaxed / looseline-height: 1 → 2
kata-tracking-tighter / tight / normal / wide / wider / widestletter-spacing

Text Decoration

Underline, overline, line-through, and decoration style.

ClassCSS
kata-underline / overline / line-through / no-underlinetext-decoration-line
kata-decoration-solid / dashed / dotted / double / wavytext-decoration-style

Borders

Border width, style, color, and radius.

Width & style

ClassCSS
kata-border-0 / border / border-2 / border-4 / border-8border-width: 0 → 8px
kata-border-t / r / b / lindividual side: 1px
kata-border-solid / dashed / dotted / double / noneborder-style

Radius

ClassCSS
kata-rounded-none / sm / md / lg / xl / 2xl / 3xl0 → 1.5rem
kata-rounded-fullborder-radius: 9999px
kata-rounded-{n}border-radius: n×0.25rem

Colors

Every key works as kata-text-*, kata-bg-*, kata-border-*. Click any card to copy.

Pattern:  kata-bg-blue-500  ·  kata-text-gray-700  ·  kata-border-red-300

Standard palette

Background helpers

ClassCSS
kata-bg-nonebackground: none
kata-bg-cover / containbackground-size
kata-bg-center / top / bottombackground-position
kata-bg-no-repeat / repeatbackground-repeat

Cursor & Visibility

Cursor style and element visibility.

Cursor

ClassCSS
kata-cursor-auto / default / pointer / wait / text / move / not-allowed / grabcursor

Visibility

ClassCSS
kata-visible / kata-invisiblevisibility: visible / hidden

Chai Theming

Colors matched to real chai and tea varieties from across the world. A ChaiCode cohort original.

ChaiCode Exclusive

Chai Scheme

Built for the ChaiCode community — KataCSS originals.

Prefix:  kata-bg-kata-chai-masala  ·  kata-text-kata-chai-earl-grey
html
<div class="kata-bg-kata-chai-masala kata-p-6 kata-rounded-lg">
  <h2 class="kata-text-kata-chai-foam kata-text-xl kata-font-bold">Masala</h2>
</div>
<span class="kata-bg-kata-chai-matcha kata-text-white kata-px-4 kata-py-1 kata-rounded-full">
  Matcha
</span>