2019-12-07 00:02:31 +08:00
# Theme Environment
2020-02-05 13:13:48 +08:00
Sometimes you may need some component to access some values at specific theme. You can use `theme-environment` . Config Consumer & Element have access to theme environment.
2019-12-07 00:02:31 +08:00
```html
2020-02-05 13:13:48 +08:00
< div >
< n-button @click =" theme = 'dark' " > Dark Theme</ n-button >
< n-button @click =" theme = 'light' " > Light Theme</ n-button >
< / div >
2020-05-31 13:38:35 +08:00
< n-config-provider :theme = "theme" :theme-environment = "env" >
< n-card >
< n-config-consumer v-slot = "{ themeEnvironment }" >
< n-tag > {{ themeEnvironment }}< / n-tag >
2020-03-01 19:17:53 +08:00
< / n-config-consumer >
2020-05-31 13:38:35 +08:00
< / n-card >
< / n-config-provider >
2019-12-07 00:02:31 +08:00
```
```js
export default {
data () {
return {
2020-05-31 13:38:35 +08:00
theme: 'dark',
2019-12-07 00:02:31 +08:00
env: {
2020-02-05 13:13:48 +08:00
dark: 'NaCl',
light: 'Ionic Compound'
2019-12-07 00:02:31 +08:00
}
}
}
}
```
```css
.n-button {
2020-02-05 13:13:48 +08:00
margin: 0 8px 12px 0;
2019-12-07 00:02:31 +08:00
}
```