🔥 Meet Our New Project: t0ggles - Your Ultimate Project Management Tool! 🔥

useTheme

Konsta UI comes with handy useTheme hook to detect currently active theme (ios or material) set by App component or KonstaProvider.

<!-- App.vue -->
<template>
  <!-- set theme on App component -->
  <k-app theme="ios">
    <HomePage />
  </k-app>
</template>
<script>
  import { kApp } from 'konsta/vue';
  import HomePage from './path/to/HomePage.vue';

  export default {
    components: {
      kApp,
      HomePage,
    },
  };
</script>
<!-- HomePage.vue -->
<template>
  <k-page>
    <p>Theme is {{theme === 'ios' ? 'iOS' : 'Material'}}</p>
  </k-page>
</template>
<script>
  import { useTheme, kPage } from 'konsta/vue';

  export default {
    components: {
      kPage,
    },
    setup() {
      // get currently set theme
      const theme = useTheme();

      console.log(theme.value); // -> 'ios'

      return {
        theme,
      };
    },
  };
</script>
Code licensed under MIT.
2022 © Konsta UI by nolimits4web.