Associated control
Make a visible field name activate and identify an input.
Components / Forms
A visible label with optional required and disabled styling.
npx @getweini/cli@latest add labelMake a visible field name activate and identify an input.
Use application-owned language to explain that a field is required.
<script setup lang="ts">
import Label from './components/ui/label/Label.vue'
import Input from './components/ui/input/Input.vue'
</script>
<template>
<Label for="name" required>Name <template #required>*</template></Label>
<Input id="name" required />
</template>Match for to the native control id.
<script setup lang="ts">
import { ref } from 'vue'
import Label from './components/ui/label/Label.vue'
import Input from './components/ui/input/Input.vue'
const email = ref('')
</script>
<template>
<Label for="email">Email address</Label>
<Input id="email" v-model="email" type="email" name="email" />
</template>The slot owns the visible marker text.
<script setup lang="ts">
import { ref } from 'vue'
import Label from './components/ui/label/Label.vue'
import Input from './components/ui/input/Input.vue'
const name = ref('')
</script>
<template>
<Label for="name" required>Full name <template #required>(required)</template></Label>
<Input id="name" v-model="name" name="name" required />
</template>The most useful props, models, slots, events, and methods for this component.
| Name | Type | Default or requirement |
|---|---|---|
for | string | required for association |
required | boolean | false |
disabled | boolean | false |
required slot | slot | * marker |
Associate the label with a real control id. The required slot supplies its marker; validation belongs on the control.