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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

              
                <h1>Composing box shadows with CSS variables demo</h1>
<p>
  The box shadows of the input fields below are brought by two classes `box-shadow--elevation` to lift it up the page and `box-shadow--inset` to give it a bit of depth inside. On focus, it gains a third box shadow to outline it with rounded corners.
</p>
<p>
  Instead of each class overriding the `box-shadow` property, a system of variables allow to compose them with each other so each class adds or remove a specific shadow.
</p>
<label for="input">Focus me</label>
<input class="box-shadow--elevation box-shadow--inset" id="input" name="field" />

              
            
!

CSS

              
                :root {
      /* Tobias Ahlin's smooth shadow: https://tobiasahlin.com/blog/layered-smooth-box-shadows/ */
      --elevation: 0 0.125rem 0.125rem rgba(0,0,0,0.12), 
              0 0.25rem 0.25rem rgba(0,0,0,0.12),
              0 0.5rem 0.5rem
rgba(0,0,0,0.12),;
      --outline: 0 0 0 0.125rem #4d003a, ;
      --inset: inset 0 0.125rem 0.125rem hsla(0, 0%, 0%, 0.2), ;
    }

    [class*="box-shadow"] {
      /* Lea Verou's empty var technique: https://lea.verou.me/2020/10/the-var-space-hack-to-toggle-multiple-values-with-one-custom-property/ */
      --shw__inset: ;
      --shw__outline: ;
      --shw__elevation: ;
      box-shadow: var(--shw__inset) var(--shw__outline) var(--shw__elevation) 0 0 0 transparent;
    }

    .box-shadow--elevation {
      --shw__elevation: var(--elevation);
    }

    .box-shadow--inset {
      --shw__inset: var(--inset);
    }

    :focus {
      --shw__outline: var(--outline);
      /* Let's not forget Windows High Contrast mode which won't have the shadows for the focus */  
      outline: solid transparent 0.125rem;
      outline-offset: 0.125rem;
    }

    input {
      border: solid 1px #4d003a;
      padding: 0.25rem;
      border-radius: 0.25rem;
    }

html,
body {
  height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items:center;
  background-color: #00efce;
  color: #4d003a;
  font-family: sans-serif;
}

body > * {
  max-width: 30rem;
}

h1 {
  text-align: center;
}
              
            
!

JS

              
                
              
            
!
999px

Console