sdxc

[ @sdxc/u/overflow ]

overflow-x

Applies overflow-x, independently of the block axis.

import { overflowX } from "@sdxc/u/overflow";

Quick reference

Every documented call, beside the CSS it emits.

CallCSS
u.overflowX("auto")css({ overflowX: "auto" })

Examples

Basic example

Use overflowX("auto") to let an element scroll horizontally when its content is wider than it is. Scroll the row sideways:

1
2
3
4
5
<div mix={[overflowX("auto"), hstack({ gap: 4 }), is(96), maxIs("100%"), p(4), ...]}>
	<div mix={[shrink(), is(24), ...]}>1</div>
	<div mix={[shrink(), is(24), ...]}>2</div>
	<div mix={[shrink(), is(24), ...]}>3</div>
	<div mix={[shrink(), is(24), ...]}>4</div>
	<div mix={[shrink(), is(24), ...]}>5</div>
</div>

Scrolling always

Use overflowX("scroll") to always show a horizontal scrollbar, where the operating system draws one, even when the content fits:

1
2
<div mix={[overflowX("scroll"), hstack({ gap: 4 }), is(96), maxIs("100%"), p(4), ...]}>
	<div mix={[shrink(), is(24), ...]}>1</div>
	<div mix={[shrink(), is(24), ...]}>2</div>
</div>

Clipping horizontally

Call overflowX(), which applies hidden, to clip content that is wider than its element:

1
2
3
4
5
<div mix={[overflowX(), hstack({ gap: 4 }), is(96), maxIs("100%"), p(4), ...]}>
	<div mix={[shrink(), is(24), ...]}>1</div>
	<div mix={[shrink(), is(24), ...]}>2</div>
	<div mix={[shrink(), is(24), ...]}>3</div>
	<div mix={[shrink(), is(24), ...]}>4</div>
	<div mix={[shrink(), is(24), ...]}>5</div>
</div>

Applying on a state

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

u.hover(u.overflowX("auto"))

Responsive design

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

u.at("md", u.overflowX("auto"))

Signature

u.overflowX(value?: OverflowValue)

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