SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

position

Sets position: relative.

tsx
import { relative } from "@sdxc/u/layout";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.relative()css({ position: "relative" })

Examples

Basic example

Use relative() to position an element in the normal flow, so its absolutely positioned children are offset from it:

Relative parent

absolute()
tsx
<div mix={[relative(), is(72), bs(36), ...]}>
	<p>Relative parent</p>
	<div mix={[absolute(), insBs(3), insIe(3), ...]}>absolute()</div>
</div>

Offsetting in the flow

Add offsets like insBs(4) and insIs(6) to shift a relative element from its place, while the space it came from stays reserved:

relative()
tsx
<div mix={[...]}>
	<div mix={[relative(), insBs(4), insIs(6), ...]}>relative()</div>
</div>

Applying on a state

Wrap the call in a state utility to scope it to one selector.

typescript
u.hover(u.relative())

Responsive design

Wrap the call in a container query to scope it to one width.

typescript
u.at("md", u.relative())

Signature

typescript
u.relative()
@sdxc/u

Can’t find it? Contact us