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

              
                 <!-- <svg style="display: none">
  <symbol id="checkmark" viewBox="0 0 24 24">
    <path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12c0 1.268-.63 2.39-1.593 3.068a3.745 3.745 0 01-1.043 3.296 3.745 3.745 0 01-3.296 1.043A3.745 3.745 0 0112 21c-1.268 0-2.39-.63-3.068-1.593a3.746 3.746 0 01-3.296-1.043 3.745 3.745 0 01-1.043-3.296A3.745 3.745 0 013 12c0-1.268.63-2.39 1.593-3.068a3.745 3.745 0 011.043-3.296 3.746 3.746 0 013.296-1.043A3.746 3.746 0 0112 3c1.268 0 2.39.63 3.068 1.593a3.746 3.746 0 013.296 1.043 3.746 3.746 0 011.043 3.296A3.745 3.745 0 0121 12z" />
  </symbol>
</svg>  -->

<!-- <select>
  <option value="">foo</option>
  <option value="">bar</option>
  <option value="">baz</option>
</select>

<select multiple style="inline-size: 10ch;">
  <option value="">foo</option>
  <option value="">bar</option>
  <option value="">baz</option>
</select>

<select multiple style="inline-size: 10ch;">
  <optgroup label="Group 1">
    <option value="">foo</option>
  </optgroup>
  <optgroup label="Group 2">
    <option value="">bar</option>
    <option value="">baz</option>
  </optgroup>
</select>

<selectlist>
  <option value="">foo</option>
  <option value="">bar</option>
  <option value="">baz</option>
</selectlist>

<selectlist multiple>
  <option value="">foo</option>
  <option value="">bar</option>
  <option value="">baz</option>
</selectlist> --> 

<selectlist>
  <button type=selectlist>
    <div>
      <selectedoption></selectedoption>
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path fill="currentColor" d="m7 10l5 5l5-5z"/>
      </svg>
    </div>
  </button>
  <listbox popover=auto>
    <option>
      <!-- custom so it's fully consumed for selectedoption -->
      <div class="custom-option">
        <span class="indicator success"></span>
        <span class="option-text">On</span>
      </div>
    </option>
    <option>
      <div class="custom-option">
        <span class="indicator danger"></span>
        <span class="option-text">Off</span>
      </div>
    </option>
    <option>
      <div class="custom-option">
        <span class="indicator disable"></span>
        <span class="option-text">Disable</span>
      </div>
    </option>
  </listbox>
</selectlist>

<selectlist>
  <button type=selectlist>
    <div>
      <selectedoption></selectedoption>
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path fill="currentColor" d="m7 10l5 5l5-5z"/>
      </svg>
    </div>
  </button>
  <listbox popover=auto>
    <option>
      <div class="custom-option">
        <span class="avatar">
          <img width="20" height="20" src="https://pbs.twimg.com/profile_images/1587634978308997121/u7009cGe_400x400.jpg" alt="">
        </span>
        <span class="option-text">Una Kravets</span>
      </div>
    </option>
    <option>
      <div class="custom-option">
        <span class="avatar">
          <img width="20" height="20" src="https://pbs.twimg.com/profile_images/1276240813333401600/brd0hSfW_400x400.jpg" alt="">
        </span>
        <span class="option-text">Bramus Van Damme</span>
      </div> 
    </option>
    <option>
      <div class="custom-option">
        <span class="avatar">
          <img width="20" height="20" src="https://pbs.twimg.com/profile_images/1720589781476982784/P9Ld4vC5_400x400.jpg" alt="">
        </span>
        <span class="option-text">Adam Argyle</span>
      </div>
    </option>
  </listbox>
</selectlist>

<selectlist id="colorspace">
  <button type=selectlist>
    <small>Color Space</small>
    <div>
      <selectedoption style="view-transition-name: foo"></selectedoption>
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path fill="currentColor" d="m7 10l5 5l5-5z"/>
      </svg>
    </div>
  </button> 
  <listbox popover=auto>
    <div role="group">
      <label>Standard</label>
      <option value="srgb">rgb</option>
      <option>srgb-linear</option>
      <option>hsl</option>
      <option>hwb</option>
    </div>
    <div role="group">
      <label>HD</label>
      <option>display-p3</option>
      <option>a98-rgb</option>
    </div>
    <div role="group">
      <label>Ultra HD</label>
      <option>lab</option>
      <option>lch</option> 
      <option selected>oklch</option>
      <option>oklab</option>
      <option>rec2020</option>
      <option>prophoto</option>
      <option>xyz</option>
      <option>xyz-d50</option>
      <option>xyz-d65</option>
    </div>
  </listbox>
</selectlist>

<selectlist class="primary">
  <button type=selectlist>
    <div>
      <selectedoption></selectedoption>
      <svg width="24" height="24" viewBox="0 0 24 24">
        <path fill="currentColor" d="m7 10l5 5l5-5z"/>
      </svg>
    </div>
  </button>
  <listbox popover=auto>
    <option>
      <div class="custom-option">
        <div>Published</div>
        <div class="description">Live on the web, available to anyone with the link.</div>
      </div>
    </option>
    <option>
      <div class="custom-option">
        <div>Draft</div>
        <div class="description">Not available on the web, no public access.</div>
      </div> 
    </option>
  </listbox>
</selectlist>

<div id="support">
  <p>Your browser doesn't support <code>selectlist</code> elements yet.</p>
</div>
              
            
!

CSS

              
                @import "https://unpkg.com/open-props" layer(design.system);
@import "https://unpkg.com/open-props/normalize.min.css" layer(demo.support);
@import "https://unpkg.com/open-props/buttons.min.css" layer(demo.support);

@layer demo {
  selectlist {
    font-size: var(--font-size-1);
    
    > button {
      --_text: var(--text-1);
      
      &:has(selectedoption) {
        align-items: start;
        min-inline-size: 20ch;
        flex-direction: column;
      }
      
      > div {
        inline-size: 100%;
        display: flex;
        justify-content: space-between;
        gap: var(--size-3);
      }
      
      & > small {
        color: var(--text-2);
      }
      
      & svg {
        inline-size: 2ch;
        transition: transform .3s var(--ease-elastic-out-2);
      }
    }
    
    &.primary > button {
      --_bg: var(--link);
      --_border: none;
      --_text: var(--surface-1);
      --_ink-shadow: none;
    }
    
    &:open > button svg {
      transform: rotate(.5turn);
    }
    
    > listbox {
      min-inline-size: calc(anchor-size(self-inline) + 20px);
      margin-block-start: var(--size-2);
      background: var(--surface-2);
/*       box-shadow: var(--shadow-5); */
      border-radius: var(--radius-2);
      padding: 0;
      scroll-behavior: smooth;
      
      opacity: 0;
      clip-path: inset(0 0 100% 0);
      clip-path: circle(0% at top left);
/*       clip-path: polygon(0 0, 50% 50%, 100% 100%, 50% 50%); */
      transition: 
        opacity .1s ease,
        clip-path 0s var(--ease-out-3) .1s, 
        display .1s allow-discrete, 
        overlay .1s allow-discrete
      ;
      
      @media (prefers-color-scheme: light) {
        background: white;
        border: 1px solid var(--surface-2);
      }
      
      &:popover-open {
        transition-duration: 0s, .4s, .4s, .4s;
        opacity: 1;
        clip-path: inset(0 0 0 0);
        clip-path: circle(150% at top left);
        
        @starting-style {
          opacity: 0;
          clip-path: inset(0 0 100% 0);
          clip-path: circle(0% at top left);
        }
      }
      
      & hr {
        margin-block: var(--size-2);
      }
      
      & label {
        display: block;
        position: sticky;
        top: 0;
        z-index: 1;
        background: var(--surface-3);
        font-size: var(--font-size-0);
        color: var(--text-2);
        font-weight: var(--font-weight-7);
        padding-block: var(--size-1);
        padding-inline: var(--size-3);
      }
      
      & option {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: var(--size-3);
        padding-block: var(--size-2);
        padding-inline: var(--size-3);
        margin-block: 1px;
        font-size: var(--font-size-1);
        
        cursor: pointer;
        outline-offset: -1px;
        
        &:focus-visible {
          outline-offset: -1px;
        }
        
        &:is(:focus, :hover) {
/*           background: AccentColor;
          color: AccentColorText; */
          background: oklch(from var(--link) l c h / 25%);
          color: inherit;
        }
        
        &:is(:checked) {
          background: var(--link);
          color: var(--surface-1);
          font-weight: var(--font-weight-8);
          
          &::after {
            content: "";
            block-size: var(--size-4);
            aspect-ratio: 1;
            background: url(https://api.iconify.design/ic:round-check.svg);
            background-size: contain;
          }
        }
      }
    }
  }
}

@layer demo.support {
  body {
    display: grid;
    place-items: start;
    place-content: center;
    padding: var(--size-5);
    gap: var(--size-5);
  }
  
  .custom-option {
    display: flex;
    gap: var(--size-3);
    align-items: center;
    justify-content: space-between;
    
    listbox &:has(.description) {
      display: grid;
      justify-items: start;
      gap: var(--size-2);
      padding-block: var(--size-2);
      text-shadow: none;
      
      & .description {
        color: var(--text-2);
      }
    }
    
    option:is(:checked) & .description {
      font-weight: normal;
      color: var(--surface-2);
    }
    
    selectedoption & .description {
      display: none;
    }
  }
  
  .indicator {
    display: inline-block;
    block-size: var(--size-2);
    inline-size: var(--size-2);
    border-radius: var(--radius-round);
    background: var(--gray-5);
    
    &.success {
      background: var(--green-5);
    }
    
    &.danger {
      background: var(--red-5);
    }
  }
  
  .option-text {
    flex: 2;
  }
  
  .avatar {
    border-radius: var(--radius-round);
    overflow: hidden;
  }
}

#support {
  position: fixed;
  inset: 0;
  background: var(--surface-1);
  display: grid;
  place-content: center;
  
  .supports-selectlist & {
    display: none;
  }
}
              
            
!

JS

              
                document.body.classList.toggle('supports-selectlist', "HTMLSelectListElement" in window)

colorspace.oninput = e => {
  console.log(colorspace.value)
}
              
            
!
999px

Console