Skip to content

Instantly share code, notes, and snippets.

@treyhuffine
Created July 23, 2020 12:21
Show Gist options
  • Save treyhuffine/fbca5f1becb0eff61f75c7b871916c2a to your computer and use it in GitHub Desktop.
Save treyhuffine/fbca5f1becb0eff61f75c7b871916c2a to your computer and use it in GitHub Desktop.
import styled from 'styled-components';
const Button = styled.button`
background-color: ${({ isActive }) => (isActive ? 'green' : 'gray')};
`;
const CssInJsComponent = () => {
const [isActive, setIsActive] = useState(false);
return (
<div>
<Button onClick={() => setIsActive(!isActive)} isActive={isActive}>
click me
</Button>
</div>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment