UI Docs Deploy now

Two ways

One form, two sets of fields. A radio picks which shows, with no script.

Styles: layout.css, components/choice.css.

€60 a year

€6 a month

Cancel any time.

Code
<form class="moin-stack" data-gap="4" data-either>
  <div class="moin-choice" role="radiogroup" aria-label="Pay">
    <label><input type="radio" name="demo-pay" value="yearly" checked>Yearly</label>
    <label><input type="radio" name="demo-pay" value="monthly" data-other>Monthly</label>
  </div>
  <p class="moin-number" data-way="first">€60 a year</p>
  <p class="moin-number" data-way="other">€6 a month</p>
  <p class="moin-text moin-muted">Cancel any time.</p>
</form>

data-either goes on the form. The radio that means the second way carries data-other. Parts with data-way="first" show until it is checked. Parts with data-way="other" show once it is. Everything else stays. Both ways are in the page, so the server gets the one that was picked. Works on any element with radios in it.

This page as Markdown