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>
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/90100%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
| Utility | Property set | File |
|---|---|---|
.border-{family}-{shade} | border-color | css/border.css |
.outline-{family}-{shade} | outline-color | css/outline.css |
.decoration-{family}-{shade} | text-decoration-color | css/text/decoration.css |
.shadow-{family}-{shade} | tinted box-shadow | css/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.
| Side | Margin | Padding |
|---|---|---|
| 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)
| Class | Value | Class | Value |
|---|---|---|---|
.m-0 / .p-0 | 0px | .m-8 / .p-8 | 2rem |
.m-1 / .p-1 | 0.25rem | .m-12 / .p-12 | 3rem |
.m-2 / .p-2 | 0.5rem | .m-16 / .p-16 | 4rem |
.m-4 / .p-4 | 1rem | .m-32 / .p-32 | 8rem |
.m-px / .p-px | 1px | .m-100 / .p-100 | 25rem |
.m-auto / .mx-auto / .my-auto | auto | … | every 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 class | Value |
|---|---|
.w-px | 1px |
.w-full | 100% |
.w-screen | 100vw |
.w-min / .w-max / .w-fit | min/max/fit-content |
.w-auto | auto |
.max-w-xs … .max-w-xl | 20rem … 36rem, named content widths |
.min-h-dvh / .min-h-svh / .min-h-lvh | dynamic / 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
| Class | Value |
|---|---|
.block | display: block |
.inline | display: inline |
.flex / .inline-flex | display: flex / inline-flex |
.grid / .inline-grid | display: grid / inline-grid |
Flex and grid containers get their own set of alignment and track utilities — see Flexbox & Grid below.
Position
| Class | Value |
|---|---|
.static | position: static |
.relative | position: relative |
.absolute | position: absolute |
.fixed | position: fixed |
.sticky | position: sticky |
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}.
Overflow
| Class | Value |
|---|---|
.overflow-auto / -hidden / -clip / -visible / -scroll | overflow |
.overflow-x-* | overflow-x (same 5 values) |
.overflow-y-* | overflow-y (same 5 values) |
Visibility
| Class | Value |
|---|---|
.visible | visibility: visible |
.invisible | visibility: hidden (keeps layout space) |
.hidden | display: 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
| Class | Value |
|---|---|
.flex-row / .flex-row-reverse / .flex-col / .flex-col-reverse | flex-direction |
.flex-wrap / .flex-nowrap / .flex-wrap-reverse | flex-wrap |
.flex-1 … .flex-12, .flex-auto, .flex-initial, .flex-none | flex |
.grow / .grow-0, .shrink / .shrink-0 | flex-grow / flex-shrink |
Alignment
| Class | Value |
|---|---|
.items-start / -center / -end / -baseline / -stretch | align-items |
.content-start / -center / -end / -between / -around / -evenly | align-content |
.self-start / -center / -end / -stretch / -baseline | align-self |
.justify-start / -center / -end / -between / -around / -evenly | justify-content |
.justify-items-start / -center / -end / -stretch | justify-items |
.justify-self-start / -center / -end / -stretch | justify-self |
Live example
<div class="flex items-center justify-between gap-4">
<div>A</div>
<div>B</div>
<div>C</div>
</div>
Grid
| Class | Value |
|---|---|
.grid-cols-1 … .grid-cols-12, -none, -subgrid | grid-template-columns |
.grid-rows-1 … .grid-rows-12, -none, -subgrid | grid-template-rows |
.col-auto, .col-1 … .col-12 | grid-column |
.col-span-1 … .col-span-12, -full | grid-column spans |
.row-span-1 … .row-span-12 | grid-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
| Class | Font size / line height |
|---|---|
.text-xs | 0.75rem / 1.33 |
.text-base | 1rem / 1.5 |
.text-xl | 1.25rem / 1.4 |
.text-4xl | 2.25rem / 1.11 |
.text-9xl | 8rem / 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
| Class | Value |
|---|---|
.text-left / -center / -right / -justify / -start / -end | text-align |
.underline / .overline / .line-through / .no-underline | text-decoration-line |
.decoration-solid / -dotted / -dashed / -double / -wavy | text-decoration-style |
.underline-offset-0 … -8, -auto | text-underline-offset |
.truncate / .text-ellipsis / .text-clip | single-line overflow handling |
.text-wrap / -nowrap / -balance / -pretty | text-wrap |
.text-shadow-2xs … -lg, -none | text-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
| Class | Value |
|---|---|
.border, .border-0/2/4/8 | all 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 0–100, setting the CSS opacity property on the whole element.
Outline
| Class | Value |
|---|---|
.outline-none / -solid / -dashed / -dotted / -double / -hidden | outline-style |
.outline, .outline-0/1/2/4/8 | outline-width |
.outline-offset-0/1/2/4/8 | outline-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.
| Family | Steps |
|---|---|
.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
| Class | Value |
|---|---|
.animate-none | no animation |
.animate-spin | 1s linear infinite rotation |
.animate-ping | 1s scale + fade pulse, infinite |
.animate-pulse | 2s opacity pulse, infinite |
.animate-bounce | 1s 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 events
| Class | Value |
|---|---|
.pointer-events-auto | pointer-events: auto |
.pointer-events-none | pointer-events: none — clicks pass through to whatever is behind the element |
Scrollbar
| Class | Value |
|---|---|
.scrollbar-auto / -thin / -none | scrollbar-width |
.scrollbar-gutter-auto / -stable / -both | scrollbar-gutter |
.scrollbar-thumb-{family}-{shade} | scrollbar-color thumb (full palette) |
CompactCSS reference — generated from the current contents of css/.