Checkbox, Radio, and Select
Choice controls need care with true-value/false-value and array checkboxes. This lesson covers practical patterns, syntax, and mistakes to avoid.
Choice Controls in Vue
Choice controls need care with true-value/false-value and array checkboxes.
Radios share a v-model and different values.
<input type="checkbox" v-model="accepted" true-value="yes" false-value="no" />
<input type="radio" v-model="color" value="red" />
<input type="radio" v-model="color" value="blue" />
Custom checkbox values + radio group.
Arrays
Checkbox value + array v-model pushes/pops values.
- Prefer Composition API + script setup.
- Use computed for derived UI.
- Keep side effects intentional.
- Practice in a small Vite app.
Checkbox, Radio, and Select Cheatsheet
Quick reference for patterns covered in this lesson.
| Item | Example | Purpose |
| true-value | checkbox | Custom |
| array model | multi check | List |
| radio group | same model | Exclusive |
| select multiple | array | Multi |
| disabled | option | UX |
| labels | wrapping | A11y |
Native Semantics
Prefer real controls over clickable divs.
Common Mistakes
- Building custom toggles without keyboard support.
- Mixing string/number values inconsistently.
Key Takeaways
- Checkbox, Radio, and Select is important in Vue apps.
- Practice in SFCs.
- Prefer clear naming.
- Check Vue docs for details.
Pro Tip
Normalize values (ids as strings) across API and form state.