Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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 id="app"></div>
    <a
      class="bear-link"
      href="https://twitter.com/intent/follow?screen_name=jh3yy"
      target="_blank"
      rel="noreferrer noopener"
    >
      <svg
        class="w-9"
        viewBox="0 0 969 955"
        fill="none"
        xmlns="http://www.w3.org/2000/svg"
      >
        <circle
          cx="161.191"
          cy="320.191"
          r="133.191"
          stroke="currentColor"
          stroke-width="20"
        ></circle>
        <circle
          cx="806.809"
          cy="320.191"
          r="133.191"
          stroke="currentColor"
          stroke-width="20"
        ></circle>
        <circle
          cx="695.019"
          cy="587.733"
          r="31.4016"
          fill="currentColor"
        ></circle>
        <circle
          cx="272.981"
          cy="587.733"
          r="31.4016"
          fill="currentColor"
        ></circle>
        <path
          d="M564.388 712.083C564.388 743.994 526.035 779.911 483.372 779.911C440.709 779.911 402.356 743.994 402.356 712.083C402.356 680.173 440.709 664.353 483.372 664.353C526.035 664.353 564.388 680.173 564.388 712.083Z"
          fill="currentColor"
        ></path>
        <rect
          x="310.42"
          y="448.31"
          width="343.468"
          height="51.4986"
          fill="#FF1E1E"
        ></rect>
        <path
          fill-rule="evenodd"
          clip-rule="evenodd"
          d="M745.643 288.24C815.368 344.185 854.539 432.623 854.539 511.741H614.938V454.652C614.938 433.113 597.477 415.652 575.938 415.652H388.37C366.831 415.652 349.37 433.113 349.37 454.652V511.741L110.949 511.741C110.949 432.623 150.12 344.185 219.845 288.24C289.57 232.295 384.138 200.865 482.744 200.865C581.35 200.865 675.918 232.295 745.643 288.24Z"
          fill="currentColor"
        ></path>
      </svg>
    </a>
              
            
!

CSS

              
                @layer demo {
  ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1ch;
    flex-wrap: wrap;
    transition: all var(--transition);
  }

  :root {
    --selected: hsl(20, 97%, 62%);
    --transition: 0.875s;
    --bg: light-dark(white, black);
    --intentful: light-dark(color-mix(in lch, canvas, canvasText 15%), black);
    --ease: linear(0 0%,
      0.6832 7.89%,
      0.9171 11.07%,
      1.0251 12.99%,
      1.1058 14.9%,
      1.1619 16.86%,
      1.1945 18.91%,
      1.2024 20.02%,
      1.2043 21.18%,
      1.1907 23.72%,
      1.1598 26.27%,
      1.0604 32.59%,
      1.0172 35.84%,
      0.9839 39.49%,
      0.967 43.26%,
      0.9639 45.77%,
      0.9661 48.59%,
      0.9963 60.54%,
      1.0054 67.42%,
      1 100%
    );
  }

  label {
    --active: 0;
    --intent: 0;
    --accent: color-mix(in lch, canvasText, canvas 25%);
    --backdrop: light-dark(white, black);
    padding: 1ch 2ch;
    background: color-mix(in lch, canvas, canvasText calc(var(--intent) * 10%));
    color: var(--accent);
    border-radius: 100px;
    border: 1px solid color-mix(in lch, var(--accent), #0000 50%);
    display: grid;
    grid-template-columns: auto calc(var(--active) * 20px);
    cursor: pointer;
    align-items: center;
    line-height: 1.25;
    transition: color, grid-template-columns;
    transition-duration: calc(var(--transition) * 0.5), var(--transition);
    transition-timing-function: var(--ease);
    position: relative;
    outline: 0px solid color-mix(in lch, canvas, canvasText 85%);
    outline-offset: 2px;
  }

  label::after {
    content: '';
    opacity: var(--active, 0);
    position: absolute;
    inset: -1px;
    border: 1px solid var(--selected);
    background: color-mix(in lch, var(--selected), #0000 80%);
    border-radius: 100px;
    z-index: 2;
    pointer-events: none;
    transition: opacity var(--transition) var(--ease);
  }

  label span::selection {
    background: transparent;
  }

  label:has(:focus-visible),
  label:hover {
    &:not(:has(:checked)) {
      --intent: 1;
    }
  }

  label:has(:focus-visible) {
    outline-width: 2px;
  }

  label:has(:checked) {
    --active: 1;
    color: var(--selected);
  }

  label span {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
  }

  label svg {
    opacity: var(--active, 0);
    justify-self: flex-end;
    position: absolute;
    width: 100%;
    left: 0.75ch;
    transition-property: opacity;
    transition-duration: var(--transition);
    transition-timing-function: var(--ease);
  }

  form {
    position: relative;
  }

  [type='reset'] {
    --intent: 0;
    position: absolute;
    top: calc(100% + 1rem);
    left: 50%;
    translate: -50% 0;
    padding: 0.75rem 1.5rem;
    border-radius: 100px;
    align-self: center;
    background: color-mix(
      in lch,
      #0000,
      var(--intentful) calc(var(--intent) * 25%)
    );
    border: 0;
    cursor: pointer;
    font-size: 12px;
    color: color-mix(
      in lch,
      #0000,
      canvasText calc((25 + (var(--intent) * 50)) * 1%)
    );

    transition-property: color, background;
    transition-duration: 0.2s;

    &:hover {
      --intent: 1;
    }
  }
}

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

html {
  color-scheme: light dark;
}

[data-theme='light'] {
  color-scheme: light only;
}

[data-theme='dark'] {
  color-scheme: dark only;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family: 'SF Pro Text', 'SF Pro Icons', 'AOS Icons', 'Helvetica Neue',
    Helvetica, Arial, sans-serif, system-ui;
}

body::before {
  --size: 45px;
  --line: color-mix(in lch, canvasText, transparent 70%);
  content: '';
  height: 100vh;
  width: 100vw;
  position: fixed;
  background: linear-gradient(
        90deg,
        var(--line) 1px,
        transparent 1px var(--size)
      )
      50% 50% / var(--size) var(--size),
    linear-gradient(var(--line) 1px, transparent 1px var(--size)) 50% 50% /
      var(--size) var(--size);
  mask: linear-gradient(-20deg, transparent 50%, white);
  top: 0;
  transform-style: flat;
  pointer-events: none;
  z-index: -1;
}

.bear-link {
  color: canvasText;
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 48px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  opacity: 0.8;
}

:where(.x-link, .bear-link):is(:hover, :focus-visible) {
  opacity: 1;
}

.bear-link svg {
  width: 75%;
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  width: 62ch;
  max-width: calc(100vw - 2rem);
}

legend {
  font-weight: 600;
  font-size: 1.25rem;
  margin-bottom: 1rem;
  padding-inline: 0.5ch;
}

              
            
!

JS

              
                import { Pane } from 'https://cdn.skypack.dev/tweakpane'
import React from 'https://cdn.skypack.dev/react'
import { render } from 'https://cdn.skypack.dev/react-dom'

const config = {
  theme: 'system',
}

const ctrl = new Pane({
  title: 'Config',
  expanded: true,
})

ctrl.addBinding(config, 'theme', {
  options: {
    System: 'system',
    Light: 'light',
    Dark: 'dark',
  },
  label: 'Theme',
})

const update = () => {
  document.documentElement.dataset.theme = config.theme
}

const sync = () => {
  if (!document.startViewTransition) update()
  document.startViewTransition(() => update())
}

ctrl.on('change', sync)

update()

const ROOT_NODE = document.querySelector('#app')
const CUISINES = [
  'Italian',
  'Chinese',
  'Indian',
  'American',
  'Mexican',
  'Japanese',
  'Thai',
  'Turkish',
  'Greek',
  'Spanish',
  'Mediterranean',
  'British',
  'Korean',
  'Vietnamese',
  'French',
  'Caribbean',
  'Lebanese',
  'Brazilian',
  'Ethiopian',
  'German',
  'Cuban',
  'Moroccan',
  'Russian',
  'Argentinian',
  'Peruvian',
  'Filipino',
]

const App = () => {
  return (
    <form onSubmit={(event) => event.preventDefault()}>
      <fieldset>
        <legend>What are your favorite cuisines?</legend>
        <ul>
          {CUISINES.map((cuisine) => {
            return (
              <li key={cuisine}>
                <label>
                  <span>{cuisine}</span>
                  <span>
                    <svg
                      aria-hidden="true"
                      xmlns="http://www.w3.org/2000/svg"
                      viewBox="0 0 24 24"
                      fill="currentColor">
                      <path
                        fill-rule="evenodd"
                        d="M2.25 12c0-5.385 4.365-9.75 9.75-9.75s9.75 4.365 9.75 9.75-4.365 9.75-9.75 9.75S2.25 17.385 2.25 12Zm13.36-1.814a.75.75 0 1 0-1.22-.872l-3.236 4.53L9.53 12.22a.75.75 0 0 0-1.06 1.06l2.25 2.25a.75.75 0 0 0 1.14-.094l3.75-5.25Z"
                        clip-rule="evenodd"
                      />
                    </svg>
                  </span>
                  <input className="sr-only" type="checkbox" />
                </label>
              </li>
            )
          })}
        </ul>
      </fieldset>
      <button type="reset">Reset</button>
    </form>
  )
}

render(<App />, ROOT_NODE)

              
            
!
999px

Console