Skip to content

Box

const Box: ForwardRefExoticComponent<BoxProps & RefAttributes<GlyphNode>>;

Generic layout container — the building block of every Glyph UI.

Box maps directly to a Yoga flexbox node, so all CSS-like flex properties (flexDirection, gap, padding, alignItems, …) work out of the box.

<Box style={{ flexDirection: "row", gap: 1, padding: 1 }}>
<Text>Hello</Text>
<Text>World</Text>
</Box>
// Centered card with a border
<Box
style={{
border: "round",
borderColor: "cyan",
padding: 1,
alignItems: "center",
justifyContent: "center",
width: 40,
height: 10,
}}
>
<Text style={{ bold: true }}>Welcome!</Text>
</Box>

PropertyTypeDescription
children?ReactNodeChild elements to render inside the box.
focusable?booleanWhen true, the box participates in the focus (Tab) order.
style?StyleFlexbox style object controlling layout, colors, borders, and more.