SizedBox
SizedBox constrains its child to specific dimensions. It's a lightweight alternative to Container when you only need sizing without decoration.

Tsx

import { SizedBox } from '@dynshift/layr';

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
1. Basic Usage
1a. Fixed Dimensions
Constrain child to exact width and height:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
1b. Width Only
Height wraps content:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
1c. Height Only
Width wraps content:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2. Spacers
2a. Vertical Spacing
Create gaps between elements:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2b. Horizontal Spacing
Space elements horizontally:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
2c. Responsive Spacing
Use rem for scalable spacing.

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
3. Static Methods
3a. SizedBox.expand
Fills all available space:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
Equivalent to width: 100%; height: 100%.
3b. SizedBox.shrink
Collapses to zero size:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
Equivalent to width: 0; height: 0.
3c. SizedBox.square
Creates equal width and height:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
Perfect for avatars, icons, or square placeholders.
4. Common Patterns
4a. Constrained Text
Limit text width for readability:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4b. Fixed Aspect Ratio Container
Combine with relative sizing:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4c. Icon Placeholder
Reserve space for icons:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4d. Responsive Width with Fixed Height
Full-width banner with controlled height:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4e. Grid Item Sizing
Consistent card dimensions:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4f. Button Min Width
Consistent button sizing:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
4g. Avatar with Placeholder
Fixed avatar size:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
5. Responsive Sizing
5a. Percentage Values
Relative to parent container:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
5b. Viewport Units
Relative to viewport:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
5c. CSS calc()
Dynamic calculations:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
6. Layout Behavior
SizedBox prevents shrinking in flex layouts using flexShrink: 0:

Tsx

Preview

NOTE: Previews are not depiction of actual website output.
7. API Reference
7a. SizedBoxProps
PropTypeDefaultDescription
childrenReactNodeWidget below this widget in the tree
widthnumber | stringExact width constraint
heightnumber | stringExact height constraint
classNamestring''Additional CSS classes
styleCSSProperties{}Custom inline styles
idstringHTML id attribute
7b. Static Methods
MethodDescriptionEquivalent
SizedBox.expandFills all available spacewidth: 100%; height: 100%
SizedBox.shrinkCollapses to zero sizewidth: 0; height: 0
SizedBox.squareEqual width and heightwidth: n; height: n
8. TypeScript
SizedBox is fully typed:

Tsx

import { SizedBox, type SizedBoxProps } from '@dynshift/layr';
const Card: React.FC<SizedBoxProps> = (props) => {
return (
<SizedBox width={320} height={240} {...props}>
<Container decoration={{ color: '#fff', borderRadius: 8 }}>
{props.children}
</Container>
</SizedBox>
);
};
9. Next Steps
• Padding — Add internal spacing • Centre — Center content