Skip to content

Instantly share code, notes, and snippets.

@alaboudi
Last active April 2, 2020 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alaboudi/8ecce1eb4936f1badd40506e3481ce62 to your computer and use it in GitHub Desktop.
Save alaboudi/8ecce1eb4936f1badd40506e3481ce62 to your computer and use it in GitHub Desktop.
Customize checkbox only using css
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