Last active
April 2, 2020 23:47
-
-
Save alaboudi/8ecce1eb4936f1badd40506e3481ce62 to your computer and use it in GitHub Desktop.
Customize checkbox only using css
This file contains hidden or 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
import styled from "styled-components"; | |
const Checkbox = styled.input.attrs(() => ({ | |
type: 'checkbox' | |
}))` | |
appearance: none; | |
background-color: #ffffff; | |
border: 1px solid #000000; | |
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05); | |
padding: 8px; | |
border-radius: 3px; | |
display: inline-block; | |
position: relative; | |
&:active { | |
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px 1px 3px rgba(0,0,0,0.1); | |
} | |
&:checked { | |
background-color: #000000; | |
border: 1px solid #000000; | |
box-shadow: 0 1px 2px rgba(0,0,0,0.05), inset 0px -15px 10px -12px rgba(0,0,0,0.05), inset 15px 10px -12px rgba(255,255,255,0.1); | |
color: #ffffff; | |
} | |
&:checked:after { | |
content: '\\2714'; | |
font-size: 14px; | |
position: absolute; | |
top: 0px; | |
left: 3px; | |
color: #ffffff; | |
} | |
`; | |
export default Checkbox; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment