Skip to content

Commit f5b69e9

Browse files
committed
Add new gradient color stop positions docs
1 parent 6db84c2 commit f5b69e9

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

src/components/CustomizePluginColors/index.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Editor } from '@/components/Editor'
22
import { highlightedCode } from './snippet.js?highlight=diff-js'
33

4-
export function CustomizePluginColors({ name, configKey, children }) {
4+
export function CustomizePluginColors({ name, configKey, children, learnMore = true }) {
55
return (
66
<>
77
<p>
@@ -27,10 +27,12 @@ export function CustomizePluginColors({ name, configKey, children }) {
2727
<code>theme.{configKey}</code> or <code>theme.extend.{configKey}</code> in your{' '}
2828
<code>tailwind.config.js</code> file.
2929
</p>
30-
<p>
31-
Learn more about customizing the default theme in the{' '}
32-
<a href="/docs/theme#customizing-the-default-theme">theme customization</a> documentation.
33-
</p>
30+
{learnMore && (
31+
<p>
32+
Learn more about customizing the default theme in the{' '}
33+
<a href="/docs/theme#customizing-the-default-theme">theme customization</a> documentation.
34+
</p>
35+
)}
3436
</>
3537
)
3638
}

src/pages/docs/gradient-color-stops.mdx

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,34 @@ Add a middle color to a gradient using the `via-{color}` utilities.
109109

110110
Gradients with a `from-{color}` and `via-{color}` will fade out to transparent by default if no `to-{color}` is present.
111111

112+
### Specifying stop positions
113+
114+
You can also specify the gradient color stop positions using the `from-{position}`, `via-{position}` and `to-{position}` utilities.
115+
116+
<Example>
117+
<div class="space-y-2 mx-5">
118+
<div class="relative h-16">
119+
<div class="absolute left-[calc(10%-20px)] flex flex-col space-y-2 items-center">
120+
<div class="rounded-full h-10 w-10 bg-indigo-500 border-4 border-white shadow-lg text-white text-[11px] font-semibold font-mono flex items-center justify-center">10%</div>
121+
<div class="bg-slate-300 w-0.5 h-4"></div>
122+
</div>
123+
<div class="absolute left-[calc(30%-20px)] flex flex-col space-y-2 items-center">
124+
<div class="rounded-full h-10 w-10 bg-sky-500 border-4 border-white shadow-lg text-white text-[11px] font-semibold font-mono flex items-center justify-center">30%</div>
125+
<div class="bg-slate-300 w-0.5 h-4"></div>
126+
</div>
127+
<div class="absolute left-[calc(90%-20px)] flex flex-col space-y-2 items-center">
128+
<div class="rounded-full h-10 w-10 bg-emerald-500 border-4 border-white shadow-lg text-white text-[11px] font-semibold font-mono flex items-center justify-center">90%</div>
129+
<div class="bg-slate-300 w-0.5 h-4"></div>
130+
</div>
131+
</div>
132+
<div class="p-4 rounded-lg bg-gradient-to-r from-indigo-500 from-10 via-sky-500 via-30 to-emerald-500 to-90">&nbsp;</div>
133+
</div>
134+
</Example>
135+
136+
```html
137+
<div class="bg-gradient-to-r from-indigo-500 **from-10** via-purple-500 **via-30** to-pink-500 **to-90** ..."></div>
138+
```
139+
112140
### Fading to transparent
113141

114142
Gradients fade out to transparent by default, without requiring you to add `to-transparent` explicitly. Tailwind intelligently calculates the _right_ "transparent" value to use based on the starting color to avoid [a bug in Safari < 15.4](https://bugs.webkit.org/show_bug.cgi?id=150940) that causes fading to simply the `transparent` keyword to fade through gray, which just looks awful.
@@ -163,8 +191,24 @@ Gradients fade out to transparent by default, without requiring you to add `to-t
163191

164192
### Customizing your theme
165193

166-
<CustomizePluginColors name="gradient" configKey="gradientColorStops" />
194+
<CustomizePluginColors name="gradient" configKey="gradientColorStops" learnMore={false} />
195+
196+
In addition to the colors, you can also customize the gradient color stop positions by editing `theme.gradientColorStopPositions` or `theme.extend.gradientColorStopPositions`.
197+
198+
```diff-js tailwind.config.js
199+
module.exports = {
200+
theme: {
201+
extend: {
202+
+ gradientColorStopPositions: {
203+
+ 33: '33%',
204+
+ }
205+
}
206+
}
207+
}
208+
```
209+
210+
Learn more about customizing the default theme in the [theme customization](/docs/theme#customizing-the-default-theme) documentation.
167211

168212
### Arbitrary values
169213

170-
<ArbitraryValues property="from|via|to-{color}" featuredClass="from-[#243c5a]" />
214+
<ArbitraryValues property="from|via|to-{color|position}" featuredClass="from-[#243c5a]" />

0 commit comments

Comments
 (0)