Skip to content

ASwitch to toggle dark mode #134

Closed Answered by sandros94
sandros94 asked this question in Q&A
Feb 23, 2023 · 2 comments · 2 replies
Discussion options

You must be logged in to vote

Ok looks like I was reinventing the wheel.
Vue does provide a built in feature to bind a checkbox to specific string for when it's true or false, but ASwitch (nor ACheckbox) doesn't take advantage of it.

Checkbox

<input
  type="checkbox"
  v-model="toggle"
  true-value="yes"
  false-value="no" />

true-value and false-value are Vue-specific attributes that only work with v-model. Here the toggle property's value will be set to 'yes' when the box is checked, and set to 'no' when unchecked. You can also bind them to dynamic values using v-bind:

<input
  type="checkbox"
  v-model="toggle"
  :true-value="dynamicTrueValue"
  :false-value="dynamicFalseValue" />

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@sandros94
Comment options

@sandros94
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by sandros94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant