Skip to Content

Layout

AliasCSS includes a broad layout vocabulary built around length-based properties, display utilities, flexbox, grid, positioning, overflow, and box-model helpers. The intent is to let you express common layout decisions directly in class names while still keeping a close relationship with native CSS concepts.

Length-based properties

Most properties that accept a length value work in a similar way in AliasCSS. You can usually write either the full semantic property name or its shorthand alias.

padding(p), margin(m), gap(g), width(w), height(h), border-width(bw), line-height(lh), letter-spacing(les), border-radius(br), text-indent(ti), text-shadow(txs), box-shadow(bxs), top(t), bottom(btm), right(r), left(l), outline-width(olw), background-size(bgs), background-position(bgp), inline-size(is), block-size, margin-block, padding-block

Examples

ClassnameShorthandCompiled style
width-200pxw-200pxwidth:200px
max-width-960pxxw-960pxmax-width:960px
min-width-600pxmw-600pxmin-width:600px
margin-2remm-2remmargin:2rem
margin-2rem-12pxm-2rem-12pxmargin:2rem 12px
margin--2rem-12pxm--2rem-12pxmargin:-2rem 12px
margin--2rem--12pxm--2rem--12pxmargin:-2rem -12px
margin-12px-0px-12px--8pxm-12px-0px-12px--8pxmargin:12px 0px 12px -8px
margin-x-12pxmx-12pxmargin-right:12px; margin-left:12px
margin-x-4mx-4margin-right:1rem; margin-left:1rem
border-radius-10pxbr-10pxborder-radius:10px
box-shadow--1px-0px-2px-4px-black/7bxs--1px-0px-2px-4px-black/7box-shadow:-1px 0px 2px 4px oklch(from black l c h / 0.7)
text-shadow-1px-1px-4px-blacktxs-1px-1px-4px-blacktext-shadow:1px 1px 4px black

Numeric values from 1 to 10 used with padding, margin, and gap are converted to a spacing scale based on 0.25rem * n, so 4 becomes 1rem.

Usage

<h1 class="mx-4 p-32px-24px w-100% mh-200px bgc-primary600/7 c--text-color" > Hello, World </h1>

This pattern is especially useful because the class names stay visually close to the CSS they generate.

Non-numeric length values

AliasCSS also supports values such as min-content, max-content, fit-content, and function-based values like min(), max(), and clamp().

Examples

ClassnameShorthandCompiled style
width-max-contentw-xcwidth:max-content
width-min-contentw-mcwidth:min-content
width-fit-contentw-fcwidth:fit-content
width-min(40%,400px)w-min(40%,400px)width:min(40%, 400px)
width-max(40%,400px)w-max(40%,400px)width:max(40%, 400px)
width-clamp(20rem,30vw,70rem)w-clamp(20rem,30vw,70rem)width:clamp(20rem, 30vw, 70rem)

MDN describes clamp() as a CSS function that constrains a value between a minimum and maximum bound, and minmax() as a range function used with CSS Grid, which makes these formats useful for responsive, token-friendly layouts .

Usage

<h1 class="w--header-width mx-4 p-32px-24px mh-200px bgc-primary600/7 c--text-color" style="--header-width:clamp(min(10vw, 20rem), 300px, max(90vw, 55rem))" > Hello, World </h1>
💡

Try to use CSS variables as much as possible for complex values. It keeps the class names readable while still giving you full access to native CSS functions.

Flex, grid, and box model

AliasCSS includes short, memorable shorthands for common display, alignment, flexbox, and grid properties. Flexbox is generally best for one-dimensional layouts, while CSS Grid is intended for two-dimensional layouts with rows and columns

Common class names

ClassnameShorthandCompiled style
display-flexdf or d-fdisplay:flex
gap-16pxg-16pxgap:16px
display-inline-flexdif or d-ifdisplay:inline-flex
display-griddg or d-gdisplay:grid
display-inline-griddig or d-igdisplay:inline-grid
display-blockdb or d-bdisplay:block
display-inline-blockdib or d-ibdisplay:inline-block
display-nonedn or d-ndisplay:none
align-content-startacs or ac-salign-content:start
align-items-centeraic or ai-calign-items:center
align-self-stretchass or as-salign-self:stretch
justify-content-space-betweenjcsb or jc-sbjustify-content:space-between
flex-shrink-0No shorthandflex-shrink:0
flex-basis-200pxfb-200pxflex-basis:200px
flex-grow-0fg-0flex-grow:0
flex-direction-rowfdr or fd-rflex-direction:row
flex-direction-row-reversefdrr or fd-rrflex-direction:row-reverse
flex-direction-columnfdc or fd-cflex-direction:column
flex-direction-column-reversefdcr or fd-crflex-direction:column-reverse
grid-template-columns-repeat-3-1frgtc-repeat-3-1frgrid-template-columns:repeat(3, 1fr)
grid-template-rows-repeat-3-1frgtr-repeat-3-1frgrid-template-rows:repeat(3, 1fr)
grid-template-rows-200px-1frgtr-200px-1frgrid-template-rows:200px 1fr
grid-template-columns-repeat-auto-fill-200pxgtc-repeat-auto-fill-200pxgrid-template-columns:repeat(auto-fill, 200px)
grid-auto-rows-200pxgar-200pxgrid-auto-rows:200px
grid-auto-rows-minmax-100px-autogar-minmax-100px-autogrid-auto-rows:minmax(100px, auto)
grid-column-start-2gcs-2grid-column-start:2
grid-column-end-4gce-4grid-column-end:4
grid-row-start-1grs-1grid-row-start:1
grid-row-end--3gre--3grid-row-end:-3
grid-row-end-span-3gre-span-3grid-row-end:span 3
grid-column-1/2gc-1/2grid-column:1 / 2
grid-column-1/--2gc-1/--2grid-column:1 / -2
grid-row-1/4gr-1/4grid-row:1 / 4
grid-area-1/1/4/2ga-1/1/4/2grid-area:1 / 1 / 4 / 2

Card grid example

<!-- Layout --> <div class="d-g gtc-repeat-auto-fit-minmax-280px-1fr g-20px p-8px ff-inter"> <!-- Card --> <article class=" d-f fd-c g-16px p-20px br-20px bgc-white b-1px-s-black/1 bxs-0px-12px-32px--8px-black/1 " > <div class="d-f aic jcsb g-12px"> <span class="d-ib p-6px-12px br-999px bgc-blue/1 c-blue fs-12px fw-600 les-0.02em"> Featured </span> <span class="fs-13px c-gray500">Updated today</span> </div> <div class="d-f fd-c g-8px"> <h3 class="fs-20px fw-700 lh-28px c-gray900 m-0">Card Title</h3> <p class="fs-15px lh-24px c-gray600 m-0"> A more modern card layout with better spacing, softer elevation, and a cleaner reading flow. </p> </div> <div class="d-f fd-c g-10px p-16px br-16px bgc-gray50"> <span class="fs-13px c-gray500">Performance</span> <strong class="fs-28px fw-700 lh-32px c-gray900">87%</strong> <div class="w-100% h-8px br-999px bgc-gray200 oh"> <div class="w-87% h-100% bgc-blue br-999px"></div> </div> </div> <div class="d-f aic jcsb g-12px mt-auto pt-4px"> <div class="d-f aic g-8px"> <div class="w-10px h-10px br-999px bgc-green"></div> <span class="fs-14px c-gray600">Active</span> </div> <button class="p-10px-14px br-12px bgc-black c-white fs-14px fw-600 bn"> View Details </button> </div> </article>

Flex Layout Example

<article class=" d-f fd-c g-16px p-24px ff-inter w-100% xw-380px br-20px b-1px-s-black/1 bgc-white bxs-0px-12px-32px--8px-black/1 " > <div class="d-f aic jcsb g-12px"> <span class=" d-ib p-6px-12px br-999px bgc-blue/1 c-blue fs-12px fw-600 les-0.02em " > New Release </span> <button class=" d-f aic jc-c w-40px h-40px br-999px b-1px-s-black/1 bgc-white c-gray " aria-label="Save card" > </button> </div> <div class="d-f fd-c g-8px"> <h3 class="fs-22px fw-700 lh-30px c-black"> Analytics workspace card </h3> <p class="fs-15px lh-24px c-gray600 m-0"> A clean content card for dashboards, landing pages, and design systems. It gives you space for status, title, short description, and actions. </p> </div> <div class="d-f fd-c g-10px p-16px br-16px bgc-gray50"> <div class="d-f aic jcsb"> <span class="fs-13px c-gray500">Monthly revenue</span> <span class="fs-13px fw-600 c-green">+12.4%</span> </div> <div class="fs-28px fw-700 lh-32px c-black"> $48,240 </div> <div class="w-100% h-8px br-999px bgc-gray200 oh"> <div class="w-72% h-100% bgc-blue br-999px"></div> </div> </div> <div class="d-f aic jcsb g-12px mt-4px"> <div class="d-f aic g-8px"> <div class="w-10px h-10px br-999px bgc-green"></div> <span class="fs-14px c-gray600">Updated 2 hours ago</span> </div> <a href="#" class=" d-ib p-10px-14px br-12px bgc-black c-white fs-14px fw-600 td-none " > Open </a> </div> </article>

Practical guidance

A good rule of thumb is:

  • Use flexbox for rows, columns, alignment, and small component layouts.
  • Use grid for page sections, card layouts, and two-dimensional placement.
  • Use spacing and sizing utilities to keep those layouts readable without dropping into custom CSS too early.

Positioning

AliasCSS also includes concise positioning and overflow helpers for stacking, anchoring, clipping, and scroll behavior.

Common class names

ClassnameShorthandCompiled style
position-absolutepaposition:absolute
position-relativeprposition:relative
position-fixedpfposition:fixed
position-staticpsposition:static
position-stickypstposition:sticky
top-20pxt-20pxtop:20px
right-20pxr-20pxright:20px
bottom-20pxbtm-20pxbottom:20px
left--20pxl--20pxleft:-20px
inset-0i-0inset:0
overflow-hiddenohoverflow:hidden
overflow-y-autooyaoverflow-y:auto
overflow-x-scrolloxsoverflow-x:scroll
float-rightfrfloat:right
float-leftflfloat:left
clear-leftclclear:left
clear-rightcrclear:right
clear-bothcbclear:both

These utilities are useful for overlays, badges, floating panels, sticky headers, scroll regions, and classic float-based content when needed.

CSS variables for complex layout values

When layout values become too complex, CSS variables are the cleanest escape hatch.

💡

You can always use CSS variables to handle complex layout values and then reference them from AliasCSS utilities.

<section class="gtc--panel-grid-area gta--named-grid-areas" style=' --panel-grid-area: repeat(3, [col-start] 1fr [col-end]); --named-grid-areas: "header header header" "sidebar main main" "footer footer footer"; ' > Hello, World </section>

This approach is especially helpful for grid template definitions, named grid areas, complex clamp() expressions, and shared layout tokens.

Guidance

A practical way to use AliasCSS layout features is to work in layers:

  1. Start with display utilities such as df or dg.
  2. Add spacing with margin, padding, and gap utilities.
  3. Define structure with width, height, basis, and grid-template helpers.
  4. Add positioning only when the layout truly needs stacking or offset control.
  5. Move complex expressions into CSS variables instead of overloading class names.
Last updated on