top / right / bottom / left
Utilities for controlling the placement of positioned elements.
| Class | Effect |
|---|---|
inset-<number> |
inset: calc(var(--spacing) * <number>); |
-inset-<number> |
inset: calc(var(--spacing) * -<number>); |
inset-<fraction> |
inset: calc(<fraction> * 100%); |
-inset-<fraction> |
inset: calc(<fraction> * -100%); |
inset-px |
inset: 1px; |
-inset-px |
inset: -1px; |
inset-full |
inset: 100%; |
-inset-full |
inset: -100%; |
inset-auto |
inset: auto; |
inset-[<value>] |
inset: <value>; |
inset-x-<number> |
inset-inline: calc(var(--spacing) * <number>); |
-inset-x-<number> |
inset-inline: calc(var(--spacing) * -<number>); |
inset-x-<fraction> |
inset-inline: calc(<fraction> * 100%); |
-inset-x-<fraction> |
inset-inline: calc(<fraction> * -100%); |
inset-x-px |
inset-inline: 1px; |
-inset-x-px |
inset-inline: -1px; |
inset-x-full |
inset-inline: 100%; |
-inset-x-full |
inset-inline: -100%; |
inset-x-auto |
inset-inline: auto; |
inset-x-[<value>] |
inset-inline: <value>; |
inset-y-<number> |
inset-block: calc(var(--spacing) * <number>); |
-inset-y-<number> |
inset-block: calc(var(--spacing) * -<number>); |
inset-y-<fraction> |
inset-block: calc(<fraction> * 100%); |
-inset-y-<fraction> |
inset-block: calc(<fraction> * -100%); |
inset-y-px |
inset-block: 1px; |
-inset-y-px |
inset-block: -1px; |
inset-y-full |
inset-block: 100%; |
-inset-y-full |
inset-block: -100%; |
inset-y-auto |
inset-block: auto; |
inset-y-[<value>] |
inset-block: <value>; |
inset-s-<number> |
inset-inline-start: calc(var(--spacing) * <number>); |
-inset-s-<number> |
inset-inline-start: calc(var(--spacing) * -<number>); |
inset-s-<fraction> |
inset-inline-start: calc(<fraction> * 100%); |
-inset-s-<fraction> |
inset-inline-start: calc(<fraction> * -100%); |
inset-s-px |
inset-inline-start: 1px; |
-inset-s-px |
inset-inline-start: -1px; |
inset-s-full |
inset-inline-start: 100%; |
-inset-s-full |
inset-inline-start: -100%; |
inset-s-auto |
inset-inline-start: auto; |
inset-s-[<value>] |
inset-inline-start: <value>; |
inset-e-<number> |
inset-inline-end: calc(var(--spacing) * <number>); |
-inset-e-<number> |
inset-inline-end: calc(var(--spacing) * -<number>); |
inset-e-<fraction> |
inset-inline-end: calc(<fraction> * 100%); |
-inset-e-<fraction> |
inset-inline-end: calc(<fraction> * -100%); |
inset-e-px |
inset-inline-end: 1px; |
-inset-e-px |
inset-inline-end: -1px; |
inset-e-full |
inset-inline-end: 100%; |
-inset-e-full |
inset-inline-end: -100%; |
inset-e-auto |
inset-inline-end: auto; |
inset-e-[<value>] |
inset-inline-end: <value>; |
inset-bs-<number> |
inset-block-start: calc(var(--spacing) * <number>); |
-inset-bs-<number> |
inset-block-start: calc(var(--spacing) * -<number>); |
inset-bs-<fraction> |
inset-block-start: calc(<fraction> * 100%); |
-inset-bs-<fraction> |
inset-block-start: calc(<fraction> * -100%); |
inset-bs-px |
inset-block-start: 1px; |
-inset-bs-px |
inset-block-start: -1px; |
inset-bs-full |
inset-block-start: 100%; |
-inset-bs-full |
inset-block-start: -100%; |
inset-bs-auto |
inset-block-start: auto; |
inset-bs-[<value>] |
inset-block-start: <value>; |
inset-be-<number> |
inset-block-end: calc(var(--spacing) * <number>); |
-inset-be-<number> |
inset-block-end: calc(var(--spacing) * -<number>); |
inset-be-<fraction> |
inset-block-end: calc(<fraction> * 100%); |
-inset-be-<fraction> |
inset-block-end: calc(<fraction> * -100%); |
inset-be-px |
inset-block-end: 1px; |
-inset-be-px |
inset-block-end: -1px; |
inset-be-full |
inset-block-end: 100%; |
-inset-be-full |
inset-block-end: -100%; |
inset-be-auto |
inset-block-end: auto; |
inset-be-[<value>] |
inset-block-end: <value>; |
top-<number> |
top: calc(var(--spacing) * <number>); |
-top-<number> |
top: calc(var(--spacing) * -<number>); |
top-<fraction> |
top: calc(<fraction> * 100%); |
-top-<fraction> |
top: calc(<fraction> * -100%); |
top-px |
top: 1px; |
-top-px |
top: -1px; |
top-full |
top: 100%; |
-top-full |
top: -100%; |
top-auto |
top: auto; |
top-[<value>] |
top: <value>; |
right-<number> |
right: calc(var(--spacing) * <number>); |
-right-<number> |
right: calc(var(--spacing) * -<number>); |
right-<fraction> |
right: calc(<fraction> * 100%); |
-right-<fraction> |
right: calc(<fraction> * -100%); |
right-px |
right: 1px; |
-right-px |
right: -1px; |
right-full |
right: 100%; |
-right-full |
right: -100%; |
right-auto |
right: auto; |
right-[<value>] |
right: <value>; |
bottom-<number> |
bottom: calc(var(--spacing) * <number>); |
-bottom-<number> |
bottom: calc(var(--spacing) * -<number>); |
bottom-<fraction> |
bottom: calc(<fraction> * 100%); |
-bottom-<fraction> |
bottom: calc(<fraction> * -100%); |
bottom-px |
bottom: 1px; |
-bottom-px |
bottom: -1px; |
bottom-full |
bottom: 100%; |
-bottom-full |
bottom: -100%; |
bottom-auto |
bottom: auto; |
bottom-[<value>] |
bottom: <value>; |
left-<number> |
left: calc(var(--spacing) * <number>); |
-left-<number> |
left: calc(var(--spacing) * -<number>); |
left-<fraction> |
left: calc(<fraction> * 100%); |
-left-<fraction> |
left: calc(<fraction> * -100%); |
left-px |
left: 1px; |
-left-px |
left: -1px; |
left-full |
left: 100%; |
-left-full |
left: -100%; |
left-auto |
left: auto; |
left-[<value>] |
left: <value>; |
Examples
Section titled “Examples”Basic example
Section titled “Basic example”Combine top-*, right-*, bottom-*, left-* and inset-* with absolute positioning.


if ui.div("grid grid-cols-3 gap-4") { for c in ([]string{"top-0 left-0", "inset-x-0 top-0", "top-0 right-0", "inset-y-0 left-0", "inset-0", "inset-y-0 right-0", "bottom-0 left-0", "inset-x-0 bottom-0", "right-0 bottom-0"}) { ui.key(c) if ui.div("relative size-24 rounded-lg bg-stripes stripes-violet-500/30 bg-violet-500/10") { ui.el(ui.cx("absolute rounded-lg bg-violet-500", c, c == "inset-0" ? "" : (c == "inset-x-0 top-0" || c == "inset-x-0 bottom-0" ? "h-8" : (c == "inset-y-0 left-0" || c == "inset-y-0 right-0" ? "w-8" : "size-8")))) } }}Centering with negative translate
Section titled “Centering with negative translate”

if ui.div("relative h-32 w-64 rounded-lg bg-stripes stripes-sky-500/30 bg-sky-500/10") { ui.el("absolute top-1/2 left-1/2 size-12 -translate-x-1/2 -translate-y-1/2 rounded-full bg-sky-500 shadow-lg")}