Skip to content

Commit 026002c

Browse files
authored
Merge pull request #803 from jlengstorf/patch-1
docs: add advanced use case
2 parents 5739514 + 947e383 commit 026002c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

packages/color/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,26 @@ import { grayscale } from '@theme-ui/color'
170170
// grayscale('primary')
171171
```
172172

173-
### Related
173+
## Advanced Usage
174+
175+
If you want to do something more complex, such as setting up gradients, you can do that with some extra workarounds.
176+
177+
We can take the result of any of the above helper functions (which return a function) and call it with the theme object to generate a string in place. This is useful for interpolating values into complex CSS declarations:
178+
179+
```jsx
180+
<MyComponentWithBackground
181+
sx={{
182+
backgroundImage: t => `
183+
linear-gradient(
184+
to bottom,
185+
${alpha('primary', 0.5)(t)}
186+
${alpha('secondary', 0.5)(t)}
187+
)
188+
`
189+
}}
190+
/>
191+
```
192+
193+
## Related
174194

175195
- [Polished](https://polished.js.org)

0 commit comments

Comments
 (0)