BColorMode
The BColorMode
directive is similar to useColorMode but provides a more low level directive for placement on individual components. It is useful when you want to make an element have one color mode, but do not want the overhead of the composable variant.
Demo
HTML
vue
<template>
<BCard v-b-color-mode="currentColor">
<BButton @click="changeColor"> Current color: {{ currentColor }} </BButton>
</BCard>
</template>
<script setup lang="ts">
import {vBColorMode} from 'bootstrap-vue-next'
// Unlike the composable variant, this is not strongly typed by default!
const currentColor = ref<'light' | 'dark'>('dark')
const changeColor = () => {
currentColor.value = currentColor.value === 'dark' ? 'light' : 'dark'
}
</script>