{"route":"/en-US-v0.13.1/reference/foundations/label/","title":"Label","description":"Documentation for the Label type.","part":null,"outline":[{"id":"summary","name":"Summary","children":[]},{"id":"example","name":"Example","children":[]},{"id":"syntax","name":"Syntax","children":[]},{"id":"constructor","name":"Constructor","children":[{"id":"constructor-name","name":"name","children":[]}]}],"body":{"kind":"type","content":{"name":"label","title":"Label","keywords":[],"oneliner":"A label for an element.","details":"<p>A label for an element.</p>\n<p>Inserting a label into content attaches it to the closest preceding element\nthat is not a space. The preceding element must be in the same scope as the\nlabel, which means that <code>Hello <span class=\"typ-punct\">#</span><span class=\"typ-punct\">[</span><span class=\"typ-label\">&lt;label&gt;</span><span class=\"typ-punct\">]</span></code>, for instance, wouldn't work.</p>\n<p>A labelled element can be <a href=\"/en-US-v0.13.1/reference/model/ref/\">referenced</a>, <a href=\"/en-US-v0.13.1/reference/introspection/query/\">queried</a> for, and\n<a href=\"/en-US-v0.13.1/reference/styling/\">styled</a> through its label.</p>\n<p>Once constructed, you can get the name of a label using\n<a href=\"/en-US-v0.13.1/reference/foundations/str/#constructor\"><code>str</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\">show</span> <span class=\"typ-label\">&lt;a&gt;</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>blue<span class=\"typ-punct\">)</span>\n<span class=\"typ-key\">#</span><span class=\"typ-key\">show</span> <span class=\"typ-func\">label</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;b&quot;</span><span class=\"typ-punct\">)</span><span class=\"typ-punct\">:</span> <span class=\"typ-key\">set</span> <span class=\"typ-func\">text</span><span class=\"typ-punct\">(</span>red<span class=\"typ-punct\">)</span>\n\n<span class=\"typ-heading\">= Heading</span> <span class=\"typ-label\">&lt;a&gt;</span>\n<span class=\"typ-strong\">*Strong*</span> <span class=\"typ-func\">#</span><span class=\"typ-func\">label</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;b&quot;</span><span class=\"typ-punct\">)</span>\n</code></pre><div class=\"preview\"><img src=\"/en-US-v0.13.1/assets/97765723d8aff99a5c36e2fcda86a09f.png\" alt=\"Preview\"></div></div>\n<h2 id=\"syntax\">Syntax</h2>\n<p>This function also has dedicated syntax: You can create a label by enclosing\nits name in angle brackets. This works both in markup and code. A label's\nname can contain letters, numbers, <code>_</code>, <code>-</code>, <code>:</code>, and <code>.</code>.</p>\n<p>Note that there is a syntactical difference when using the dedicated syntax\nfor this function. In the code below, the <code><span class=\"typ-label\">&lt;a&gt;</span></code> terminates the heading and\nthus attaches to the heading itself, whereas the <code><span class=\"typ-func\">#</span><span class=\"typ-func\">label</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;b&quot;</span><span class=\"typ-punct\">)</span></code> is part of\nthe heading and thus attaches to the heading's text.</p>\n<pre><code><span class=\"typ-comment\">// Equivalent to `#heading[Introduction] &lt;a&gt;`.</span>\n<span class=\"typ-heading\">= Introduction</span> <span class=\"typ-label\">&lt;a&gt;</span>\n\n<span class=\"typ-comment\">// Equivalent to `#heading[Conclusion #label(&quot;b&quot;)]`.</span>\n<span class=\"typ-heading\">= Conclusion <span class=\"typ-func\">#</span><span class=\"typ-func\">label</span><span class=\"typ-punct\">(</span><span class=\"typ-str\">&quot;b&quot;</span><span class=\"typ-punct\">)</span></span>\n</code></pre>\n<p>Currently, labels can only be attached to elements in markup mode, not in\ncode mode. This might change in the future.</p>","constructor":{"path":[],"name":"label","title":"Construct","keywords":[],"oneliner":"Creates a label from a string.","element":false,"contextual":false,"deprecation":null,"details":"<p>Creates a label from a string.</p>","example":null,"self":false,"params":[{"name":"name","details":"<p>The name of the label.</p>","example":null,"types":["str"],"strings":[],"default":null,"positional":true,"named":false,"required":true,"variadic":false,"settable":false}],"returns":["label"],"scope":[]},"scope":[]}}}