You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The variants config object is a simple object that allows you to define the variants that your component supports. Each variant is a key in the object and the value is an object that defines the possible values(css classes) for that variant.
98
104
99
105
```tsx
100
-
const StyledButton =styled("button", css.root, {
101
-
big: {
102
-
// Boolean values are supported
103
-
true: css.big,
106
+
const StyledButton =styled("button", {
107
+
css: css.root,
108
+
variants: {
109
+
big: {
110
+
// Boolean values are supported
111
+
true: css.big,
112
+
},
113
+
color: {
114
+
// String values are supported
115
+
primary: css.primary,
116
+
secondary: css.secondary,
117
+
},
118
+
size: {
119
+
// Number values are supported
120
+
1: css.size1,
121
+
2: css.size2,
122
+
},
104
123
},
105
-
color: {
106
-
// String values are supported
107
-
primary: css.primary,
108
-
secondary: css.secondary,
124
+
});
125
+
```
126
+
127
+
## Default Variants
128
+
129
+
You can use the `defaultVariants` feature to set a variant by default:
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "@phntms/css-components",
3
3
"description": "At its core, css-components is a simple wrapper around standard CSS. It allows you to write your CSS how you wish then compose them into a component ready to be used in React.",
0 commit comments