sdxc

[ @sdxc/u/layout ]

zstack

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

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
<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:

<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.

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

Responsive design

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

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

Signature

u.zstack(options?: ZStackOptions)

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.