Skip to content

Commit 65949b2

Browse files
committed
Add: Default Variants
1 parent 4f9e50f commit 65949b2

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

text/002-css-rules.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ button([
638638

639639
## 6. Compound Variants
640640

641-
[Stitche's `Compound Variants`](https://stitches.dev/docs/variants#compound-variants) is an effective way to set up additional css by leveraging the combination of variations you have already set up.
641+
[Stitches's `Compound Variants`](https://stitches.dev/docs/variants#compound-variants) is an effective way to set up additional css by leveraging the combination of variations you have already set up.
642642

643643
However, the method of writing the conditions seems quite inconvenient.
644644
So we want to improve the UX in this area.
@@ -647,7 +647,7 @@ So we want to improve the UX in this area.
647647

648648
```typescript
649649
const button = rules({
650-
// base style
650+
// base styles
651651

652652
variants: {
653653
color: {
@@ -679,7 +679,7 @@ But if the conditions become complicated, it will be inconvenient to fill out.
679679

680680
```typescript
681681
const button = rules({
682-
// base style
682+
// base styles
683683

684684
variants: {
685685
color: {
@@ -703,7 +703,7 @@ const button = rules({
703703
});
704704
```
705705

706-
The method we present will provide a more comfortable way to write the conditions.
706+
The method we present will provide a more comfortable way to write the conditions.
707707
This feature checks existing variants and provides automatic completion.
708708

709709
**Compiled:**
@@ -731,10 +731,30 @@ button({
731731

732732
## 7. Default Variants
733733

734+
The way of [Stitches's Default Variants](https://stitches.dev/docs/variants#default-variants) is already good to use, so we keep this method in ours.
735+
734736
**Code:**
735737

736738
```typescript
739+
const button = rules({
740+
// base styles
737741

742+
variants: {
743+
color: {
744+
brand: {
745+
color: "#FFFFA0",
746+
backgroundColor: "blueviolet",
747+
},
748+
accent: {
749+
color: "#FFE4B5",
750+
backgroundColor: "slateblue",
751+
},
752+
},
753+
},
754+
defaultVariants: {
755+
color: "brand",
756+
},
757+
});
738758
```
739759

740760
## 8. Composition

0 commit comments

Comments
 (0)