Skip to content

Commit ee46d2f

Browse files
committed
Add color opacity shorthand documentation
1 parent 116fd4c commit ee46d2f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/pages/docs/just-in-time-mode.mdx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,27 @@ The `!` always goes at the beginning of the utility name, after any variants, bu
209209

210210
This can be useful in rare situations where you need to increase specificity because you're at war with some styles you don't control.
211211

212+
### Color opacity shorthand
213+
214+
Instead of needing to use utilities like `bg-opacity-50`, `text-opacity-25`, or `placeholder-opacity-40`, the JIT engine lets you just tack the opacity right on to the end of the color:
215+
216+
```diff-html
217+
- <div class="bg-red-500 bg-opacity-25">
218+
+ <div class="bg-red-500/25">
219+
```
220+
221+
This means you can now change the opacity of colors anywhere in Tailwind, even where we previously didn't have specific opacity utilities, like in gradients for example:
222+
223+
```html
224+
<div class="bg-gradient-to-r from-red-500/50">
225+
```
226+
227+
The opacity values are taken from your `opacity` scale, but you can also use arbitrary opacity values using square bracket notation:
228+
229+
```html
230+
<div class="bg-red-500/[0.31]">
231+
```
232+
212233
### Per-side border colors
213234

214235
Requested since like 2017 but left out due to file-size considerations, the JIT engine finally adds support for setting the border color for each side of an element independently:

0 commit comments

Comments
 (0)