Label
Form label with a required indicator, description text and a tooltip slot. Clicking it focuses the control whose id is in `for`.
<arc-label>Overview
Label puts a styled label above a form control. Set for to the control's id and clicking the label focuses that control.
The <label> element is inside Label's shadow root, so it can't reach an input outside it. It doesn't give the input its accessible name. Use the input's own label for that, such as the label prop on <arc-input>.
required adds a red asterisk after the text. The asterisk is hidden from screen readers, so set required on the input as well. The description slot puts smaller muted text under the label, and the tooltip slot puts an info icon or tooltip trigger beside it.
Guidelines
Do
- Give every control an accessible name of its own. Label doesn't supply one
- Use the description slot for format hints like "MM/DD/YYYY" or character limits
- Mark mandatory fields with `required`, on both the label and the input
Don't
- Don't use Label as standalone text. Use a heading or paragraph
- Don't put interactive elements in the label text. Use the tooltip slot
Features
- Three sizes: sm, md, lg
- `disabled` halves the opacity and blocks pointer events, to match a disabled input below it
Preview
Usage
<arc-label for="username" required>Username</arc-label>
<arc-input id="username" placeholder="Enter username"></arc-input>
<arc-label for="bio">
Bio
<span slot="description">Keep it under 160 characters.</span>
</arc-label>
<arc-textarea id="bio"></arc-textarea>import { Label, Input, Textarea } from '@arclux/arc-ui-react';
export default function Example() {
return (
<>
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter username" />
<Label for="bio">
Bio
<span slot="description">Keep it under 160 characters.</span>
</Label>
<Textarea id="bio" />
</>
);
}<script setup>
import { Label, Input, Textarea } from '@arclux/arc-ui-vue';
</script>
<template>
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter username" />
<Label for="bio">
Bio
<template #description>Keep it under 160 characters.</template>
</Label>
<Textarea id="bio" />
</template><script>
import { Label, Input, Textarea } from '@arclux/arc-ui-svelte';
</script>
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter username" />
<Label for="bio">
Bio
<span slot="description">Keep it under 160 characters.</span>
</Label>
<Textarea id="bio" />import { Component } from '@angular/core';
import { Label, Input, Textarea } from '@arclux/arc-ui-angular';
@Component({
imports: [Label, Input, Textarea],
template: `
<arc-label for="username" required>Username</arc-label>
<arc-input id="username" placeholder="Enter username" />
`,
})
export class FormComponent {}import { Label, Input } from '@arclux/arc-ui-solid';
export default function Example() {
return (
<>
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter username" />
</>
);
}import { Label, Input } from '@arclux/arc-ui-preact';
export default function Example() {
return (
<>
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter username" />
</>
);
}<!-- Use native <label> with matching for/id attributes -->
<label class="arc-label" for="username">
Username <span style="color: #ef4444; font-weight: 700;">*</span>
</label>
<input id="username" placeholder="Enter username" /><!-- Use native <label> with inline styles -->
<label for="username" style="display: block; font-size: 14px; font-weight: 600; color: rgb(160, 160, 176); margin-bottom: 4px;">
Username <span style="color: #ef4444; font-weight: 700;">*</span>
</label>
<input id="username" placeholder="Enter username" />API
forstring''- ID of the target input element. Clicking the label focuses the associated control.
requiredbooleanfalse- Shows a red asterisk (*) after the label text.
size'sm' | 'md' | 'lg''md'- Controls the label font size.
disabledbooleanfalse- Reduces opacity and blocks pointer events.
See also
- InputText field with a built-in label, placeholder and validation states. Set `multiline` for a textarea.
- FieldsetGroups related form controls in a native fieldset with a legend, drawn as a bordered box or a card.
- FormWraps ARC UI inputs in a form that validates them on submit and fires arc-submit with their values.