Layout

box-sizing

Setting how the total width and height of an element is calculated.

Overview

ClassDeclarations
box-contentbox-sizing: content-box;
box-borderbox-sizing: border-box;
box-sizing:<value>box-sizing: <value>;

Examples

Include border and padding in size

Use box-border when an element's declared width and height should include its padding and border.

<div class="w:40x p:md b:1px|solid|gray-20 box-border">  Border-box</div>
Generated CSS
@layer utilities {  .box-border {    box-sizing: border-box  }}

Size the content box only

Use box-content when the declared size should apply only to the content area and padding or border can add to the rendered size.

<div class="w:40x p:md b:1px|solid|gray-20 box-content">  Content-box</div>

Prefer consistency inside components

Most UI components should use one sizing model consistently. Switch box sizing only at component boundaries or for compatibility with third-party content.

<div class="box-border">  <iframe class="box-content"></iframe></div>

Apply conditionally

Apply styles based on different states using selectors and conditional queries.

<div class="box-border box-border@print box-content@sm">...</div>


© 2026 Aoyue Design LLC.MIT License
Trademark Policy