Terms confirmation
Require a single explicit acknowledgement before submitting a form.
Components / Forms
A native checkbox for boolean or array models, including mixed state.
Last changed in version 0.14.2: Improve keyboard navigation, action feedback, and selected colors across Vue components.
bunx --bun @getweini/cli@latest add checkboxImport 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 { ref } from 'vue'
import Checkbox from './components/ui/checkbox/Checkbox.vue'
const accepted = ref(false)
</script>
<template>
<Checkbox v-model="accepted" required>Accept the terms</Checkbox>
</template>The underlying input retains native form, label, and keyboard behavior.
Require a single explicit acknowledgement before submitting a form.
Bind several native checkboxes to one array of selected values.
The wrapping label enlarges the clickable text target.
<script setup lang="ts">
import { ref } from 'vue'
import Checkbox from './components/ui/checkbox/Checkbox.vue'
const accepted = ref(false)
</script>
<template>
<Checkbox v-model="accepted" name="terms" required>I accept the terms</Checkbox>
</template>Array mode emits a new array when a choice changes.
<script setup lang="ts">
import { ref } from 'vue'
import Checkbox from './components/ui/checkbox/Checkbox.vue'
const channels = ref<string[]>(['email'])
</script>
<template>
<Checkbox v-model="channels" value="email" name="channel">Email</Checkbox>
<Checkbox v-model="channels" value="sms" name="channel">Text message</Checkbox>
</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 |
|---|---|---|---|
valueprop | T | undefined | Not set | Value represented by this control or option. |
indeterminateprop | boolean | undefined | Not set | Show a mixed state when the choice is partly selected. |
invalidprop | boolean | undefined | Not set | Show the invalid state; also provide a visible error message. |
modelValuemodel | boolean | T[] | undefined | false | Current value. Use v-model to keep it in sync with your page. |
update:modelValueevent | [value: boolean | T[]] | — | Requests a new model value from the parent. |
defaultslot | (() => unknown) | undefined | Optional | Content shown inside Checkbox. |
errorslot | ((props: { message: string; messages: string[]; }) => unknown) | undefined | Optional | Content for the error area of Checkbox. |
elementexposed | HTMLInputElement | null | — | Reference to the underlying HTML element. |
focusexposed | () => void | undefined | — | Move keyboard focus to this control. |
// packages/frameworks/vue/components/checkbox/types.ts
// ------- TYPES -------
export interface CheckboxProps<T = string> {
value?: T
indeterminate?: boolean
invalid?: boolean
}