{"route":"/en-US-v0.13.1/reference/visualize/rect/","title":"Rectangle","description":"Documentation for the `rect` 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-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-body","name":"body","children":[]}]}],"body":{"kind":"func","content":{"path":[],"name":"rect","title":"Rectangle","keywords":[],"oneliner":"A rectangle with optional content.","element":true,"contextual":false,"deprecation":null,"details":"<p>A rectangle with optional content.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-comment\">// Without content.</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>width<span class=\"typ-punct\">:</span> <span class=\"typ-num\">35%</span><span class=\"typ-punct\">,</span> height<span class=\"typ-punct\">:</span> <span class=\"typ-num\">30pt</span><span class=\"typ-punct\">)</span>\n\n<span class=\"typ-comment\">// With content.</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">[</span>\n  Automatically sized <span class=\"typ-escape\">\\</span>\n  to fit the content.\n<span class=\"typ-punct\">]</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/b8c2e4acab3c02639ef4bfaa5380982a.png\" alt=\"Preview\"></div></div>","example":null,"self":false,"params":[{"name":"width","details":"<p>The rectangle's width, relative to its parent container.</p>","example":null,"types":["auto","relative"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"height","details":"<p>The rectangle's height, relative to its parent container.</p>","example":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":"fill","details":"<p>How to fill the rectangle.</p>\n<p>When setting a fill, the default stroke disappears. To create a\nrectangle with both fill and stroke, you have to configure both.</p>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> blue<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/5e9d207b0c933ecd5aaddeb58a002324.png\" alt=\"Preview\"></div></div>","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":"<p>How to stroke the rectangle. This can be:</p>\n<ul>\n<li><code><span class=\"typ-key\">none</span></code> to disable stroking</li>\n<li><code><span class=\"typ-key\">auto</span></code> for a stroke of <code><span class=\"typ-num\">1pt</span> <span class=\"typ-op\">+</span> black</code> if and if only if no fill is\ngiven.</li>\n<li>Any kind of <a href=\"/en-US-v0.13.1/reference/visualize/stroke/\" title=\"stroke\">stroke</a></li>\n<li>A dictionary describing the stroke for each side individually. The\ndictionary can contain the following keys in order of precedence:\n<ul>\n<li><code>top</code>: The top stroke.</li>\n<li><code>right</code>: The right stroke.</li>\n<li><code>bottom</code>: The bottom stroke.</li>\n<li><code>left</code>: The left stroke.</li>\n<li><code>x</code>: The horizontal stroke.</li>\n<li><code>y</code>: The vertical stroke.</li>\n<li><code>rest</code>: The stroke on all sides except those for which the\ndictionary explicitly sets a size.</li>\n</ul>\n</li>\n</ul>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-func\">#</span><span class=\"typ-func\">stack</span><span class=\"typ-punct\">(</span>\n  dir<span class=\"typ-punct\">:</span> ltr<span class=\"typ-punct\">,</span>\n  spacing<span class=\"typ-punct\">:</span> <span class=\"typ-num\">1fr</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>stroke<span class=\"typ-punct\">:</span> red<span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>stroke<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2pt</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>stroke<span class=\"typ-punct\">:</span> <span class=\"typ-num\">2pt</span> <span class=\"typ-op\">+</span> red<span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/44d3c9c5a1d56ba8ecfcffbc7c9144c4.png\" alt=\"Preview\"></div></div>","types":["none","auto","length","color","gradient","stroke","tiling","dictionary"],"strings":[],"default":"<code><span class=\"typ-key\">auto</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"radius","details":"<p>How much to round the rectangle's corners, relative to the minimum of\nthe width and height divided by two. This can be:</p>\n<ul>\n<li>A relative length for a uniform corner radius.</li>\n<li>A dictionary: With a dictionary, the stroke for each side can be set\nindividually. The dictionary can contain the following keys in order\nof precedence:\n<ul>\n<li><code>top-left</code>: The top-left corner radius.</li>\n<li><code>top-right</code>: The top-right corner radius.</li>\n<li><code>bottom-right</code>: The bottom-right corner radius.</li>\n<li><code>bottom-left</code>: The bottom-left corner radius.</li>\n<li><code>left</code>: The top-left and bottom-left corner radii.</li>\n<li><code>top</code>: The top-left and top-right corner radii.</li>\n<li><code>right</code>: The top-right and bottom-right corner radii.</li>\n<li><code>bottom</code>: The bottom-left and bottom-right corner radii.</li>\n<li><code>rest</code>: The radii for all corners except those for which the\ndictionary explicitly sets a size.</li>\n</ul>\n</li>\n</ul>","example":"<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">set</span> <span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>stroke<span class=\"typ-punct\">:</span> <span class=\"typ-num\">4pt</span><span class=\"typ-punct\">)</span>\n<span class=\"typ-func\">#</span><span class=\"typ-func\">rect</span><span class=\"typ-punct\">(</span>\n  radius<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>\n    left<span class=\"typ-punct\">:</span> <span class=\"typ-num\">5pt</span><span class=\"typ-punct\">,</span>\n    top-right<span class=\"typ-punct\">:</span> <span class=\"typ-num\">20pt</span><span class=\"typ-punct\">,</span>\n    bottom-right<span class=\"typ-punct\">:</span> <span class=\"typ-num\">10pt</span><span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n  stroke<span class=\"typ-punct\">:</span> <span class=\"typ-punct\">(</span>\n    left<span class=\"typ-punct\">:</span> red<span class=\"typ-punct\">,</span>\n    top<span class=\"typ-punct\">:</span> yellow<span class=\"typ-punct\">,</span>\n    right<span class=\"typ-punct\">:</span> green<span class=\"typ-punct\">,</span>\n    bottom<span class=\"typ-punct\">:</span> blue<span class=\"typ-punct\">,</span>\n  <span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n<span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/3fdded0cd492aef99d7d7bf62fb32661.png\" alt=\"Preview\"></div></div>","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":"<p>How much to pad the rectangle's content.\nSee the <a href=\"/en-US-v0.13.1/reference/layout/box/#parameters-outset\">box's documentation</a> for more details.</p>","example":null,"types":["relative","dictionary"],"strings":[],"default":"<code><span class=\"typ-num\">0%</span> <span class=\"typ-op\">+</span> <span class=\"typ-num\">5pt</span></code>","positional":false,"named":true,"required":false,"variadic":false,"settable":true},{"name":"outset","details":"<p>How much to expand the rectangle's size without affecting the layout.\nSee the <a href=\"/en-US-v0.13.1/reference/layout/box/#parameters-outset\">box's documentation</a> for more details.</p>","example":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":"body","details":"<p>The content to place into the rectangle.</p>\n<p>When this is omitted, the rectangle takes on a default size of at most\n<code><span class=\"typ-num\">45pt</span></code> by <code><span class=\"typ-num\">30pt</span></code>.</p>","example":null,"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":[]}}}