Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="container">
  <div class="artboard t-material-light" id="artboard-1"></div>
  <div class="artboard t-material-dark" id="artboard-2"></div>
  <div class="artboard t-material-light" id="artboard-3"></div>
  <div class="artboard t-material-dark" id="artboard-4" dir="rtl"></div>
  <div class="artboard t-material-light" id="artboard-5"></div>
  <div class="artboard t-material-dark" id="artboard-6"></div>
  <div class="artboard t-material-light" id="artboard-7"></div>
  <div class="artboard t-material-dark" id="artboard-8"></div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto');


// TEMPLATE SETUP
@function theme-light ($key) {
  @if map-has-key($theme-material-light, $key) {
    @return map-get($theme-material-light, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}
@function theme-dark ($key) {
  @if map-has-key($theme-material-dark, $key) {
    @return map-get($theme-material-dark, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}
@function theme-app ($key) {
  @if map-has-key($theme-app, $key) {
    @return map-get($theme-app, $key)
  }
  
  @else {
    @warn "No such key in map"
  }
}
@mixin flexbox-c-c {
  display: flex;
  align-items: center;
  justify-content: center;
}
@mixin apply-child-themes ($color, $properties...) {
  .t-material-light & {
    @each $property in $properties {
      #{$property}: theme-light($color);
    }
  }
  .t-material-dark & {
    @each $property in $properties {
      #{$property}: theme-dark($color);
    }
  }
}
@mixin hidden-visually () {
  border: 0 !important;
  clip: rect(0 0 0 0) !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
}
@mixin square ($size) {
	height: $size;
	width: $size;
}

$color-white: #fff;
$color-black: #000;
$color-gray: #B0B0B0;

$theme-material-light: (
  statusBar: #e0e0e0,
  appBar: #f5f5f5,
  appBackground: #fafafa,
  modal: #fff,
  textPrimary: rgba(#000, .87),
  textSecondary: rgba(#000, .54),
  disabled: rgba(#000, .38),
  dividers: rgba(#000, .12)
);
  
$theme-material-dark: (
  statusBar: #000,
  appBar: #212121,
  appBackground: #303030,
  modal: #424242,
  textPrimary: rgba(#fff, 1),
  textSecondary: rgba(#fff, .7),
  disabled: rgba(#fff, .5),
  dividers: rgba(#fff, .12)
);

$theme-app: (
  base: #00aa8d,
  lighter: #00bf92,
  darker: #008975
);


html,
body {
  width: 100%;
  min-height: 100%;
}

body {
  padding: 50px 0;
  align-items: flex-start;
  background-color: rgba(#1B2B34, .5);
  display: flex;
  justify-content: center;
}

.container {
  display: grid;
  grid-template-columns: repeat(2, 200px);
  grid-template-rows: repeat(4, 200px);
  grid-column-gap: 20px;
  grid-row-gap: 20px;
  justify-items: stretch;
  align-items: stretch;
}

.artboard {
  @include flexbox-c-c;
  
  &.t-material-light {
    background-color: theme-light(appBackground);
  }
  
  &.t-material-dark {
    background-color: theme-dark(appBackground);
  }
}




//REACT CHECKBOX
@keyframes ripple {
	0% {
		opacity: 0;
		r: 0;
	}
	
	50% {
		opacity: .18;
		r: 120%;
	}
	
	100% {
		opacity: 0;
		r: 140%;
	}
}


$checkbox-color: theme-app(base);
$checkbox-empty-color: $color-gray;
$checkbox-disabled-color: $color-gray;
$checkbox-mark-color: $color-white;
$checkbox-label-color: $color-black;
$checkbox-size: 18px;
$checkbox-radius: 2px;
$label-color: $color-black;
$label-offset: 12px;


.checkbox {
	align-items: center;
	cursor: pointer;
	display: inline-flex;
  font-family: Roboto, Helvetica;
	justify-content: flex-start;
	user-select: none;
	padding: 12px;
	
	[dir='rtl'] & {
		flex-direction: reverse;
	}
}


.checkbox__input {
	@include hidden-visually;
	
	&:disabled {
    ~ .checkbox__indicator {
      @include apply-child-themes(disabled, border-color);
		
		  .checkbox__indicator__bg {
        @include apply-child-themes(disabled, fill);
        
			  fill: $checkbox-disabled-color;
		  }
	  }
    
    ~ .checkbox__label {
      @include apply-child-themes(disabled, color);
      
      color: $checkbox-disabled-color;
    }
  }

	&:focus ~ .checkbox__indicator {
		.checkbox__indicator__ripple {
			animation: ripple 600ms;
		}
	}
	
	&:checked ~ .checkbox__indicator {
    border-color: $checkbox-color;
    
		.checkbox__indicator__bg {
			@include square(100%);
			
			opacity: 1;
			transition: 200ms ease-in-out opacity;
		}
		
		.checkbox__indicator__mark {
			stroke-dashoffset: 0;
		}
	}
	
	&:required ~ .checkbox__label {
		&:after {
			content: '*';
		}
	}
}


.checkbox__indicator {
	@include square($checkbox-size);
  @include apply-child-themes(textSecondary, border-color);
	
  border-color: $checkbox-empty-color;
	border-radius: $checkbox-radius;
	border-style: solid;
	border-width: 2px;
	overflow: visible !important; //override reset
}


.checkbox__indicator--round {
	border-radius: 50%;
	
	.checkbox__indicator__bg {
		cx: 50%;
		cy: 50%;
		r: 50%;
	}
}


.checkbox__indicator__bg {
	@include square(0);

	fill: $checkbox-color;
	opacity: 0;
	transition: 250ms ease-in-out opacity;
	will-change: opacity;
}


.checkbox__indicator__mark {
  @include apply-child-themes(appBackground, stroke);
  
	fill: none;
	stroke: $checkbox-mark-color;
	stroke-width: 2;
	transition: 300ms linear stroke-dashoffset;
}


.checkbox__indicator__ripple {
	fill: $checkbox-color;
	cx: 50%;
	cy: 50%;
	will-change: opacity, r;
}


.checkbox__label {
  @include apply-child-themes(textSecondary, color);
  
	padding: 0 $label-offset;
}
              
            
!

JS

              
                let nextId = 0

function getNextId (prefix='element') {
	return `${prefix}-${nextId++}`
}

const CheckboxIndicator = ({ round }) => {
  const markLength = 15.749618530273438
  
  return (
    <svg viewBox="0 0 16 16" className={`checkbox__indicator ${round && 'checkbox__indicator--round'}`}>
    {
      round
        ? <circle className='checkbox__indicator__bg' />
        : <rect className='checkbox__indicator__bg' />
    }
    <circle className='checkbox__indicator__ripple' />
    <path className='checkbox__indicator__mark jsMark' transform='translate(1, 2)' strokeDashoffset={ markLength } strokeDasharray={ markLength } d="M1.42420783 6.03075103 5.00322799 9.5725669 12.5960318 2.01301652" />
  </svg>
  )
}

const CheckboxLabel = ({ label }) => (
  label && <span className='checkbox__label'>{ label }</span>
)

const Checkbox = ({ required, disabled, name, checked, label, value, round, onChange=()=>{} }) => {
	const elementId = getNextId(),
			isDisabled = disabled ? 'disabled' : false,
			isRequired = required ? 'required' : false,
			isChecked = checked ? 'checked' : false
	
	return (
    <label className='checkbox' htmlFor={ elementId }>
				<input
					onChange={ onChange }
					className='checkbox__input'
					type='checkbox'
					name={ name }
					value={ value }
					required={ isRequired }
					disabled={ isDisabled }
					defaultChecked={ isChecked }
					id={ elementId } />
				<CheckboxIndicator round={ round } />
        <CheckboxLabel label={ label } />
			</label>
  );
}

ReactDOM.render(<Checkbox label='light theme' checked/>, document.getElementById('artboard-1'))

ReactDOM.render(<Checkbox label='dark theme' />, document.getElementById('artboard-2'))

ReactDOM.render(<Checkbox label='round required' round required />, document.getElementById('artboard-3'))

ReactDOM.render(<Checkbox label='round rtl' round />, document.getElementById('artboard-4'))

ReactDOM.render(<Checkbox label='disabled' disabled />, document.getElementById('artboard-5'))

ReactDOM.render(<Checkbox label='disabled' disabled />, document.getElementById('artboard-6'))

ReactDOM.render(<Checkbox label='checked disabled' checked disabled />, document.getElementById('artboard-7'))

ReactDOM.render(<Checkbox label='checked disabled' checked disabled />, document.getElementById('artboard-8'))
              
            
!
999px

Console