Created
November 15, 2020 11:41
-
-
Save jacobhq/cf79f36e15d1ba90289b0d18d2b2cde6 to your computer and use it in GitHub Desktop.
Desikit toggles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<h5 class="mt-3">Toggleable Button</h5> | |
<b-button :pressed.sync="myToggle" variant="primary">Toggle Me</b-button> | |
<p>Pressed State: <strong>{{ myToggle }}</strong></p> | |
<h5>In a button group</h5> | |
<b-button-group size="sm"> | |
<b-button | |
v-for="(btn, idx) in buttons" | |
:key="idx" | |
:pressed.sync="btn.state" | |
variant="primary" | |
> | |
{{ btn.caption }} | |
</b-button> | |
</b-button-group> | |
<p>Pressed States: <strong>{{ btnStates }}</strong></p> | |
</div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { | |
myToggle: false, | |
buttons: [ | |
{ caption: 'Toggle 1', state: true }, | |
{ caption: 'Toggle 2', state: false }, | |
{ caption: 'Toggle 3', state: true }, | |
{ caption: 'Toggle 4', state: false } | |
] | |
} | |
}, | |
computed: { | |
btnStates() { | |
return this.buttons.map(btn => btn.state) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment