Field Group

Component status
Contribution
Last releasedOctober 8, 2019
Current version@spectrum-css/fieldgroup@2.0.0

Usage notes#


A group of fields, usually Radios or Checkboxes.

Variants#


Standard#
Contribution

<div class="spectrum-FieldGroup">
  <div class="spectrum-Radio">
    <input type="radio" name="pets" class="spectrum-Radio-input" id="radio-0">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-0">Kittens</label>
  </div>
  <div class="spectrum-Radio">
    <input type="radio" name="pets" class="spectrum-Radio-input" id="radio-1">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-1">Dogs</label>
  </div>
</div>
<div class="spectrum-FieldGroup">
  <label class="spectrum-Checkbox">
    <input type="checkbox" class="spectrum-Checkbox-input" id="checkbox-0">
    <span class="spectrum-Checkbox-box">
      <svg class="spectrum-Icon spectrum-UIIcon-CheckmarkSmall spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-css-icon-CheckmarkSmall" />
      </svg>
    </span>
    <span class="spectrum-Checkbox-label">Checkbox</span>
  </label>
  <label class="spectrum-Checkbox">
    <input type="checkbox" class="spectrum-Checkbox-input" id="checkbox-1" checked>
    <span class="spectrum-Checkbox-box">
      <svg class="spectrum-Icon spectrum-UIIcon-CheckmarkSmall spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-css-icon-CheckmarkSmall" />
      </svg>
    </span>
    <span class="spectrum-Checkbox-label">Checkbox</span>
  </label>
</div>
Show markup

Labels below#
Contribution

Put the labels below by adding the modifier class to the field itself.

<div class="spectrum-FieldGroup">
  <div class="spectrum-Radio spectrum-Radio--labelBelow">
    <input type="radio" name="rating" class="spectrum-Radio-input" id="radio-2">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-2">1</label>
  </div>
  <div class="spectrum-Radio spectrum-Radio--labelBelow">
    <input type="radio" name="rating" class="spectrum-Radio-input" id="radio-3">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-3">2</label>
  </div>
  <div class="spectrum-Radio spectrum-Radio--labelBelow">
    <input type="radio" name="rating" class="spectrum-Radio-input" id="radio-4">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-4">3</label>
  </div>
</div>
Show markup

Vertical#
Contribution

A vertical group of fields.

<div class="spectrum-FieldGroup spectrum-FieldGroup--vertical">
  <div class="spectrum-Radio">
    <input type="radio" name="animals" class="spectrum-Radio-input" id="radio-fieldgroup-vertical-1">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-fieldgroup-vertical-1">Kittens</label>
  </div>
  <div class="spectrum-Radio">
    <input type="radio" name="animals" class="spectrum-Radio-input" id="radio-fieldgroup-vertical-2">
    <span class="spectrum-Radio-button"></span>
    <label class="spectrum-Radio-label" for="radio-fieldgroup-vertical-2">Dogs</label>
  </div>
</div>

<div class="spectrum-FieldGroup spectrum-FieldGroup--vertical">
  <label class="spectrum-Checkbox">
    <input type="checkbox" class="spectrum-Checkbox-input">
    <span class="spectrum-Checkbox-box">
      <svg class="spectrum-Icon spectrum-UIIcon-CheckmarkSmall spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-css-icon-CheckmarkSmall" />
      </svg>
    </span>
    <span class="spectrum-Checkbox-label">Kibble</span>
  </label>
  <label class="spectrum-Checkbox">
    <input type="checkbox" class="spectrum-Checkbox-input" checked>
    <span class="spectrum-Checkbox-box">
      <svg class="spectrum-Icon spectrum-UIIcon-CheckmarkSmall spectrum-Checkbox-checkmark" focusable="false" aria-hidden="true">
        <use xlink:href="#spectrum-css-icon-CheckmarkSmall" />
      </svg>
    </span>
    <span class="spectrum-Checkbox-label">Bits</span>
  </label>
</div>
Show markup