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="bear__wrapper">
      <svg class="bear" viewBox="0 0 241 257" fill="none" xmlns="http://www.w3.org/2000/svg">
        <g class="bear__body">
          <path d="M213.727 108.553C213.727 136.968 213.701 173.493 201.933 202.922C196.071 217.583 187.328 230.384 174.292 239.532C161.263 248.676 143.78 254.286 120.235 254.286C96.6889 254.286 79.2065 248.676 66.1771 239.532C53.1413 230.384 44.3983 217.583 38.536 202.922C26.7685 173.493 26.7425 136.968 26.7425 108.553C26.7425 52.8665 68.7328 7.97217 120.235 7.97217C171.736 7.97217 213.727 52.8665 213.727 108.553Z" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>
          <circle cx="37.3983" cy="36.9758" r="34.8416" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>
          <circle cx="203.509" cy="36.9758" r="34.8416" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>
          <g class="bear__eyes">
            <g class="bear__eyes-crossed">
              <!-- Right -->
              <line x1="164.746" x2="183.746" y1="99.811" y2="111.811" stroke-width="4" stroke-linecap="round" stroke="var(--gray-8)"></line>
              <line x1="164.746" x2="183.746" y1="111.811" y2="99.811" stroke-width="4" stroke-linecap="round" stroke="var(--gray-8)"></line>
              <!-- Left -->
              <line x1="58.1606" x2="74.1606" y1="99.811" y2="111.811" stroke-width="4" stroke-linecap="round" stroke="var(--gray-8)"></line>
              <line x1="58.1606" x2="74.1606" y1="111.811" y2="99.811" stroke-width="4" stroke-linecap="round" stroke="var(--gray-8)"></line>
            </g>
            <g class="bear__eyes-normal">
              <circle cx="174.746" cy="105.811" r="8.0793" fill="var(--gray-8)"/>
              <circle cx="66.1606" cy="105.811" r="8.0793" fill="var(--gray-8)"/>
            </g>
          </g>
          <path d="M141.246 120.415C141.246 128.625 131.378 137.866 120.401 137.866C109.425 137.866 99.5567 128.625 99.5567 120.415C99.5567 112.205 109.425 108.134 120.401 108.134C131.378 108.134 141.246 112.205 141.246 120.415Z" fill="var(--gray-8)"/>
          <rect x="75.7932" y="69.9394" width="88.3706" height="13.25" fill="#FF1E1E"/>
          <path fill-rule="evenodd" clip-rule="evenodd" d="M187.771 28.755C205.711 43.1491 215.789 65.9033 215.789 86.2595H154.142C154.055 72.5907 142.947 61.5369 129.258 61.5369H110.699C97.0096 61.5369 85.902 72.5907 85.8151 86.2595L24.4714 86.2595C24.4714 65.9033 34.5498 43.149 52.4893 28.755C70.4288 14.361 94.76 6.27448 120.13 6.27448C145.501 6.27448 169.832 14.361 187.771 28.755Z" fill="var(--gray-8)"/>
        </g>
        <g class="bear__arm">
          <rect x="2" y="120" height="54" width="220" rx="27" fill="#AF7128" stroke-width="4" stroke="var(--gray-8)"></rect>
          <line x1="214" y1="139" x2="192" y2="138" stroke-linecap="round" stroke="var(--gray-8)" stroke-width="4"></line>  
          <line x1="214" y1="157" x2="192" y2="158" stroke-linecap="round" stroke="var(--gray-8)" stroke-width="4"></line>  
        </g>
        <g class="bear__arms">
          <rect x="-10" y="100" width="54" height="80" ry="27" stroke-width="4" stroke="var(--gray-8)" fill="#AF7128"></rect>
          <rect x="0" y="110" width="34" height="40" ry="17" fill="#F2DA89"></rect>
          <rect x="198" y="100" width="54" height="80" ry="27" stroke-width="4" stroke="var(--gray-8)" fill="#AF7128"></rect>
          <rect x="208" y="110" width="34" height="40" ry="17" fill="#F2DA89"></rect>
        </g>
      </svg>
    </div>
    <main>
      <form onSubmit="function(e){e.preventDefault()}">
        <div class="form-group">
          <label for="email">Email</label>
          <input type="email" autocomplete="off" id="email" required placeholder="Enter email">
        </div>
        <div class="form-group">
          <label for="password">Password</label>
          <input type="password" id="password" required placeholder="Enter password">
          <button id=reveal type=button aria-pressed=false>
            <span aria-hidden class="material-symbols-outlined">visibility</span>
            <span class="sr-only">Reveal password</span>
          </button>
        </div>
        <input type="submit" value="Sign In">
        <svg class="indicator-arm" viewBox="-4 -4 102 62" fill="none" xmlns="http://www.w3.org/2000/svg">
          <defs>
            <clipPath id="arm">
              <!-- Plus/Minus 4 on each side to accommodate stroke -->
              <rect x="0" y="0" width="98" height="58" rx="28" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>    
            </clipPath>
            <clipPath id="behind">
              <rect x="58" y="0" height="61" width="59"/>
            </clipPath>
          </defs>
          <g class="indicator-arm__arm" clip-path="url(#arm)">
            <!-- <rect x="2" y="2" width="92" height="54" rx="28" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>     -->
            <g clip-path="url(#behind)">
              <g class="indicator-arm__paw">
                <rect x="2" y="2" width="94" height="54" rx="28" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>
                <rect x="12" width="72" y="12" height="34" fill="#F2DA89" rx="18"></rect>
              </g>
            </g>
            <g class="indicator-arm__claws">
              <rect x="2" y="2" width="94" height="54" rx="28" fill="#AF7128" stroke="var(--gray-8)" stroke-width="4"/>
              <line x1="8" y1="21" x2="30" y2="19" stroke-linecap="round" stroke="var(--gray-8)" stroke-width="4"></line>  
              <line x1="8" y1="39" x2="30" y2="41" stroke-linecap="round" stroke="var(--gray-8)" stroke-width="4"></line>  
            </g>
            <g clip-path="url(#behind)">
              <g class="indicator-arm__paw" clip-path="url(#behind)">
                <rect x="2" y="2" width="94" height="54" rx="28" fill="none" stroke="var(--gray-8)" stroke-width="4"/>    
              </g>
            </g>
          </g>  
        </svg>
      </form>
    </main>
              
            
!

CSS

              
                @import "https://unpkg.com/normalize.css" layer(normalize);
@import "https://unpkg.com/open-props/open-props.min.css" layer(open-props);
@import "https://unpkg.com/open-props/normalize.min.css" layer(open-props);

:root {
  --anchor-size: 5vmin;
  --anchored-size: 25vmin;
}

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

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  font-family:  'Google Sans', sans-serif, system-ui;
  background: var(--gray-2);
  position: relative;
  overflow: hidden;
}

main {
  height: 100vh;
  width: 100vw;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.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;
}

form {
  padding: var(--size-4) var(--size-9);
  background: var(--surface-1);
  display: grid;
  gap: var(--size-5);
  border: 2px solid var(--surface-3);
  box-shadow: var(--shadow-5);
  position: relative;
  z-index: 2;
}

label {
  font-weight: var(--font-weight-9);
  color: var(--text-2);
}

#email {
  anchor-name: --email;
}

#password {
  anchor-name: --password;
}

.form-group {
  display: grid;
  gap: var(--size-1);
}

.material-symbols-outlined {
  font-variation-settings: 'wght' 600;
}

form {
  anchor-name: --form;
  --anchor-name: --email;
}

form:has(#email:focus) {
  --anchor-name: --email;
}

form:has(#password:focus, #reveal:focus, [type=submit]:focus) {
  --anchor-name: --password;
}


[type] {
  padding: var(--size-2) var(--size-4);
  max-width: 220px;
}

[type]:focus-visible {
  outline-color: var(--cyan-6);
}

[type=button] {
  width: 44px;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: transparent;
  padding: 0;
  position: absolute;
  translate: 0 -50%;
  top: anchor(--password center);
  right: anchor(--password right);
}

main {
  position: relative;
}

.bear__wrapper {
  position: absolute;
  width: 240px;
  aspect-ratio: 1;
  bottom: anchor(--form top);
  right: anchor(--form right);
  translate: calc(var(--show-valid, 0) * -20%) 50%;
  transition: translate var(--step) var(--step);
}

:is([type=password], [type=text]) {
  padding-right: 44px;
}

[type=submit] {
  background-color: var(--cyan-6);
  font-weight: var(--font-weight-9);
  color: var(--gray-0);
  padding: var(--size-2) var(--size-4);
}


:root {
  --step: 0.1s;
}
:root:has(form:focus-within) {
  --show-paw: 1;
}
form:focus-within .indicator-arm__claws {
  transition: translate var(--step) var(--step);
}
form:focus-within .indicator-arm__paw {
  transition: translate var(--step);
}

/* Arm stuff */
.indicator-arm {
  overflow: visible;
  width: 96px;
  position: absolute;
  left: 100%;
  top: anchor(var(--anchor-name) center);
  translate: -60% -50%;
  z-index: 2;
}
.indicator-arm__claws {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  translate: calc((110 - (var(--show-paw, 0) * 110)) * 1%) 0;
  transition: translate var(--step);
}
.indicator-arm__paw {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  translate: calc((-50 + (var(--show-paw, 0) * 50)) * 1%) 0;
  transition: translate var(--step) var(--step);
}
.bear {
  overflow: visible;
  width: 100%;
}
.bear__arm {
  transform-box: fill-box;
  transform-origin: 5% 50%;
  translate: calc((-12 + (var(--reveal, 0) * -16)) * 1%) calc((50 - (var(--password-focus, 0) * 62)) * 1%);
  rotate: calc(var(--password-focus, 0) * -12deg);
  transition: translate var(--step), rotate var(--step);
}

.bear__eyes-normal {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: blink 6s -2s infinite;
}

@keyframes blink {
  0%, 46%, 48%, 50%, 100% {
    scale: 1 1;
  }
  47%, 49% {
    scale: 1 0.01;
  }
}

:root:has(#password:focus, #reveal:focus) .bear__arm {
  transition: translate var(--step) var(--step), rotate var(--step) var(--step);
}

:root:has(form:hover) {
  --show-bear: 0.45;
}
:root:has(form:valid:hover) {
  --show-bear: 0.55;
}
:root:has([type=text]) {
  --reveal: 1;
}
:root:has(form:focus-within) {
  --show-bear: 0.55;
}
:root:has(#password:focus, #reveal:focus) {
  --password-focus: 1;
}

:root:has(#email:invalid:not(:placeholder-shown):not(:focus)):has(#password:not(:focus)):has(#reveal:not(:focus)) {
  --show-cross: 1;
}

:root:has(#email:invalid:not(:placeholder-shown):not(:focus)):has(#password:not(:focus)):has(#reveal:not(:focus)) .bear__body {
  animation: shake calc(var(--show-cross, 0) * 0.2s) both;
}

:root:has(#email:valid:not(:placeholder-shown):not(:focus)):has(#password:valid:not(:placeholder-shown):not(:focus)):has(#reveal:not(:focus)) {
  --show-paw: 0;
  --show-valid: 1;
}

:root:has(#email:valid:not(:placeholder-shown):not(:focus)):has(#password:valid:not(:placeholder-shown):not(:focus)):has(#reveal:not(:focus))
.indicator-arm__claws {
  transition: translate var(--step);
}
:root:has(#email:valid:not(:placeholder-shown):not(:focus)):has(#password:valid:not(:placeholder-shown):not(:focus)):has(#reveal:not(:focus))
.indicator-arm__paw {
  transition: translate var(--step) var(--step);
}

:root:has(#email:valid:not(:placeholder-shown):not(:focus)):has(#password:valid:not(:placeholder-shown):not(:focus)):has(#reveal:not(:focus))
.bear__arms {
  display: block;
  transition: opacity var(--step) var(--step) steps(1);
}

.bear__body {
  transform-box: fill-box;
  transform-origin: 50% 50%;
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  } 
  20%, 40%, 60%, 80% {
    transform: translateX(-2%);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(2%);
  }
}

.bear__eyes-normal {
  opacity: calc(1 - var(--show-cross, 0));
}

.bear__eyes-crossed {
  opacity: var(--show-cross, 0);
}

.bear {
  transition: transform var(--step);
  transform:
    translateY(calc((50 - (var(--show-bear, 0) * 100)) * 1%))
    rotate(calc(var(--password-focus, 0) * -15deg))
    translate(calc(var(--password-focus, 0) * -5%), calc(var(--password-focus, 0) * 5%));
}

.bear__arms {
  display: none;
  transform-box: fill-box;
  transform-origin: 50%;
  opacity: var(--show-valid, 0);
  animation: pump 0.25s 4 both;
  translate: 0 60%;
}

@keyframes pump {
  50% {
    translate: 0 -20%;
  }
}

/* Debugging purposes */
/* :root {
  --show-paw: 0;
  --show-valid: 1;
  --show-bear: 0.55;
} */

              
            
!

JS

              
                const TOGGLE_REVEAL = document.querySelector('[type=button]')
const PASSWORD_FIELD = document.querySelector('#password')
const ICON = document.querySelector('.material-symbols-outlined')
TOGGLE_REVEAL.addEventListener('click', () => {
  PASSWORD_FIELD.type = PASSWORD_FIELD.matches('[type=password]') ? 'text' : 'password'
  ICON.innerText = PASSWORD_FIELD.matches('[type=password]') ? 'visibility' : 'visibility_off'
})
              
            
!
999px

Console