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

              
                <!--  Orig radiento: https://codepen.io/argyleink/pen/BaGrXmv -->
<fieldset id="radiento" class="bento">
  <div>
    <input type="radio" id="huey" name="drone" value="huey" checked>
    <label for="huey">Huey</label>
  </div>

  <div>
    <input type="radio" id="dewey" name="drone" value="dewey">
    <label for="dewey">Dewey</label>
  </div>

  <div>
    <input type="radio" id="louie" name="drone" value="louie">
    <label for="louie">Louie</label>
  </div>
</fieldset>

              
            
!

CSS

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

@property --vt-checked {
  syntax: "<custom-ident>";
  inherits: false;
  initial-value: OFF;
}
#radiento input:checked {
  --vt-checked: ON;
}

div:has(#huey) {
  background: lime;
}

div:has(#dewey) {
  background: hotpink;
}

::view-transition-group(*) {
  animation-timing-function: var(--ease-squish-1);
  animation-timing-function: var(--ease-spring-2);
  animation-duration: .75s;
}

/* fixex ghosting at the bottom */
::view-transition-old(opt-1),
::view-transition-old(opt-2),
::view-transition-old(opt-3),
::view-transition-new(opt-1),
::view-transition-new(opt-2),
::view-transition-new(opt-3) {
  height: 100%;
}

@layer demo {
  .bento {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: var(--size-3);
    
    min-inline-size: 75vw;
    aspect-ratio: var(--ratio-widescreen);
    
    & > * {
      border-radius: var(--radius-3);
      background: var(--surface-2);
      
      @media (prefers-reduced-motion: no-preference) {
        &:nth-child(1) {
          view-transition-name: opt-1;
          & > label {
            view-transition-name: opt-1-label;
          }
          & > input {
            view-transition-name: opt-1-input;
          }
        }
        &:nth-child(2) {
          view-transition-name: opt-2;
          & > label {
            view-transition-name: opt-2-label;
          }
          & > input {
            view-transition-name: opt-2-input;
          }
        }
        &:nth-child(3) {
          view-transition-name: opt-3;
          & > label {
            view-transition-name: opt-3-label;
          }
          & > input {
            view-transition-name: opt-3-input;
          }
        }

        & :is(label, input) {
          width: fit-content;
        }
      }
    }
    
    & > div:has(input:checked) {
      grid-row: 1 / -1;
      grid-column: 1;
    }
  }
}

@layer demo.support {
  html {
    view-transition-name: none;
  }
  
  body {
    display: grid;
    place-content: center;
    padding: var(--size-5);
    gap: var(--size-5);
  } 
  
  fieldset {
    border: none;
    
    > div {
      display: grid;
      grid: 1fr / 1fr;
      padding: var(--size-3);

      & > label {
        grid-area: 1 / 1;
      }
    }
  }
}
              
            
!

JS

              
                import CSSStyleObserver, { NotificationMode, ReturnFormat } from "https://esm.sh/@bramus/style-observer";

// Utility fn to clear an array
const clearArray = (array) => {
  while (array.length > 0) {
    array.pop();
  }
}

// Function than handles a pair of changes
const handleChanges = async (changes) => {
  // We need a pair
  if (changes.length != 2) return;
  
  // Extract changes
  const [change1, change2] = changes;
  
  // Revert back to old state
  change1.element.checked = change1.previousValue == 'ON';
  change2.element.checked = change2.previousValue == 'ON';
  
  // Now reapply new state, with a View Transition.
  try {
    const t = document.startViewTransition(() => {
      change1.element.checked = change1.value == 'ON';
      change2.element.checked = change2.value == 'ON';
    });

    // Get ready for next pair
    await t.finished;
  } finally {
    clearArray(changes);
  }
}

const pairOfChanges = [];
const styleObserver = new CSSStyleObserver(
  ['--vt-checked'],
  (changes) => {
    const change = changes['--vt-checked'];
    
    // Ignore initial triggers from CSSStyleObserver
		if (!change || !change.previousValue) return;
    
    // Ignore when a pair is currently being handled
    if (pairOfChanges.length == 2) return;
    
    // Store the change, and see if we can handle it
    pairOfChanges.push(change);
    handleChanges(pairOfChanges);
	},
  {
      notificationMode: NotificationMode.CHANGED_ONLY,
      returnFormat: ReturnFormat.OBJECT,
   }
);

document.querySelectorAll('#radiento input').forEach($radio => {
  styleObserver.attach($radio);
});
              
            
!
999px

Console