Associated control
Make a visible field name activate and identify an input.
Components / Forms
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.
bunx --bun @getweini/cli@latest add labelImport 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.
<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 <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.
Make a visible field name activate and identify an input.
Use application-owned language to explain that a field is required.
Match for to the native control id.
<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>The slot owns the visible marker text.
<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 <template #required>(required)</template></Label>
<Input id="name" v-model="name" name="name" required />
</template>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.
| Name | Type or signature | Default | What it does |
|---|---|---|---|
disabledprop | boolean | undefined | Not set | Prevent interaction and show the disabled state. |
requiredprop | boolean | undefined | Not set | Ask the browser to require a value before form submission. |
defaultslot | () => unknown | Required | Content shown inside Label. |
requiredslot | (() => unknown) | undefined | Optional | Content for the required area of Label. |
// packages/frameworks/vue/components/label/types.ts
// ------- TYPES -------
export interface LabelProps {
disabled?: boolean
required?: boolean
}