Skip to content

Commit 6ba8af3

Browse files
committed
Update at-apply documentation
1 parent ec9b9b9 commit 6ba8af3

File tree

1 file changed

+63
-1
lines changed

1 file changed

+63
-1
lines changed

docs/source/docs/functions-and-directives.blade.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,69 @@ This is extremely useful when you find a common utility pattern in your HTML tha
5454
}
5555
```
5656

57-
Note that `@@apply` **will not work** for mixing in hover or responsive variants of another utility. Instead, mix in the plain version of that utility into the `:hover` pseudo-selector or a new media query:
57+
Rules can listed on a single line or with multiple calls to `@@apply`:
58+
59+
```less
60+
.btn {
61+
@@apply .font-bold;
62+
@@apply .py-2;
63+
@@apply .px-4;
64+
@@apply .rounded;
65+
}
66+
```
67+
68+
You can mix `@@apply` declarations with normal CSS declarations too of course:
69+
70+
```less
71+
.btn:hover {
72+
@@apply .bg-blue-dark;
73+
transform: translateY(-1px);
74+
}
75+
```
76+
77+
Any rules mixed in with `@@apply` will have `!important` **removed** by default to avoid specificity issues:
78+
79+
```less
80+
// Input
81+
.foo {
82+
@@apply .bar;
83+
}
84+
85+
.bar {
86+
color: blue !important;
87+
}
88+
89+
// Output
90+
.foo {
91+
color: blue;
92+
}
93+
94+
.bar {
95+
color: blue !important;
96+
}
97+
```
98+
99+
If you'd like to `@@apply` an existing class and make it `!important`, simply add `!important` to the end of the declaration:
100+
101+
102+
```less
103+
// Input
104+
.btn {
105+
@@apply .font-bold .py-2 .px-4 .rounded !important;
106+
}
107+
108+
// Output
109+
.btn {
110+
font-weight: 700 !important;
111+
padding-top: .5rem !important;
112+
padding-bottom: .5rem !important;
113+
padding-right: 1rem !important;
114+
padding-left: 1rem !important;
115+
border-radius: .25rem !important;
116+
}
117+
```
118+
119+
Note that `@@apply` **will not work** for mixing in hover, focus, or responsive variants of another utility. Instead, mix in the plain version of that utility into the appropriate pseudo-selector or a new media query:
58120

59121
```less
60122
// Won't work:

0 commit comments

Comments
 (0)