Skip to content

Commit 78b5663

Browse files
authored
Update themes.mdx (nativewind#1142)
Fix code example
1 parent aaaa01e commit 78b5663

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

apps/website/docs/guides/themes.mdx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@ module.exports = {
1111
theme: {
1212
colors: {
1313
// Create a custom color that uses a CSS custom value
14-
primary: "rgb(var(--color-primary) / <alpha-value>)",
14+
primary: "rgb(var(--color-values) / <alpha-value>)",
1515
},
1616
},
1717
plugins: [
1818
// Set a default value on the `:root` element
19-
({ addBase }) => addBase({ ":root": { "--color-primary": "255 0 0" } }),
19+
({ addBase }) => addBase({
20+
":root": {
21+
"--color-values": "255 0 0",
22+
"--color-rgb": "rgb(255 0 0)"
23+
}
24+
}),
2025
],
2126
};
2227
```
@@ -25,18 +30,20 @@ module.exports = {
2530
import { vars } from 'nativewind'
2631

2732
const userTheme = vars({
28-
'--color-primary': '255 0 0'
33+
'--color-values': '0 255 0',
34+
'--color-rgb': 'rbg(0 0 255)'
2935
});
3036

3137
export default App() {
3238
return (
3339
<View>
3440
<Text className="text-primary">Access as a theme value</Text>
35-
<Text className="text-[--color-primary]">Or the variable directly</Text>
41+
<Text className="text-[--color-rgb]">Or the variable directly</Text>
3642

3743
{/* Variables can be changed inline */}
3844
<View style={userTheme}>
39-
<Text className="text-primary">I am now red!</Text>
45+
<Text className="text-primary">I am now green!</Text>
46+
<Text className="text-[--color-rgb]">I am now blue!</Text>
4047
</View>
4148
</View>
4249
)

0 commit comments

Comments
 (0)