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

              
                <body class="bg-white min-h-screen grid place-content-center">
   <!-- theme toggle radio -->
   <input type="checkbox" id="theme" class="sr-only peer/theme" checked>

  <div style="--total: 12;" class="relative rounded-full grid  size-72 [grid-template-areas:'stack'] place-content-center
        [&>label]:[grid-area:stack]
        [&>label]:size-20
        [&>label]:rounded-full
        [&>label]:grid
        [&>label]:place-content-center 
        [&>label]:bg-white/20
        [&>label]:relative
        [&>label]:text-sky-500
        [&>label]:text-xl
        [&>label]:transition-all 
        [&>label]:duration-500
        [&>label]:cursor-pointer
        [&>label]:ring-4
        [&>label]:ring-white/5
        [&_img]:rounded-full
        [&_img]:s-full
        [&_img]:object-cover
        [&_img]:transition-all
        [&_img]:duration-1000
        [&_img]:ease-in-out
        [&_svg]:transition-all
        [&_svg]:duration-500
        [&_svg]:ease-in-out
        [&_svg]:absolute
        [&_svg]:top-2/4
        [&_svg]:left-2/4
        [&_svg]:-translate-x-2/4
        [&_svg]:-translate-y-2/4
        [&_svg]:w-[125px]
        [&_svg]:opacity-0 
        [&_svg]:-z-10

        [&_input:checked+label]:transform-none
        [&_input:checked+label]:duration-1000
        [&_input:checked+label>img]:scale-[200%]
        [&_input:checked+label>svg]:opacity-100
        [&_input:checked+label>svg]:scale-[225%]
        [&_input:checked+label>svg]:rotate-45
        [&_input:checked+label>svg]:[transition-delay:700ms,500ms,2000ms]
        
        peer-checked/theme:before:[&_#center]:-inset-[3000%]
        peer-checked/theme:[&>label]:text-white
    ">
    <div id="center" class="absolute inset-0 m-auto size-32 bg-sky-600 border border-white/40   rounded-full grid place-content-center uppercase font-thin tracking-wider text-slate-100 text-lg  
        before:absolute 
            before:-inset-0
            before:bg-sky-950 
            before:rounded-full
            before:-z-10
            before:transition-all
            before:duration-1000
            peer-checked/theme:before:-inset-[3000%]
        
        ">The Team</div>

    <input type="radio" name="radio-avatar" id="radio-avatar-1" class="sr-only">
    <label id="avatar-1" for="radio-avatar-1" class="avatar" style="--i:1">
      <img src="https://i.pravatar.cc/300?img=12" alt="Steven Robinson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Steven Robinson - Web Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-2" class="sr-only">
    <label id="avatar-2" for="radio-avatar-2" class="avatar" style="--i:2">
      <img src="https://i.pravatar.cc/300?img=37" alt="Mari Johnson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Mari Johnson - UX Designer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-3" class="sr-only">
    <label id="avatar-3" for="radio-avatar-3" class="avatar" style="--i:3">
      <img src="https://i.pravatar.cc/300?img=3" alt="Bob">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Bob - Designer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-4" class="sr-only">
    <label id="avatar-4" for="radio-avatar-4" class="avatar" style="--i:4">
      <img src="https://i.pravatar.cc/300?img=42" alt="Susan Williams">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Susan Williams - Full Stack Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-5" class="sr-only">
    <label id="avatar-5" for="radio-avatar-5" class="avatar" style="--i:5">
      <img src="https://i.pravatar.cc/300?img=52" alt="James Braun">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">James Braun - Content Creator</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-6" class="sr-only">
    <label id="avatar-6" for="radio-avatar-6" class="avatar" style="--i:6">
      <img src="https://i.pravatar.cc/300?img=33" alt="Andrew Charles">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Andrew Charles - Front End Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-7" class="sr-only">
    <label id="avatar-7" for="radio-avatar-7" class="avatar" style="--i:7">
      <img src="https://i.pravatar.cc/300?img=44" alt="Jane Dobson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Jane Dobson - Social Media Manager</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-8" class="sr-only">
    <label id="avatar-8" for="radio-avatar-8" class="avatar" style="--i:8">
      <img src="https://i.pravatar.cc/300?img=13" alt="Ryan Williams">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Ryan Williams - Back End Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-9" class="sr-only">
    <label id="avatar-9" for="radio-avatar-9" class="avatar" style="--i:9">
      <img src="https://i.pravatar.cc/300?img=14" alt="Ralph Heartling">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Ralph Heartling - Full Stack Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-10" class="sr-only">
    <label id="avatar-10" for="radio-avatar-10" class="avatar" style="--i:10">
      <img src="https://i.pravatar.cc/300?img=15" alt="Bryan Davidson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Bryan Davidson - Team Leader</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-11" class="sr-only">
    <label id="avatar-11" for="radio-avatar-11" class="avatar" style="--i:11">
      <img src="https://i.pravatar.cc/300?img=16" alt="Angie Jameson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Angie Jameson - Front End Developer</textPath>
        </text>
      </svg>
    </label>

    <input type="radio" name="radio-avatar" id="radio-avatar-12" class="sr-only">
    <label id="avatar-12" for="radio-avatar-12" class="avatar" style="--i:12">
      <img src="https://i.pravatar.cc/300?img=17" alt="Raymond Simpson">
      <svg viewBox="0 0 300 300">
        <text fill="currentColor">
          <textPath xlink:href="#circlePath">Raymond Simpson - CEO and Entrepreneur</textPath>
        </text>
      </svg>
    </label>

  </div>
  
  <!-- theme toggle switch -->
        <div style="--height:2rem; --border:.1" class="absolute top-4 left-4
                
                [&>label]:w-[calc(var(--height)*2)]
                [&>label]:h-[var(--height)]
                [&>label]:cursor-pointer
                [&>label]:relative
                [&>label]:isolate
                [&>label]:px-[calc(var(--height)/4)]
                [&>label]:flex
                [&>label]:items-center
                [&>label]:justify-center
                [&>label]:gap-[calc(var(--height)/2)] // this calculation is not correct
                
                [&>label>span]:text-slate-700
                first:[&>label>span]:text-slate-500
                [&>label>span]:text-lg
                [&>label>span]:transition-all
                [&>label>span]:duration-500
                
                before:[&>label]:absolute
                before:[&>label]:inset-0
                before:[&>label]:rounded-full
                before:[&>label]:bg-slate-200 

                before:[&>label]:
                before:[&>label]:-z-20
                before:[&>label]:transition-all
                before:[&>label]:duration-300
                hover:before:[&>label]:-inset-1
                peer-foccs:before:[&>label]:-inset-1

                after:[&>label]:absolute
                after:[&>label]:rounded-full
                after:[&>label]:-z-10
                after:[&>label]:bg-white
                after:[&>label]:transition-all
                after:[&>label]:duration-500
                after:[&>label]:ease-in-out
                Xafter:[&>label]:[box-shadow:0_1px_2px_rgba(0,0,0,.5),inset_0_1px_rgba(255,255,255,.5)]
                
                // calculate postion and size based on custom properties - no need to change these
                after:[&>label]:top-[calc(var(--height)*var(--border))]
                after:[&>label]:left-[calc(var(--height)*var(--border))]
                after:[&>label]:h-[calc(var(--height)*calc(1-var(--border)*2))]
                after:[&>label]:w-[calc(var(--height)*calc(1-var(--border)*2))]
                
                peer-checked/theme:before:[&>label]:bg-slate-500
                peer-checked/theme:first:[&>label>span]:text-white
                peer-checked/theme:after:[&>label]:translate-x-[var(--height)]
                peer-checked/theme:after:bg-teal-900  
        ">
            <label for="theme" class="switch">
                <span class="material-symbols-outlined ">light_mode</span>
                <span class="material-symbols-outlined">dark_mode</span>
            </label>
        </div>
  
    <p class="absolute bottom-4 right-4 text-white mt-4 text-sm">Looking for a <a href="https://codepen.io/cbolson/pen/QWPYQBe" class="text-orange-500 hover:underline" target="_parent">pure css version</a>?
      
<!-- SVG template for dynamic text -->
  <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 300 300" width="0" height="0">
    <defs>
      <path id="circlePath" d="M 150, 150 m -100, 0 a 100,100 0 0,1 200,0 a 100,100 0 0,1 -200,0" />
    </defs>
  </svg>
  

</body>
              
            
!

CSS

              
                /*
* CREDITS:
* original code for circle placement calculations taken from this codepen:
* https: //codepen.io/team/keyframers/pen/LYWyrqO
*/
.avatar {
    --radius: 14rem;
    --d: calc(var(--i) / var(--total));
    --r-offset: -0.15turn;
    --r-amount: 1turn;
    --r: calc((var(--r-amount) * var(--d)) + var(--r-offset));
    transform: rotate(var(--r)) translate(var(--radius)) rotate(calc(-1 * var(--r)));
}



              
            
!

JS

              
                // uncheck radio buttons (unfortunatley this can't be done with CSS alone)
document.querySelectorAll('input[type="radio"]').forEach(radio => {
    radio.addEventListener('click', (e) => {
        e.preventDefault();
        // setting a timeout enables this hack to work
        setTimeout(() => radio.checked = !radio.checked, 0);
    });
});
              
            
!
999px

Console