Skip to content

Instantly share code, notes, and snippets.

@jacobhq
Created November 15, 2020 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobhq/cf79f36e15d1ba90289b0d18d2b2cde6 to your computer and use it in GitHub Desktop.
Save jacobhq/cf79f36e15d1ba90289b0d18d2b2cde6 to your computer and use it in GitHub Desktop.
Desikit toggles
<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