naive-ui/demo/pages/docs/theme/enUS/provide-theme.demo.md
2021-02-14 14:52:14 +08:00

496 B

Provide Theme

Use n-config-provider to set the theme of all its descedant components.

<n-config-provider :theme="theme">
  <n-card>
    <n-space>
      <n-button @click="theme = darkTheme">Dark</n-button>
      <n-button @click="theme = null">Light</n-button>
    </n-space>
  </n-card>
</n-config-provider>
import { ref } from 'vue'
import { darkTheme } from 'naive-ui'

export default {
  setup () {
    return {
      darkTheme,
      theme: ref(null)
    }
  }
}