{"route":"/en-US-v0.14.1/reference/layout/box/","title":"Box","description":"Documentation for the `box` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"parameters","name":"Parameters","children":[{"id":"parameters-width","name":"width","children":[]},{"id":"parameters-height","name":"height","children":[]},{"id":"parameters-baseline","name":"baseline","children":[]},{"id":"parameters-fill","name":"fill","children":[]},{"id":"parameters-stroke","name":"stroke","children":[]},{"id":"parameters-radius","name":"radius","children":[]},{"id":"parameters-inset","name":"inset","children":[]},{"id":"parameters-outset","name":"outset","children":[]},{"id":"parameters-clip","name":"clip","children":[]},{"id":"parameters-body","name":"body","children":[]}]}],"body":{"kind":"func","content":{"path":[],"name":"box","title":"Box","keywords":[],"oneliner":"An inline-level container that sizes content.","element":true,"contextual":false,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>An inline-level container that sizes content.</p>\n<p>All elements except inline math, text, and boxes are block-level and cannot\noccur inside of a <a href=\"/en-US-v0.14.1/reference/model/par/\">paragraph</a>. The box function can be used to\nintegrate such elements into a paragraph. Boxes take the size of their\ncontents by default but can also be sized explicitly.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code>Refer to the docs\n<span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">9pt</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">image</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;docs.svg&quot;</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">)</span>\nfor more information.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/781f4d033bb6c64f8ed6689f7e8cf029.png\" alt=\"Preview\"></div></div>"}],"self":false,"params":[{"name":"width","details":[{"kind":"html","content":"<p>The width of the box.</p>\n<p>Boxes can have <a href=\"/en-US-v0.14.1/reference/layout/fraction/\">fractional</a> widths, as the example below\ndemonstrates.</p>\n<p><em>Note:</em> Currently, only boxes and only their widths might be fractionally\nsized within paragraphs. Support for fractionally sized images, shapes,\nand more might be added in the future.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code>Line in <span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span> <span class=\"typ-func\">line</span><span class=\"typ-punct\">(</span>length<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100%</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span> between.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/77326ba2a90f710f23d720fa9d9484d0.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["auto","relative","fraction"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"height","details":[{"kind":"html","content":"<p>The height of the box.</p>"}],"types":["auto","relative"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"baseline","details":[{"kind":"html","content":"<p>An amount to shift the box's baseline by.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code>Image: <span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>baseline<span class=\"typ-punct\">:</span> <span class=\"typ-num\">40%</span><span class=\"typ-punct\">,</span> <span class=\"typ-func\">image</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;tiger.jpg&quot;</span><span class=\"typ-punct\">,</span> width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2cm</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/8cd6665dc2d94162a88dbe58873dee11.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["relative"],"strings":[],"default":"<code><span class=\"typ-num\">0%</span> <span class=\"typ-op\">+</span> <span class=\"typ-num\">0pt</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"fill","details":[{"kind":"html","content":"<p>The box's background color. See the\n<a href=\"/en-US-v0.14.1/reference/visualize/rect/#parameters-fill\">rectangle's documentation</a> for more details.</p>"}],"types":["none","color","gradient","tiling"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"stroke","details":[{"kind":"html","content":"<p>The box's border color. See the\n<a href=\"/en-US-v0.14.1/reference/visualize/rect/#parameters-stroke\">rectangle's documentation</a> for more details.</p>"}],"types":["none","length","color","gradient","stroke","tiling","dictionary"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">:</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"radius","details":[{"kind":"html","content":"<p>How much to round the box's corners. See the\n<a href=\"/en-US-v0.14.1/reference/visualize/rect/#parameters-radius\">rectangle's documentation</a> for more details.</p>"}],"types":["relative","dictionary"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">:</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"inset","details":[{"kind":"html","content":"<p>How much to pad the box's content.</p>\n<p>This can be a single length for all sides or a dictionary of lengths\nfor individual sides. When passing a dictionary, it can contain the\nfollowing keys in order of precedence: <code>top</code>, <code>right</code>, <code>bottom</code>, <code>left</code>\n(controlling the respective cell sides), <code>x</code>, <code>y</code> (controlling vertical\nand horizontal insets), and <code>rest</code> (covers all insets not styled by\nother dictionary entries). All keys are optional; omitted keys will use\ntheir previously set value, or the default value if never set.</p>\n<p><a href=\"/en-US-v0.14.1/reference/layout/relative/\">Relative lengths</a> for this parameter are relative to the box\nsize excluding <a href=\"/en-US-v0.14.1/reference/layout/box/#parameters-outset\">outset</a>. Note that relative insets and\noutsets are different from relative <a href=\"/en-US-v0.14.1/reference/layout/box/#parameters-width\">widths</a> and\n<a href=\"/en-US-v0.14.1/reference/layout/box/#parameters-height\">heights</a>, which are relative to the container.</p>\n<p><em>Note:</em> When the box contains text, its exact size depends on the\ncurrent <a href=\"/en-US-v0.14.1/reference/text/text/#parameters-top-edge\">text edges</a>.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>inset<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>Tight<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/1950e9bc82ffb5ee8a9520120f78b611.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["relative","dictionary"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">:</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"outset","details":[{"kind":"html","content":"<p>How much to expand the box's size without affecting the layout.</p>\n<p>This can be a single length for all sides or a dictionary of lengths for\nindividual sides. <a href=\"/en-US-v0.14.1/reference/layout/relative/\">Relative lengths</a> for this parameter are\nrelative to the box size excluding outset. See the documentation for\n<a href=\"/en-US-v0.14.1/reference/layout/box/#parameters-inset\">inset</a> above for further details.</p>\n<p>This is useful to prevent padding from affecting line layout. For a\ngeneralized version of the example below, see the documentation for the\n<a href=\"/en-US-v0.14.1/reference/text/raw/#parameters-block\">raw text's block parameter</a>.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code>An inline\n<span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>\n  fill<span class=\"typ-punct\">:</span> <span class=\"typ-func\">luma</span><span class=\"typ-punct\">(</span><span class=\"typ-num\">235</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  inset<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>x<span class=\"typ-punct\">:</span> <span class=\"typ-num\">3pt</span><span class=\"typ-punct\">,</span> y<span class=\"typ-punct\">:</span> <span class=\"typ-num\">0pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  outset<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>y<span class=\"typ-punct\">:</span> <span class=\"typ-num\">3pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  radius<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2pt</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span><span class=\"typ-punct\">[</span>rectangle<span class=\"typ-punct\">]</span>.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/ebc290926fc7b24332d5a0c06d059877.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["relative","dictionary"],"strings":[],"default":"<code><span class=\"typ-punct\">(</span><span class=\"typ-punct\">:</span><span class=\"typ-punct\">)</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"clip","details":[{"kind":"html","content":"<p>Whether to clip the content inside the box.</p>\n<p>Clipping is useful when the box's content is larger than the box itself,\nas any content that exceeds the box's bounds will be hidden.</p>"},{"kind":"example","content":{"body":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>\n  width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">50pt</span><span class=\"typ-punct\">,</span>\n  height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">50pt</span><span class=\"typ-punct\">,</span>\n  clip<span class=\"typ-punct\">:</span> <span class=\"typ-key\">true</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">image</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;tiger.jpg&quot;</span><span class=\"typ-punct\">,</span> width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100pt</span><span class=\"typ-punct\">,</span> height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">100pt</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/440635222ac048249d1f4a4ce36d3d6f.png\" alt=\"Preview\"></div></div>","title":null}}],"types":["bool"],"strings":[],"default":"<code><span class=\"typ-key\">false</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"body","details":[{"kind":"html","content":"<p>The contents of the box.</p>"}],"types":["none","content"],"strings":[],"default":"<code><span class=\"typ-key\">none</span></code>","positional":true,"named":false,"required":false,"variadic":false,"settable":true}],"returns":["content"],"scope":[]}}}