Position
Position utilities control CSS positioning and provide a set of named placement classes for anchoring elements within a positioned container. Combine them with inset utilities to offset elements from their edges, and with z-index utilities to manage stacking order.
Position types
Section titled “Position types”| Class | Sets |
|---|---|
.p-absolute | position: absolute |
.p-fixed | position: fixed |
.p-relative | position: relative |
.p-sticky | position: sticky |
Placement
Section titled “Placement”Placement classes position an element within its nearest positioned ancestor. They work with all position types.
| Class | Position |
|---|---|
.at-center | Dead center of the container |
.at-golden-ratio | Vertically at the golden ratio (~38.2% from top), horizontally centered |
.at-maximum | Stretches to fill the entire container (100dvw × 100dvh) |
.at-top | Top edge, horizontally centered |
.at-right | Right edge, vertically centered |
.at-bottom | Bottom edge, horizontally centered |
.at-left | Left edge, vertically centered |
.at-top-left | Top-left corner |
.at-top-right | Top-right corner |
.at-bottom-left | Bottom-left corner |
.at-bottom-right | Bottom-right corner |
.at-center .at-golden-ratio .at-maximum .at-bottom .at-top .at-left .at-right .at-top-right .at-bottom-right .at-bottom-left .at-top-left Inset utilities set the offset distance between a positioned element and the edges of its container. They set the --tng-inset custom property, which is consumed by the placement classes above.
| Class | Sets |
|---|---|
.inset-none | --tng-inset: var(--tng-spacing-none) |
.inset-3xs | --tng-inset: var(--tng-spacing-3xs) |
.inset-2xs | --tng-inset: var(--tng-spacing-2xs) |
.inset-xs | --tng-inset: var(--tng-spacing-xs) |
.inset-sm | --tng-inset: var(--tng-spacing-sm) |
.inset-md | --tng-inset: var(--tng-spacing-md) |
.inset-lg | --tng-inset: var(--tng-spacing-lg) |
.inset-xl | --tng-inset: var(--tng-spacing-xl) |
.inset-2xl | --tng-inset: var(--tng-spacing-2xl) |
| … | Continues up to .inset-10xl |
Inset values use the same spacing tokens as padding and gap, keeping distances consistent across the system.
.inset-none .inset-3xs .inset-2xs .inset-xs .inset-sm .inset-md .inset-lg .inset-xl .inset-2xl .inset-3xl .inset-4xl .inset-5xl .inset-6xl .inset-7xl .inset-8xl .inset-9xl .inset-10xl <!-- Badge in the top-right corner with a small inset --><div class="p-relative"> <img src="product.jpg" alt="Product" /> <span class="tng-badge | p-absolute at-top-right inset-sm">New</span></div>When to use
Section titled “When to use”| Pattern | Classes |
|---|---|
| Overlay centered in viewport | .p-fixed .at-center .z-overlay |
| Badge on an image corner | .p-absolute .at-top-right .inset-sm |
| Sticky header | .p-sticky .at-top .z-sticky |
| Full-screen backdrop | .p-fixed .at-maximum .z-overlay |
| Golden-ratio dialog | .p-fixed .at-golden-ratio .z-overlay |
Best practices
Section titled “Best practices”- Always set a positioning context —
.p-absoluteneeds a parent with.p-relative(or another positioned ancestor). Without one, the element positions relative to the viewport. - Combine with z-index — positioned elements often overlap others. Use z-index utilities to control stacking.
- Prefer placement classes over raw CSS —
.at-top-right .inset-smis more readable and maintainable than hand-writtentop/right/translatecombinations.