CompactCSS

Documentation

CompactCSS

A lightweight, utility-first CSS library modeled after Tailwind CSS — hundreds of small, single-purpose classes for color, spacing, typography, layout, effects and more. There is no build step, no config file and no CLI: every utility is plain, hand-authored CSS that you link directly in your page.

Installation

The fastest way to get started is to link the pre-built, minified stylesheet straight from the CDN — no download and no build step:

<link rel="stylesheet" href="https://compactcss.online/dist/compact.min.css">

Prefer to self-host or only ship the utilities you actually use? The library is also split into small stylesheets, one per feature — link just the ones you need in <head>:

<link rel="stylesheet" href="css/bg.css">
<link rel="stylesheet" href="css/spacing/p.css">
<link rel="stylesheet" href="css/text/size.css">
<link rel="stylesheet" href="css/rounded.css">
<link rel="stylesheet" href="css/shadow.css">

Usage

Every utility maps to one CSS declaration (or a small related group) and is named after the property it controls. Compose them directly on any element, just like Tailwind:

<div class="bg-indigo-600 text-white p-6 rounded-xl shadow-lg">
  Hello CompactCSS
</div>
Hello CompactCSS
Some corners of the library are still in progress — inset positioning (top-*/right-*/bottom-*/left-*), hover: state variants, the bubble and glass UI helpers — the stylesheets exist as placeholders but ship no rules yet. Sections below call these out where relevant.

Design

Colors

Every color-related utility — bg-, text-, border-, outline-, decoration-, shadow- and scrollbar-thumb- — draws from the same palette: Tailwind CSS's default 26 color families, each with 11 shades from 50 (lightest) to 950 (darkest), plus five base keywords. The naming pattern is always .{utility}-{family}-{shade}.

Base keywords

Opacity modifiers

Append /opacity to any color class to blend it with transparency via color-mix(). Available steps are 10, 25, 50, 75 and 90 — the slash must be escaped in the stylesheet (.bg-blue-500\/50) but written plainly in your HTML's class attribute.

<div class="bg-blue-500/10"></div>
<div class="bg-blue-500/50"></div>
<div class="bg-blue-500"></div>
/10
/25
/50
/75
/90
100%

Background colors

Class pattern: .bg-{family}-{shade}background-color.

Text colors

Same palette and shade scale, applied to color: .text-{family}-{shade}.

Also available on

UtilityProperty setFile
.border-{family}-{shade}border-colorcss/border.css
.outline-{family}-{shade}outline-colorcss/outline.css
.decoration-{family}-{shade}text-decoration-colorcss/text/decoration.css
.shadow-{family}-{shade}tinted box-shadowcss/shadow.css
.scrollbar-thumb-{family}-{shade}scrollbar-color (thumb)css/scrollbar.css

Layout

Spacing

Margin, padding and gap all share one scale: step n equals n × 0.25rem, running every integer from 0 to 100, plus -px (1px) and -auto (margin only) keyword variants.

SideMarginPadding
All sides.m-4.p-4
Top.mt-4.pt-4
Right.mr-4.pr-4
Bottom.mb-4.pb-4
Left.ml-4.pl-4
Vertical (top + bottom).my-4.py-4
Horizontal (left + right).mx-4.px-4

Live example

.m-6 around, .p-6 inside

Margin / padding scale (excerpt)

ClassValueClassValue
.m-0 / .p-00px.m-8 / .p-82rem
.m-1 / .p-10.25rem.m-12 / .p-123rem
.m-2 / .p-20.5rem.m-16 / .p-164rem
.m-4 / .p-41rem.m-32 / .p-328rem
.m-px / .p-px1px.m-100 / .p-10025rem
.m-auto / .mx-auto / .my-autoautoevery integer step in between

Live example — horizontal centering

<div class="mx-auto px-6" style="width:200px;">centered</div>
.mx-auto + .px-6

Gap

.gap-{n} sets the gap property (both row and column at once) on a flex or grid container, using the same n × 0.25rem scale as margin/padding. For independent axes use .gap-x-{n} (column-gap) and .gap-y-{n} (row-gap).

<div class="flex gap-4">
  <div>A</div>
  <div>B</div>
</div>

<div class="grid grid-cols-3 gap-x-8 gap-y-2">...</div>

.gap-2 · .gap-8 · .grid-cols-3.gap-x-8.gap-y-2 (wide columns, tight rows)


Layout

Sizing

w-, h-, min-w-, min-h-, max-w- and max-h- share Tailwind's classic sizing scale: quarter-rem steps from 0 to 3.5, then wider jumps (14, 16, 20, 24, 28, 32…96), plus keyword values.

Keyword classValue
.w-px1px
.w-full100%
.w-screen100vw
.w-min / .w-max / .w-fitmin/max/fit-content
.w-autoauto
.max-w-xs.max-w-xl20rem … 36rem, named content widths
.min-h-dvh / .min-h-svh / .min-h-lvhdynamic / small / large viewport height

Live example

 

.w-8 · .w-16 · .w-32 · .w-64 · .w-full

.max-w-sm (24rem) clamps this paragraph's width regardless of how wide its container is, which keeps long-form text readable.


Layout

Display & Position

Single-purpose classes for the CSS display, position, overflow and visibility properties.

Display

ClassValue
.blockdisplay: block
.inlinedisplay: inline
.flex / .inline-flexdisplay: flex / inline-flex
.grid / .inline-griddisplay: grid / inline-grid

Flex and grid containers get their own set of alignment and track utilities — see Flexbox & Grid below.

Position

ClassValue
.staticposition: static
.relativeposition: relative
.absoluteposition: absolute
.fixedposition: fixed
.stickyposition: sticky
Inset offsets (top-*, right-*, bottom-*, left-*) don't exist yet — css/position/top.css, bottom.css, left.css and right.css are linked but currently empty. Use inline styles or your own CSS for offsets in the meantime.

Z-index

.z-{n} for n from 0 to 100, plus .z-auto and negative values written as .-z-{n}.

z-10
z-20

Overflow

ClassValue
.overflow-auto / -hidden / -clip / -visible / -scrolloverflow
.overflow-x-*overflow-x (same 5 values)
.overflow-y-*overflow-y (same 5 values)

Visibility

ClassValue
.visiblevisibility: visible
.invisiblevisibility: hidden (keeps layout space)
.hiddendisplay: none (removes layout space)

Layout

Flexbox & Grid

Alignment utilities work the same way whether the container is .flex or .grid. Add .gap-* (see Spacing) to space children without margins.

Flex container

ClassValue
.flex-row / .flex-row-reverse / .flex-col / .flex-col-reverseflex-direction
.flex-wrap / .flex-nowrap / .flex-wrap-reverseflex-wrap
.flex-1.flex-12, .flex-auto, .flex-initial, .flex-noneflex
.grow / .grow-0, .shrink / .shrink-0flex-grow / flex-shrink

Alignment

ClassValue
.items-start / -center / -end / -baseline / -stretchalign-items
.content-start / -center / -end / -between / -around / -evenlyalign-content
.self-start / -center / -end / -stretch / -baselinealign-self
.justify-start / -center / -end / -between / -around / -evenlyjustify-content
.justify-items-start / -center / -end / -stretchjustify-items
.justify-self-start / -center / -end / -stretchjustify-self

Live example

<div class="flex items-center justify-between gap-4">
  <div>A</div>
  <div>B</div>
  <div>C</div>
</div>
A
B
C

Grid

ClassValue
.grid-cols-1.grid-cols-12, -none, -subgridgrid-template-columns
.grid-rows-1.grid-rows-12, -none, -subgridgrid-template-rows
.col-auto, .col-1.col-12grid-column
.col-span-1.col-span-12, -fullgrid-column spans
.row-span-1.row-span-12grid-row spans

.grid .grid-cols-3 .gap-2, first cell uses .col-span-2


Typography

Text & Fonts

Font family, size, weight, alignment, decoration and wrapping behavior, all as single-purpose classes.

Font family

.font-sans — the system UI stack

.font-serif — Georgia, Cambria, Times

.font-mono — ui-monospace, Menlo, Consolas

Size & weight

ClassFont size / line height
.text-xs0.75rem / 1.33
.text-base1rem / 1.5
.text-xl1.25rem / 1.4
.text-4xl2.25rem / 1.11
.text-9xl8rem / 1

Weight runs from .font-thin (100) to .font-black (900) in the usual nine steps, plus .italic / .not-italic.

The quick brown fox

jumps over the lazy dog

Alignment, decoration & wrapping

ClassValue
.text-left / -center / -right / -justify / -start / -endtext-align
.underline / .overline / .line-through / .no-underlinetext-decoration-line
.decoration-solid / -dotted / -dashed / -double / -wavytext-decoration-style
.underline-offset-0-8, -autotext-underline-offset
.truncate / .text-ellipsis / .text-clipsingle-line overflow handling
.text-wrap / -nowrap / -balance / -prettytext-wrap
.text-shadow-2xs-lg, -nonetext-shadow

This sentence is far too long to fit and gets truncated

wavy underline

text-shadow-lg


Borders & Effects

Borders & Radius

Width, side and color are independent axes — combine a width class with a color class to get a visible border.

Border width & sides

ClassValue
.border, .border-0/2/4/8all sides
.border-x-* / .border-y-*inline / block axis
.border-t-* / -r-* / -b-* / -l-*single side
.border-{family}-{shade}border-color (full palette, see Colors)

Radius

.rounded-{size} covers all four corners (xs sm md lg xl 2xl 3xl 4xl full none). Prefix with a side (t r b l) or logical edge (s start, e end) or a single corner (tl tr br bl) to round selectively.

.rounded-sm · .rounded-lg · .rounded-full · .rounded-t-2xl · .rounded-tl-3xl


Borders & Effects

Shadows, Opacity & Outline

Box shadow

.shadow-{size} (2xs xs sm md lg xl 2xl none), .inset-shadow-{size} for inset variants, and .shadow-{family}-{shade} to tint the shadow with a palette color.

.shadow-sm · .shadow-lg · .shadow-2xl · .shadow-lg.shadow-indigo-400

Opacity

.opacity-{n} for every integer 0100, setting the CSS opacity property on the whole element.

Outline

ClassValue
.outline-none / -solid / -dashed / -dotted / -double / -hiddenoutline-style
.outline, .outline-0/1/2/4/8outline-width
.outline-offset-0/1/2/4/8outline-offset
.outline-{family}-{shade}outline-color

Borders & Effects

Filters

Each CSS filter function gets its own utility family. Combine several classes and the browser stacks them into one filter declaration each defines independently, so mixing e.g. .blur-sm with .grayscale applies both at once via the cascade.

FamilySteps
.blur-*xs sm md lg xl 2xl 3xl none
.brightness-*0 50 75 90 95 100 105 110 125 150…
.contrast-*0 50 75 100 125 150 200
.grayscale / .grayscale-{0,25,50,75,100}percentage
.hue-rotate-{0,15,30,60,90,180}degrees
.invert / .invert-{0,25,50,75,100}percentage
.saturate-{0,50,100,150,200}percentage
.sepia / .sepia-{0,50,100}percentage
.drop-shadow-{xs,sm,md,lg,xl,2xl,none}drop-shadow filter

Live example

.blur-sm · .grayscale · .contrast-150 · .hue-rotate-90 · .invert · .sepia


Motion & Interaction

Transitions & Animation

Duration

.duration-{ms} sets transition-duration: 0 75 100 150 200 300 500 700 1000, plus .duration-initial. Pair it with your own transition-property to animate a hover or state change.

Hover the square — .duration-500 eases the transform over 500ms.

Animation

ClassValue
.animate-noneno animation
.animate-spin1s linear infinite rotation
.animate-ping1s scale + fade pulse, infinite
.animate-pulse2s opacity pulse, infinite
.animate-bounce1s bounce, infinite

Motion & Interaction

Cursor, Pointer Events & Scrollbar

Cursor

One class per native cursor keyword, e.g. .cursor-pointer, .cursor-grab, .cursor-not-allowed, .cursor-crosshair, .cursor-zoom-in — covering the full CSS cursor value list.

pointer grab not-allowed help zoom-in

Pointer events

ClassValue
.pointer-events-autopointer-events: auto
.pointer-events-nonepointer-events: none — clicks pass through to whatever is behind the element

Scrollbar

ClassValue
.scrollbar-auto / -thin / -nonescrollbar-width
.scrollbar-gutter-auto / -stable / -bothscrollbar-gutter
.scrollbar-thumb-{family}-{shade}scrollbar-color thumb (full palette)

Scroll me — this box uses .scrollbar-thin and .scrollbar-thumb-indigo-400.

Line two of filler content.

Line three of filler content.

Line four of filler content.

CompactCSS reference — generated from the current contents of css/.