<form>
  <fieldset>  
    <label class="active">
      <input type="radio" name="class" value="container--one" class="radio" checked="checked">
      <code>row</code>
      <small>(default)</small>
    </label>        
    <label>
      <input type="radio" name="class" value="container--two" class="radio">
      <code>column</code>
    </label>     
    <label>
      <input type="radio" name="class" value="container--three" class="radio">
      <code>row</code> (+ writing-mode)
    </label>         
    <label>
      <input type="radio" name="class" value="container--four" class="radio">
      <code>column</code> (+ writing-mode)
    </label>             
  </fieldset>  
</form>

<div class="container container--one" id="container">
  <p class="column">1</p>
  <p class="column">2</p>
  <p class="column">3</p>  
</div>
.container--one {
  grid-auto-flow: row;
}

.container--two {
  grid-auto-flow: column;
}

.container--three {
  grid-auto-flow: row;
  writing-mode: vertical-rl;
}

.container--four {
  grid-auto-flow: column;
  writing-mode: vertical-rl;  
}


.container {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
}

/* etc: */

body {
  margin: 1.5em;
  font-size: 130%;
}

.column {
  margin: 0.25rem;
  padding: 0.5rem;
  border: 5px dotted black;
  padding-block: 2rem;
  border-block-color: LimeGreen;
}

.container {
  border: 5px solid black;
  padding: 1em;
  margin-bottom: 2em;  
}
var radios = document.querySelectorAll('.radio');
var container = document.getElementById('container');
radios.forEach(function(i){
    i.addEventListener('click', function(el){
        var clicked = el.currentTarget;
        var active = clicked.parentElement.parentElement.querySelector('.active');
        active && active.classList.remove('active');
        clicked.parentElement.classList.add('active');     
        container.className = 'container '+clicked.value;
    });
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.