Created
December 5, 2019 06:54
-
-
Save timsully/04f83590919543651bbac0164afb582c to your computer and use it in GitHub Desktop.
Everything is in one place — logic, styling, and markup. Styled components.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can pass a function to your style declarations with one parameter which is component's | |
// props. You can then use props to adjust your styling. | |
import React from 'react' | |
import ReactDOM from 'react-dom' | |
import styled from 'styled-components' | |
const StyledButton = styled.button` | |
border-radius: 5px; | |
background-color: ${props => (props.secondary ? '#F7A072' : '#a1cdf1')}; | |
color: #fff; | |
padding: 10px 15px; | |
outline: none; | |
border: none; | |
cursor: pointer; | |
margin: 15px; | |
` | |
const Application = () => { | |
return ( | |
<div> | |
<StyledButton>Click me</StyledButton> | |
<StyledButton secondary>Click for secondary Action</StyledButton> | |
</div> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Basic Usage of Styled-Components | |
import React from 'react' | |
import styled from 'styled-components' | |
const StyledButton = styled.button` | |
border-radius: 5px; | |
background-color: #a1cdf1; | |
color #fff; | |
padding: 10px 15px; | |
outline: none; | |
border: none; | |
cursor: pointer; | |
` | |
const Application = () => { | |
return <StyledButton onClick={() => console.log('clicked')}>Click me</StyledButton> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment