import { fade } from '@material-ui/core/styles/colorManipulator';
/**
* Set the absolute transparency of a color.
* Any existing alpha values are overwritten.
*
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla()
* @param {number} value - value to set the alpha channel to in the range 0 -1
* @returns {string} A CSS color string. Hex input values are returned as rgb
*/
{
backgroundColor: fade(theme.colors.red, 0.5)
}
5 回答
我找到了一个解决方案
或者,您可以使用Material UI Next中提供的淡入淡出功能 .
这里's how it'工作:https://github.com/mui-org/material-ui/blob/v1-beta/src/styles/colorManipulator.js#L157-L164
另一种解决方案可能是使用https://github.com/styled-components/polished中的类似颜色函数
材质UI具有
colorManipulator
utility file,其中包含fade
方法:用法:
color库也可能有用:
然后你可以在你的代码中引用它:
您可以使用RGBA值
https://facebook.github.io/react-native/docs/colors.html
对于它的 Value ,8位十六进制代码也可以工作