Skip to content

Label

A component for labeling form fields and other UI elements.

Import

vue
<script setup lang="ts">
import { Label } from '@heroui-vue/vue'
</script>

Usage

Basic

<template>
  <div class="flex flex-col gap-2">
    <Label for="name">Full Name</Label>
    <Label for="email" :is-required="true">Email Address</Label>
  </div>
</template>

<script setup>
import { Label } from '@heroui-vue/vue'
</script>

Required Indicator

vue
<template>
  <Label for="username" :is-required="true">Username</Label>
</template>

With Description

vue
<template>
  <div>
    <Label for="password">Password</Label>
    <Input id="password" type="password" />
    <Description>Must be at least 8 characters</Description>
  </div>
</template>

API

Label Props

PropTypeDefaultDescription
forstring-The id of the associated form field
isRequiredbooleanfalseWhether to show required indicator

Label Slots

SlotDescription
defaultThe label content

Accessibility

  • Label uses semantic <label> HTML element
  • Properly associated with form fields via for attribute
  • Required indicator is announced to screen readers
  • Clicking label focuses the associated field

Released under the Apache-2.0 License.