sdxc

[ @sdxc/u/layout ]

flexColReverse

Sets display: flex; flex-direction: column-reverse.

import { flexColReverse } from "@sdxc/u/layout";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.flexColReverse()css({ display: "flex", flexDirection: "column-reverse" })

Examples

Basic example

Use flexColReverse() to stack flex items vertically in the opposite order; it makes the element a flex container too:

01
02
03
<div mix={[flexColReverse(), gap(4), is(64)]}>
	<div mix={[...]}>01</div>
	<div mix={[...]}>02</div>
	<div mix={[...]}>03</div>
</div>

Opening a chat at the newest message

A scroll container with flexColReverse() starts scrolled to its end, so write the newest message first and the log opens on it. Scroll up for older messages:

Message 8 (newest)
Message 7
Message 6
Message 5
Message 4
Message 3
Message 2
Message 1 (oldest)
<div mix={[flexColReverse(), gap(2), overflowY("auto"), is(72), bs(48), ...]}>
	<div mix={[...]}>Message 8 (newest)</div>
	<div mix={[...]}>Message 7</div>
	<div mix={[...]}>Message 6</div>
	<div mix={[...]}>Message 5</div>
	<div mix={[...]}>Message 4</div>
	<div mix={[...]}>Message 3</div>
	<div mix={[...]}>Message 2</div>
	<div mix={[...]}>Message 1 (oldest)</div>
</div>

Applying on a state

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

u.hover(u.flexColReverse())

Responsive design

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

u.at("md", u.flexColReverse())

Signature

u.flexColReverse()

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