[ @sdxc/u/layout ]
flex-grow
Applies flex-grow.
import { grow } from "@sdxc/u/layout";Quick reference
Every documented call, beside the CSS it emits.
| Call | CSS |
|---|---|
u.grow() | css({ flexGrow: "1" }) |
u.grow(0) | css({ flexGrow: "0" }) |
Examples
Basic example
Use grow() to let a flex item grow to fill any available space:
01
grow()
03
<div mix={[flex(), gap(4), is("full")]}>
<div mix={[is(14), ...]}>01</div>
<div mix={[grow(), ...]}>grow()</div>
<div mix={[is(14), ...]}>03</div>
</div>Growing in proportion
Pass a factor like grow(2) to grow items in proportion to each other, here from a basis(0) so the shares are exact:
grow(1)
grow(2)
grow(1)
<div mix={[flex(), gap(4), is("full")]}>
<div mix={[grow(1), basis(0), ...]}>grow(1)</div>
<div mix={[grow(2), basis(0), ...]}>grow(2)</div>
<div mix={[grow(1), basis(0), ...]}>grow(1)</div>
</div>Preventing items from growing
Use grow(0) to keep an item at its own size while its siblings grow:
grow()
grow(0)
grow()
<div mix={[flex(), gap(4), is("full")]}>
<div mix={[grow(), ...]}>grow()</div>
<div mix={[grow(0), ...]}>grow(0)</div>
<div mix={[grow(), ...]}>grow()</div>
</div>Applying on a state
Wrap the call in a state utility to scope it to one selector.
u.hover(u.grow())Responsive design
Wrap the call in a container query to scope it to one width.
u.at("md", u.grow())Signature
u.grow(value?: number | (string & {}))