{"route":"/en-US-v0.14.1/reference/foundations/target/","title":"Target","description":"Documentation for the `target` function.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"when-to-use-it","name":"When to use it","children":[]},{"id":"varying-targets","name":"Varying targets","children":[]},{"id":"example","name":"Example","children":[]}],"body":{"kind":"func","content":{"path":[],"name":"target","title":"Target","keywords":[],"oneliner":"Returns the current export target.","element":false,"contextual":true,"deprecationMessage":null,"deprecationUntil":null,"details":[{"kind":"html","content":"<p>Returns the current export target.</p>\n<p>This function returns either</p>\n<ul>\n<li><code><span class=\"typ-str\">&quot;paged&quot;</span></code> (for PDF, PNG, and SVG export), or</li>\n<li><code><span class=\"typ-str\">&quot;html&quot;</span></code> (for HTML export).</li>\n</ul>\n<p>The design of this function is not yet finalized and for this reason it is\nguarded behind the <code>html</code> feature. Visit the <a href=\"/en-US-v0.14.1/reference/html/\">HTML documentation\npage</a> for more details.</p>\n<h2 id=\"when-to-use-it\">When to use it</h2>\n<p>This function allows you to format your document properly across both HTML\nand paged export targets. It should primarily be used in templates and show\nrules, rather than directly in content. This way, the document's contents\ncan be fully agnostic to the export target and content can be shared between\nPDF and HTML export.</p>\n<h2 id=\"varying-targets\">Varying targets</h2>\n<p>This function is <a href=\"/en-US-v0.14.1/reference/context/\">contextual</a> as the target can vary within a\nsingle compilation: When exporting to HTML, the target will be <code><span class=\"typ-str\">&quot;paged&quot;</span></code>\nwhile within an <a href=\"/en-US-v0.14.1/reference/html/frame/\" title=\"`html.frame`\"><code>html.frame</code></a>.</p>\n<h2 id=\"example\">Example</h2>\n<div class=\"previewed-code\"><pre><code><span class=\"typ-key\">#</span><span class=\"typ-key\">let</span> <span class=\"typ-func\">kbd</span><span class=\"typ-punct\">(</span>it<span class=\"typ-punct\">)</span> <span class=\"typ-op\">=</span> <span class=\"typ-key\">context</span> <span class=\"typ-punct\">{</span>\n  <span class=\"typ-key\">if</span> <span class=\"typ-func\">target</span><span class=\"typ-punct\">(</span><span class=\"typ-punct\">)</span> <span class=\"typ-op\">==</span> <span class=\"typ-str\">&quot;html&quot;</span> <span class=\"typ-punct\">{</span>\n    html<span class=\"typ-punct\">.</span><span class=\"typ-func\">elem</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;kbd&quot;</span><span class=\"typ-punct\">,</span> it<span class=\"typ-punct\">)</span>\n  <span class=\"typ-punct\">}</span> <span class=\"typ-key\">else</span> <span class=\"typ-punct\">{</span>\n    <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>fill<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rgb</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;#1f2328&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">)</span>\n    <span class=\"typ-key\">let</span> r <span class=\"typ-op\">=</span> <span class=\"typ-num\">3pt</span>\n    <span class=\"typ-func\">box</span><span class=\"typ-punct\">(</span>\n      fill<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rgb</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;#f6f8fa&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n      stroke<span class=\"typ-punct\">:</span> <span class=\"typ-func\">rgb</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;#d1d9e0b3&quot;</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> r<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> r<span class=\"typ-punct\">)</span><span class=\"typ-punct\">,</span>\n      radius<span class=\"typ-punct\">:</span> r<span class=\"typ-punct\">,</span>\n      <span class=\"typ-func\">raw</span><span class=\"typ-punct\">(</span>it<span class=\"typ-punct\">)</span>\n    <span class=\"typ-punct\">)</span>\n  <span class=\"typ-punct\">}</span>\n<span class=\"typ-punct\">}</span>\n\nPress <span class=\"typ-func\">#</span><span class=\"typ-func\">kbd</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;F1&quot;</span><span class=\"typ-punct\">)</span> for help.\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.14.1/assets/d9ee13e0a44e198decccc6c1bd269c76.png\" alt=\"Preview\"></div></div>"}],"self":false,"params":[],"returns":["str"],"scope":[]}}}