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 class="center">

<div class="splitbutton">
<input type="button" value="Primary" onclick="alert('primary');" />
<select onchange="alert(this.value); this.value='primary';">
  <option value="primary" hidden>Primary</option>
  <option value="secondary">Secondary</option>
  <option value="alternative">Alternative</option>
</select>
</div>

  
  <p><a href="https://web.dev/shows/gui-challenges/Qcpru-fIgwk/">GUI challenge?</a><br />Maybe...</p>
</div>
              
            
!

CSS

              
                body {
  background: #f5f8f9;
  font-family: sans-serif;
  line-height: 1.5rem;
}
.center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.center p, .center p a {color: gray;}
.splitbutton {
  position: relative; 
  display: inline-block;
}
.splitbutton::before,
.splitbutton::after {
  content: "";
  position: absolute;
  right: 0.7rem;
  top: 1.1rem;
  width: 0;
  height: 0;
  border-top: 0.35rem solid white;
  border-left: 0.35rem solid transparent;
  border-right: 0.35rem solid transparent;
  pointer-events: none;
}
.splitbutton::before {
  border-top-color: hsl(220, 75%, 40%);
  top: calc(1.1rem + 1px);
}
.splitbutton input, .splitbutton select {
  background: #2060df; 
  color: white;
  border: 0;
  height: 2.5rem;
  line-height: 2.5rem;
  font-family: sans-serif;
  border-top-left-radius: 0.3rem;
  border-bottom-left-radius: 0.3rem;
  cursor: pointer;
}
.splitbutton input {
  width: calc(100% - 2rem);
  position: absolute;
  border-right: 1px solid #9fb5df;
  text-shadow: 0 1px 0 hsl(220, 75%, 40%);
}
.splitbutton input:hover,
.splitbutton select:hover {
  background: hsl(220, 75%, 45%);
}
.splitbutton input:active,
.splitbutton select:active {
  background: hsl(220, 75%, 40%)
}
.splitbutton select {
  padding-right: 2rem;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border-top-right-radius: 0.3rem;
  border-bottom-right-radius: 0.3rem;
}
              
            
!

JS

              
                /* 

Hey Adam, do you really need a split button? Isn't hiding things under a tiny non-descriptive arrow a clear sign of bad interface design? However, when you think you really do... I would not overthink it. You can just use native browser controls. They work really well, also on mobile, AND they are accessible by default. I hope I did not spoil this challenge for you. I am looking forward to your next GUI challenge. Have a great day!

https://web.dev/shows/gui-challenges/Qcpru-fIgwk/

*/
              
            
!
999px

Console