SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

zstack

A grid-overlay stack for layering children on top of each other.

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

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.zstack({ align: "center", justify: "center" })css({ display: "grid", alignItems: "center", justifyItems: "center", "& > *": { gridArea: "1 / 1" } })

Examples

Basic example

Use zstack() to stack children on top of each other, with align and justify placing them inside the shared cell:

Lake Tahoe
tsx
<div mix={[zstack({ align: "end", justify: "start" })]}>
	<div mix={[is(80), bs(48), ...]} />
	<div mix={[m(3), ...]}>Lake Tahoe</div>
</div>

Centering an overlay

Set both align and justify to "center" to lay an overlay over the middle of the content under it:

tsx
<div mix={[zstack({ align: "center", justify: "center" })]}>
	<div mix={[is(80), bs(48), ...]} />
	<button type="button" mix={[...]}>
		▶ Play
	</button>
</div>

Applying on a state

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

typescript
u.hover(u.zstack({ align: "center", justify: "center" }))

Responsive design

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

typescript
u.at("md", u.zstack({ align: "center", justify: "center" }))

Signature

typescript
u.zstack(options?: ZStackOptions)
@sdxc/u

Can’t find it? Contact us