Label
Installation
npx @mielui/svelte add labelyarn dlx @mielui/svelte add labelbunx @mielui/svelte add labelUsage
Match for to the control's id. Clicking any part of the label, including elements you put in its children, focuses that control.
required shows a mark after the text. The mark is hidden from assistive technology, so set required on the control too. A label placed after a peer control dims when that control is disabled; when the label comes first, add the disabled styling yourself.
<script lang="ts">
import { Input } from '@mielui/svelte/components/input';
import { Label } from '@mielui/svelte/components/label';
</script>
<Label for="email">Email</Label>
<Input id="email" type="email" />Examples
Required
Label draws the mark itself. Input and Textarea do the same for their built-in label when they are required, and Field.Label follows Field.Root.
Disabled
API reference
Label
Labels a form control.
class(string & (ClassValue | null))Classes added to the element.
childrenSnippet<[]>Content rendered inside.
requiredbooleanShows a required mark after the text. The mark is hidden from assistive technology, so set
requiredon the control as well.Default
false
pnpm dlx @mielui/svelte add label