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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                
              
            
!

CSS

              
                :root{
  --white: #d3d5d7;
  --black: #19191c;
  --text: #c3c5c7;
}

*, *:before, *:after {
  box-sizing: border-box;
}

html{
  font: 18px monospace;
}

body{
  min-height: 100vh;
  text-rendering: optimizeSpeed;
  line-height: 1.5;
  color: var(--text);
  text-align: center;
}

img,
picture {
  max-width: 100%;
  display: block;
}

a:not([class]) {
  text-decoration-skip-ink: auto;
}

html{
  background: var(--black);
  font: 18px sans-serif;
}

body{
  text-align: center;
}

h1, h2{
  font-family: sans-serif;
  text-transform: uppercase;
  display: block;
  letter-spacing: 0.3em;
  text-align: center;
  font-size: 48px; 
  color: var(--white);
  display: inline-block;
  margin: 0;
}

h2{
  display: block;
  font-size: 32px;
  color: var(--white);
}

textarea, input{
  background: var(--black);
  color: var(--white);
  font-size: 24px;
  padding: 16px;
  border: none;
  border-radius: 8px;
  outline: none;
  display: flex;
  margin: 0 auto;
}

button{
  color: var(--white);
  background: transparent;
  border: 1px var(--white) solid;
  padding: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  min-width: 10em;
  margin: 4px;
  display: block;
  margin: 0 auto;
}

button:hover, button:active, button:focus{
  background: var(--white);
  color: var(--black);
}

p{
  max-width: 40em;
  margin: 1em auto;
}

button{
  display: inline-block;
  margin: 4px auto;
}
              
            
!

JS

              
                import { Nanny,html } from 'https://cdn.skypack.dev/nanny-state'

const View = state => html`
<h1>True or False?</h1>
<h2>Score: ${state.score}</h2>
${state.index < state.questions.length ?
html`<p>${state.index + 1}) ${state.questions[state.index].question}</p>
     <button onclick=${state.checkAnswer(true)}>TRUE</button>
     <button onclick=${state.checkAnswer(false)}>FALSE</button>`
:
html`<h2>Game Over, you scored ${state.score}</h2>`
}`

const checkAnswer = answer => event => Update(state => ({
    score: answer === state.questions[state.index].answer ? state.score + 1 : state.score,
    index: state.index + 1
}))

const State = {
  score: 0,
  index: 0,
  questions: [
    {question: "A Nanny State is a country where nannies are employed by the state", answer: false},
    {question: "Nanny State is also the name of a beer", answer: true},
    {question: "Mila Kunis and Ashton Kutcher employ 16 nannies to look after their children", answer: false},
    {question: "The Nanny McPhee films are based on the Nurse Matilda books", answer: true},
    {question: "Nanny State uses the µhtml library for rendering", answer: true},
],
  checkAnswer,
  View
}

const Update = Nanny(State)
              
            
!
999px

Console