Label
Neo-brutalist label component for form fields, with variant support.
Demo
尺寸
必填
Installation
pnpm dlx brutx-vue@latest add labelUsage
<script setup>
import { Label, Input } from 'brutx-ui-vue'
</script>
<template>
<div class="space-y-2">
<Label for="email">Email</Label>
<Input id="email" type="email" placeholder="you@example.com" />
</div>
</template>Required Indicator
When the required prop is set, a red * asterisk is automatically rendered at the end of the label (marked as aria-hidden), and the root element gets aria-required="true" to help accessibility tools identify required fields.
<script setup>
import { Label, Input } from 'brutx-ui-vue'
</script>
<template>
<div class="space-y-2">
<Label for="username" required>Username</Label>
<Input id="username" placeholder="Enter your username" />
</div>
</template>Variants
| Variant | Description |
|---|---|
default | Standard foreground text |
error | Destructive (red) text |
success | Success (green) text |
muted | Muted foreground text |
Sizes
| Size | Font Size | Line Height |
|---|---|---|
sm | text-xs | leading-none |
default | text-sm | leading-none |
lg | text-base | leading-none |
<script setup>
import { Label } from 'brutx-ui-vue'
</script>
<template>
<div class="flex flex-wrap items-center gap-4">
<Label size="sm">Small Label</Label>
<Label size="default">Default Label</Label>
<Label size="lg">Large Label</Label>
</div>
</template>API Reference
| Name | Type | Default | Description |
|---|---|---|---|
variant | "default" | "error" | "muted" | "success" | undefined | "default" | Sets the semantic color variant of the label. |
DetailsDeclared typeNonNullable<"default" | "success" | "muted" | "error" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
size | "default" | "lg" | "sm" | undefined | "default" | Sets the label text and spacing size. |
DetailsDeclared typeNonNullable<"default" | "lg" | "sm" | null | undefined> | undefined Literal values
Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
required | boolean | undefined | false | Shows a decorative required asterisk after the label text; declare required semantics on the form control as well. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
disabled | boolean | undefined | false | Applies disabled-state styling and sets aria-disabled; it does not disable the associated form control. |
DetailsDeclared typeboolean | undefined Literal values
Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
for | string | undefined | undefined | Sets the native label for attribute to associate it with a form control that has the same ID. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
class | string | undefined | undefined | CSS classes added to the label root element. |
DetailsDeclared typestring | undefined Default value details
Sourcepackages/ui/src/components/label/Label.vue | |||
| Name | Signature or type | Description |
|---|---|---|
#default | {} | The displayed label text, field name, or other inline content. |
DetailsDeclared type{}Sourcepackages/ui/src/components/label/Label.vue | ||
Accessibility
The Label component renders as an HTML <label> element. When using the for attribute, it associates with the matching form control, improving accessibility and click-to-focus behavior.
- When
requiredistrue, the component automatically adds thearia-required="true"attribute - The required indicator
*is marked asaria-hidden="true"to avoid duplicate announcements by screen readers - Pass
disabledto explicitly show the disabled label state and setaria-disabled="true";peer-disabledstyling remains available