SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

Letterbox

A frame that fills whatever box holds it and centres a fixed-ratio surface inside.

Q3 review
Q3 review
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add letterbox

Usage

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

  • Letterbox
  • Letterbox.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 in cqw/cqh of the surface itself.

Props

Read from the component's own types, so every prop, every default and every allowed value is listed.

PropTypeDefaultRequiredDescription
rationumber—NoWidth 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">.

@sdxc/ui

Can’t find it? Contact us