naive-ui/demo/documentation/components/configConsumer/enUS/themeEnvironment.demo.md
07akioni 487001d697 build: add changelog to site, refactor loader based on suffix
.demo.md for component demo
.demo-entry.md for demo entry
.md for common docs
2020-08-19 23:30:04 +08:00

31 lines
614 B
Markdown

# Theme Environments
Get current theme environment.
```html
<n-button @click="theme = 'dark'">Dark Theme</n-button>
<n-button @click="theme = 'light'">Light Theme</n-button>
<n-config-provider :theme="theme" :theme-environments="env">
<n-config-consumer v-slot="{ themeEnvironment }">
<n-card>
<n-tag>{{ themeEnvironment }}</n-tag>
</n-card>
</n-config-consumer>
</n-config-provider>
```
```js
export default {
data () {
return {
theme: 'dark',
env: {
dark: 'NaCl',
light: 'Ionic Compound'
}
}
}
}
```
```css
.n-button {
margin: 0 8px 12px 0;
}
```