Letterbox
A frame that fills whatever box holds it and centres a fixed-ratio surface inside.
View code
<div mix={[hstack({ gap: 5, align: "start" }), flexWrap()]}>
<div mix={[is("12rem"), bs("12rem")]}>
<Letterbox>
<Letterbox.Surface
mix={css({ display: "grid", placeItems: "center", background: "#4f46e5", color: "#fff", fontSize: "12cqh" })}
>
Q3 review
</Letterbox.Surface>
</Letterbox>
</div>
<div mix={[is("20rem"), bs("8rem")]}>
<Letterbox>
<Letterbox.Surface
mix={css({ display: "grid", placeItems: "center", background: "#4f46e5", color: "#fff", fontSize: "12cqh" })}
>
Q3 review
</Letterbox.Surface>
</Letterbox>
</div>
</div>Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add letterboxUsage
import { Letterbox } from "@sdxc/ui";Fills its container and paints the bars in --ui-letterbox-bars (black by default). In a
container with no definite height the frame takes its height from its width at the ratio, so
the surface fills it with no bars. The ratio rides on --ui-letterbox-ratio.
Composition
The parts the component publishes, each a static property of the host.
LetterboxLetterbox.SurfaceThe fixed-ratio area inside a Letterbox: as large as fits the frame, centred on both axes, and a size container, so its children size incqw/cqhof the surface itself.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
ratio | number | — | No | Width divided by height of the surface, as a number so the frame can size the surface with it (4 / 3, 1). |
Also accepts everything in TagProps<"div">.
Letterbox.Surface
Also accepts everything in TagProps<"div">.