Skip to content

Search documentation

Search guides, examples, and component APIs.

Quick links
↑↓ NavigateEnter OpenEsc Close
Get started

Documentation navigation

Components / Forms

Label

A visible label with optional required and disabled styling.

Last changed in version 0.13.0: Add avatar groups and chips, expand the block gallery, and improve component colors, spacing, and motion.

Interactive showcase

Install

Run in your project
bunx --bun @getweini/cli@latest add label

Start with this example

Import the files copied by the install command, then place the component in your Vue template. The text and values in the example belong to your app; change them to fit your task.

Vue
<script setup lang="ts">
import Input from './components/ui/input/Input.vue'
import Label from './components/ui/label/Label.vue'
</script>

<template>
  <Label for="name" required>Name&nbsp;<template #required>*</template></Label>
  <Input id="name" required />
</template>

Associate the label with a real control id. The required slot supplies its marker; validation belongs on the control.

When to use it

Associated control

Make a visible field name activate and identify an input.

Required field marker

Use application-owned language to explain that a field is required.

More examples

Email label

Match for to the native control id.

Email label
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'
import Label from './components/ui/label/Label.vue'

const email = ref('')
</script>
<template>
  <Label for="email">Email address</Label>
  <Input id="email" v-model="email" type="email" name="email" />
</template>

Localized required marker

The slot owns the visible marker text.

Localized required marker
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'
import Label from './components/ui/label/Label.vue'

const name = ref('')
</script>
<template>
  <Label for="name" required>Full name&nbsp;<template #required>(required)</template></Label>
  <Input id="name" v-model="name" name="name" required />
</template>

Complete API

Every public prop, model, event, slot, and exposed member of the installed Vue parts is listed below. “Not set” means you can leave that value out; “Required” means you must provide it. Native HTML attributes also work where the component uses a native element.

Label

Complete API for Label
NameType or signatureDefaultWhat it does
disabledpropboolean | undefinedNot setPrevent interaction and show the disabled state.
requiredpropboolean | undefinedNot setAsk the browser to require a value before form submission.
defaultslot() => unknownRequiredContent shown inside Label.
requiredslot(() => unknown) | undefinedOptionalContent for the required area of Label.
Public type definitions
Public types
// packages/frameworks/vue/components/label/types.ts
// ------- TYPES -------

export interface LabelProps {
  disabled?: boolean
  required?: boolean
}

Implementation notes

  • The required prop changes label presentation; put required on the control for validation.
  • The disabled prop dims the label; disable the associated control separately.

Accessibility and localization

  • Use for and id together, or nest a native control in the label. Translate the required slot alongside the label.

Source contract and editing guidance