styled-components, polished and themes

笑着哭i 提交于 2019-12-11 09:46:41

问题


I am trying Styled-components in a simple React project, I have a theme object that is passed to the component so I can do:

background-color: ${props => props.theme.primary};

I am also using Polished to modify the passed values, so a button uses a darker version of the color as an outline. I can do this with:

border: 1px solid ${darken(0.05, '#00823b')};

But I need the color value to be from the theme, how do I go about passing the theme properties in?

Thanks!


回答1:


Define your border style definition like this:

border: 1px solid ${props => darken(0.05, props.theme.primary)};

Working Demo



来源:https://stackoverflow.com/questions/47812117/styled-components-polished-and-themes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!