I am trying to create a Button component using Styled-Components and Styled-System. In general, it works fine. However, when it comes to doing a basic prop test, I can't seem to get it to work.
For instance, the following code is not working for me:
background-color: ${props => (props.bg ? 'red' : 'blue')}
Whether or not I have set the bg
prop, the background-color is always red. In other words, the following components both return a red background:
<Button>Button</Button>
<Button bg="primary.base">Primary</Button>
Any idea how I can conditionally check if a prop is set?
In case it helps, I am referring to the Button.js
and layout.js
files in the Components
folder here: https://codesandbox.io/s/gatsbystarterdefault-rbzo8?fontsize=14