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

              
                 <form>
  <header>
    <h3>Example Vanilla Form</h3>
    <p>With just the import from Open Props, this is a great look into the result.</p>
  </header>
  <fieldset id="forms__input">
    <legend>Input fields</legend>
    <div> 
      <label for="input__name">Text Input</label>
      <input id="input__name" name="name" type="text" required placeholder="Name">
    </div>
    <div>
      <label for="input__password">Password</label>
      <input id="input__password" type="password" autocomplete="new-password">
    </div>
    <div>
      <label for="input__webaddress">Web Address</label>
      <input id="input__webaddress" type="url" placeholder="https://yoursite.com" autocomplete="url">
    </div>
    <div>
      <label for="input__emailaddress">Email Address</label>
      <input id="input__emailaddress" type="email" placeholder="name@email.com" autocomplete="email">
    </div>
    <div>
      <label for="input__phone">Phone Number</label>
      <input id="input__phone" type="tel" placeholder="(999) 999-9999">
    </div>
    <div>
      <label for="input__search">Search</label>
      <input id="input__search" type="search" placeholder="Search for flavors" list="searches">
      <datalist id="searches">
        <option value="Chocolate">
        <option value="Vanilla">
        <option value="Strawberry">
      </datalist>
    </div>
    <div>
      <label for="input__text2">Number Input</label>
      <input id="input__text2" type="number" placeholder="100">
    </div>
    <div>
      <label for="input__readonly">Read only</label>
      <input readonly id="input__readonly" type="text" value="Nope!">
    </div>
    <div>
      <label for="input__disabled">Disabled</label>
      <input disabled id="input__disabled" type="text" value="Nope!">
    </div>
    <footer>
      <menu>
        <button type="reset">Reset</button>
      </menu>
      <menu>
        <button type="button">Cancel</button>
        <button>Submit</button>
      </menu>
    </footer>
  </fieldset>
  <fieldset id="forms__select">
    <legend>Select menus</legend>
    <div>
      <label for="select">Pick an option</label>
      <select id="select">
        <optgroup label="Option Group">
          <option>Option One</option>
          <option>Option Two</option>
          <option>Option Three</option>
        </optgroup>
      </select>
    </div>
  </fieldset>
  <fieldset id="forms__checkbox">
    <legend>Checkboxes</legend>
    <ul class="list list--bare">
      <li><label for="checkbox1"><input id="checkbox1" name="checkbox" type="checkbox" checked="checked"> Choice A</label></li>
      <li><label for="checkbox2"><input id="checkbox2" name="checkbox" type="checkbox"> Choice B, something long enough to become multiline</label></li>
      <li><label for="checkbox3"><input id="checkbox3" name="checkbox" type="checkbox"> Choice C</label></li>
    </ul>
  </fieldset>
  <fieldset id="forms__radio">
    <legend>Radio buttons</legend>
    <ul class="list list--bare">
      <li><label for="radio1"><input id="radio1" name="radio" type="radio" class="radio" checked="checked"> Option 1</label></li>
      <li><label for="radio2"><input id="radio2" name="radio" type="radio" class="radio"> Option 2, something long enough to become multiline</label></li>
      <li><label for="radio3"><input id="radio3" name="radio" type="radio" class="radio"> Option 3</label></li>
    </ul>
  </fieldset>
  <fieldset id="forms__textareas">
    <legend>Textareas</legend>
    <textarea id="textarea" rows="8" cols="48" placeholder="Enter your message here"></textarea>
    <footer>
      <menu>
        <button type="reset">Clear</button>
      </menu>
      <menu>
        <button type="button">Cancel</button>
        <button>Send</button>
      </menu>
    </footer>
  </fieldset>
   <fieldset id="forms__alone-fieldset">
    <p>Enter your email address</p>
    <legend>Single input fieldset</legend>
    <input type="email">
  </fieldset>
  <fieldset id="forms__html5">
    <legend>Inputs Extended</legend>
    <div>
      <label for="file-in">File input</label>
      <input type="file" id="file-in">
    </div>
    <div>
      <label for="ic">Color input</label>
      <input type="color" id="ic" value="#5c7cfa">
    </div>
    <div>
      <label for="ir">Range input</label>
      <input type="range" id="ir" value="10">
    </div>
    <div>
      <label for="ir">Progress element</label>
      <progress></progress>
      <progress value=".5" />50%</progress>
    </div>
    <div>
      <label for="idd">Date input</label>
      <input type="date" id="idd" value="1970-01-01">
    </div>
    <div>
      <label for="idm">Month input</label>
      <input type="month" id="idm" value="1970-01">
    </div>
    <div>
      <label for="idw">Week input</label>
      <input type="week" id="idw" value="1970-W01">
    </div>
    <div>
      <label for="idt">Datetime input</label>
      <input type="datetime" id="idt" value="1970-01-01T00:00:00Z">
    </div>
    <div>
      <label for="idtl">Datetime-local input</label>
      <input type="datetime-local" id="idtl" value="1970-01-01T00:00">
    </div>
  </fieldset>
</form>
              
            
!

CSS

              
                @use postcss-nested;
@import "https://unpkg.com/open-props";
@import "https://unpkg.com/open-props/normalize.min.css";
@import "https://unpkg.com/open-props/buttons.min.css";

/* 
todo:
- sprite sheet icons (light/dark) for single request
- :placeholder-shown
- :in-range, etc https://codepen.io/argyleink/pen/RwKMdWy
- label underline to be a dot
- demo should have nested forms so resets are scoped
- invalid/required more specific demo
*/

fieldset {
  padding-inline: var(--size-4);
  padding-block: var(--size-2) var(--size-3);
  
  &:focus-within > legend {
    color: var(--link);
  }
  
  & > div:focus-within > label {
    text-decoration: underline;
    text-decoration-color: var(--link);
    text-underline-offset: .25ex;
  }
}

:where(input:not(
  button,
  [type="button"], 
  [type="file"], 
  [type="number"],
  [type="range"],
  [type="color"],
  [type="checkbox"],
  [type="radio"]
)) {
  /*  consider a bg sprite that each state matches a bg position. animate the positional change.  */
  /* todo: touch-callout */
  padding-block: .75ch;
  padding-inline: 1.75ch;
  /* todo: remove border from file input */
  transition: background-color .5s var(--ease-3);
  
  :placeholder-shown {
    text-overflow: ellipsis;
  }
}

:where(input:not(
  button, 
  input[type="button"], 
/*   input[type="file"],  */
  input[type="range"],
  input[type="color"],
  input[type="checkbox"],
  input[type="radio"]
), textarea) {
  box-shadow: var(--shadow-2), 0 0 1px 1px var(--surface-2);
  
  @media (prefers-color-scheme: dark) {
    box-shadow: var(--inner-shadow-2);
  }
}

input:not(
  button, 
  [disabled], 
  [readonly], 
  [type="file"], 
  [type="button"], 
  [type="submit"], 
  [type="reset"],
  [type="checkbox"],
  [type="radio"]), 
  textarea, 
  select {
  color: var(--text-1);
  
  @media (prefers-color-scheme: light) {
    background-color: white;
/*     border: var(--border-size-1) solid var(--surface-2); */
  }
  
  &:is(:hover, :focus-within) {
    background-color: white;
    
    @media (prefers-color-scheme: dark) {
      background-color: hsl(204deg 25% 5%);
    }
  }
  
/*   &:valid {
    color: green;
  } */

  &:not(:focus-visible,:required):invalid {
    text-decoration: underline wavy var(--red-6);
  }

  &:not(:focus-visible):invalid:required {
/*     outline: 2px solid red; */
    /*   todo: box-shadow props so inner/outer stays   */
    box-shadow: var(--shadow-2), 0 0 1px 1px var(--surface-2), inset 0 -4px 0 -2px var(--red-6);
    background-image: url(https://api.iconify.design/ic:baseline-error.svg?color=%23ffffff);
    background-position: calc(100% - 1.5ch) center;
    
    @media (prefers-color-scheme: dark) {
      box-shadow: inset 0 -4px 0 -2px var(--red-6);
    }
  }
}

input[readonly],
input[disabled] {
  cursor: not-allowed;
}

[disabled] {
  opacity: .5;
  box-shadow: none;
}

input[type="number"] {
  padding-block: .75ch;
  padding-inline: 1.75ch .75ch;
  inline-size: 10ch;
}

input[type="search"] {
  background-image: url(https://api.iconify.design/ic:search.svg?color=%23cccccc);
  background-position: 1.5ch center;
  padding-inline: 4ch 0;
  border-radius: var(--radius-round);
  
  &[list]:placeholder-shown {
    background-image: 
      url(https://api.iconify.design/ic:search.svg?color=%23cccccc),
      url(https://api.iconify.design/ic:keyboard-arrow-down.svg?color=%23cccccc);
    background-position: 1.5ch center, calc(100% - 1.25ch) center;
    background-size: auto, 2.25ch;
  }
  
  &::-webkit-calendar-picker-indicator {
    color: transparent;
  }
}

input[type="password"] {
  background-image: url(https://api.iconify.design/ic:lock.svg?color=%23cccccc);
  background-position: calc(100% - 1.5ch) center;
  padding-inline-end: 3.5ch;
}

input[type="email"] {
  background-image: url(https://api.iconify.design/ic:email.svg?color=%23cccccc);
  background-position: calc(100% - 1.5ch) center;
  padding-inline-end: 3.5ch;
}

input[type="url"] {
  background-image: url(https://api.iconify.design/ic:link.svg?color=%23cccccc);
  background-position: calc(100% - 1.5ch) center;
  padding-inline-end: 3.5ch;
}

input[type="tel"] {
  max-inline-size: 18ch;
  background-image: url(https://api.iconify.design/ic:phone.svg?color=%23cccccc);
  background-position: calc(100% - 1.5ch) center;
  padding-inline-end: 3.5ch;
}

input[type="color"] {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  inline-size: var(--size-8);
  block-size: var(--size-8);
  border-radius: var(--radius-round);
  overflow: hidden;
  box-shadow: var(--shadow-5);
  
  &::-webkit-color-swatch-wrapper {
    padding: 0;
  }
}

textarea {
  transition: background-color .5s var(--ease-3);
}

select {
  /*  todo: share more with buttons  */
  /*  todo: share icon prop with search  */
  --_bg-light: #fff;
  --_bg-dark: var(--surface-3);
  --_bg: var(--_bg-light);
  background-color: var(--_bg);
  box-shadow: var(--shadow-3), 0 1px var(--surface-3);
  
  appearance: none;
  /*  use adaptive link color for svg  */
  background-image: url(https://api.iconify.design/ic:keyboard-arrow-down.svg?color=%23cccccc);
  background-position: calc(100% - 1ch) center;
  background-size: 2.25ch;
  padding-block: 0.75ch;
  padding-inline: 1.75ch;
  line-height: 1.5;
  
  &:is(:hover,:focus) {
    /* add button hover */
    background-color: var(--_bg);
/*     background-position-y: 55%; */
  }
  
  @media (prefers-color-scheme: dark) {
    --_bg: var(--_bg-dark);
  }
}

input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text-1);
  -webkit-box-shadow: 0 0 0px 1e5px hsl(204deg 25% 5%) inset;
  transition: background-color 5000s ease-in-out 0s;
}

::placeholder {
  color: var(--gray-5);
  
  @media (prefers-color-scheme: dark) {
    color: var(--surface-4);
  }
}

fieldset, form > header {
  display: grid;
  gap: var(--size-2);
}

form {
  display: grid;
  gap: var(--size-4);
}

legend {
  margin-inline-start: -2px;
  color: var(--text-2);
  font-weight: var(--font-weight-6);
}

fieldset {
  max-inline-size: max-content;
  
  @media (max-width: 520px) {
    gap: var(--size-4);
  }
  
  & > div {
    display: flex;
    flex-wrap: wrap;
    gap: var(--size-1) var(--size-3);
    align-items: center;
    
    & > label {
      flex-grow: 1;
    }
  }
  
  & label {
    inline-size: var(--size-content-1);
  }
  
  & > footer {
    display: flex;
    justify-content: space-between;
    gap: var(--size-3);
    margin-block-start: var(--size-6);
    
    & > menu:only-child {
      margin-inline-start: auto;
    }
  }
  
  & > ul {
    padding: 0;
    margin: 0;
    list-style-type: none;
    display: grid;
    gap: var(--size-2);
    
    & > li {
      padding: 0;
      
      & > label {
        display: inline-flex;
        align-items: baseline;
        gap: var(--size-4);
        max-inline-size: var(--size-content-1);
        
        & > input {
          margin-inline-start: 0;
          flex-shrink: 0;
        }
      }
    }
  }
}

:where(
  input[type="checkbox"],
  input[type="radio"]
) {
  box-shadow: var(--shadow-6);
  transform-style: preserve-3d;
  cursor: pointer;
  
  --isLTR: 1;
  --isRTL: -1;
  
  &:dir(rtl) {
    --isLTR: -1;
    --isRTL: 1;
  }

  &:hover::before {
    --thumb-scale: 1;
  }

  @media (hover: none) {
    inline-size: 1.5rem;
    block-size: 1.5rem;
  }

  &::before {
    --thumb-scale: .01;
    --thumb-highlight-size: 225%;

    content: "";
    inline-size: var(--thumb-highlight-size);
    block-size: var(--thumb-highlight-size);
    clip-path: circle(50%);
    position: absolute;
    inset-block-start: 50%;
    inset-inline-start: 50%;
    background: hsl(0 0% 50% / 20%);
    transform-origin: center center;
    transform: 
      translateX(calc(var(--isRTL) * 50%)) 
      translateY(-50%) 
      translateZ(-1px) 
      scale(var(--thumb-scale))
    ;
    will-change: transform;

    @media (prefers-reduced-motion: no-preference) {
      transition: transform .2s ease;
    }
  }
}

@media (pointer: coarse) {
  input[type="checkbox"],
  input[type="radio"]{
    inline-size: var(--size-4);
    block-size: var(--size-4);
  }
}








body {
  display: grid;
  place-content: center;
  padding: var(--size-5);
  gap: var(--size-5);
}

.buttons-list {
  display: flex;
  gap: var(--size-3);
}
              
            
!

JS

              
                
              
            
!
999px

Console