css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <todos-app></todos-app>
            
          
!
            
              html {
	background: #e2e1e0;
	box-shadow: inset 0px 0px 5vw 0px rgba(0,0,0,0.75);
	min-height: 100vh;
}
* {
  font-family: "Helvetica Neue", Arial, Helvetica, Geneva, sans-serif;
	margin: 0;
	padding: 0;
	box-sizing: box-shadow;
}

todos-app {
  max-width: 450px;
	display: block;
	background: #fafafa;
	margin: 6vh auto;
	box-shadow: 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
}
h1 {
	font-size: 24px;
	margin: 0 0 15px 2px;
	padding: 30px 30px 0;
}

#editor {
  position: relative;
  height: 24px;
}

#editor > * {
    display: block;
    position: absolute;
}

#editor > input[type=text] {
    height: 18px;
    font-size: 1px;
    font-family: Arial;
    left: 18px;
    right: 28px;
}

#editor > .spinner {
    top: 0px;
    right: 4px;
    width: 16px;
    cursor: pointer;
    color: #4169be;
    font-weight: bold;
}

#editor > .spinner.hidden {
    display: none;
}

todos-app > input {
	font-size: 21px;
	font-family: Arial, sans-serif;
	padding: 10px;
	margin-left: 5%;
	width: 60%;
}
todos-app > input + button {
	font-size: 21px;
	font-family: Arial, sans-serif;
	padding: 10px;
	justify-content: flex-end;
	font-weight: bold;
	width: 20%;
	margin-left: 2.5%;
	margin-right: 5%;
	color: white;
	background: cornflowerblue;
	border: none;
	transition: all .25s ease-in-out;
	&:hover {
		background: midnightblue;
		color: white;
	}
}

ul {
    list-style: none;
    padding-left: 0;
    padding-top: 15px;
}
li {
	display: flex;
	align-items: center;
	text-align: left;
  position: relative;
  padding: 10px 30px;
	border-bottom: 1px dotted rgba(0,0,0,.25);
	font-size: 14px;
	transition: all .3s ease-in-out;
	&:last-of-type {
		border-bottom: none;
	}
}
li:hover {
    background-color: #eeeeee;
}
li > span, li > input[type="text"] {
	margin-right: auto;
	margin-left: 15px;
	font-size: 21px;
	padding: 20px;
}
li > input[type="text"] {
	position: relative;
	margin-left: 30px;
	padding: 20px 5px;
	flex: 1;
}
li > span.done {
  text-decoration: line-through;
	color: lightgray;
	font-style: italic;
	letter-spacing: 1px;
}
span + button {
	display: flex;
	position: absolute;
	right: 30px;
  width: 25px;
  height: 25px;
  line-height: 25px;
  border: 1px solid lightgray;
  border-radius: 50%;
	text-align:center;
  text-decoration: none;
	transition: all .25s ease-in-out;
	cursor: default;
	&:before, &:after {
		position: absolute;
		top: 5px;
		left: 11px;
		content: ' ';
		height: 13px;
		width: 1px;
		background-color: lightgray;
	}
	&:hover {
		border-color: #a30000;
		background-color: #a30000;
		color: white;
		&:before, &:after {
			background-color: white;
		}
	}
}
span + button:before {
  transform: rotate(45deg);
}
span + button:after {
  transform: rotate(-45deg);
}
li > input[type="checkbox"] {
    position: relative;
    display: inline-block;
    
    /*16px width of fake checkbox + 6px distance between fake checkbox and text*/
    padding-left: 30px;
}

li > input[type="checkbox"]::before,
li > input[type="checkbox"]::after {
    position: absolute;
    content: "";
}

/*Outer box of the fake checkbox*/
li > input[type="checkbox"]::before{
	height: 24px;
	width: 24px;
	background: #FFFFFF;
	box-shadow: 0px 0px 0px 3px rgba(0,0,0,0.5);
	left: 0px;
	top: -7px;
	border-radius: 3px;
	cursor: pointer;
}

/*Checkmark of the fake checkbox*/
li > input[type="checkbox"]::after {
	height: 6px;
	width: 18px;
	border-left: 3px solid;
	border-bottom: 3px solid;
	transform: rotate(-45deg);
	left: 2px;
	top: -1px;
	cursor: pointer;
}

/*Hide the checkmark by default*/
li > input[type="checkbox"]::after {
    content: none;
}

/*Unhide on the checked state*/
li > input[type="checkbox"]:checked::after {
    content: "";
}

/*Adding focus styles on the outer-box of the fake checkbox*/
li > input[type="checkbox"]:focus::before {
    outline: rgb(59, 153, 252) auto 5px;
}
            
          
!
            
              // Creates a mock backend with 3 todos
import { todoFixture } from "//unpkg.com/can-demo-models@5";
todoFixture(3);

import { Component, realtimeRestModel } from "//unpkg.com/can@5/core.mjs";

const Todo = realtimeRestModel("/api/todos/{id}").Map;

Component.extend({
	tag: "todos-app",
	view: `
		<h1>Today’s to-dos</h1>
		{{#if(this.todosPromise.isPending)}}
			Loading todos…
		{{/if}}
		{{#if(this.todosPromise.isRejected)}}
			<p>Couldn’t load todos; {{this.todosPromise.reason}}</p>
		{{/if}}
		{{#if(this.todosPromise.isResolved)}}
			<input placeholder="What needs to be done?" value:bind="this.newTodoName" />
			<button on:click="this.save()" type="button">Add</button>
			<ul>
				{{#for(todo of this.todosPromise.value)}}
					<li>
						<input checked:bind="todo.complete" on:change="todo.save()" type="checkbox" />
						{{#eq(todo, this.selectedTodo)}}
							<input focused:from="true" on:blur="this.saveTodo(todo)" type="text" value:bind="todo.name" />
						{{else}}
							<span class="{{#if(todo.complete)}}done{{/if}}" on:click="this.selectedTodo = todo">{{todo.name}}</span>
						{{/eq}}
						<button on:click="todo.destroy()" type="button"></button>
					</li>
				{{/for}}
			</ul>
		{{/if}}
	`,
	ViewModel: {
		newTodoName: "string",
		selectedTodo: Todo,
		get todosPromise() {
			return Todo.getList({sort: "name"});
		},
		save() {
			const todo = new Todo({name: this.newTodoName});
			todo.save();
			this.newTodoName = "";
		},
		saveTodo(todo) {
			todo.save();
			this.selectedTodo = null;
		}
	}
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console