• Lightest
  • Light
  • Dark
  • Darkest
  • Medium
  • Large
  • LTR
  • RTL

Field Label

Component status
Verified
Last releasedOctober 20, 2020
Current version@spectrum-css/fieldlabel@3.0.0-beta.6

Usage notes


Field label for use with form inputs.

Variants


Standard
Contribution

Show markup
<label for="lifestory" class="spectrum-FieldLabel">Life Story</label>
<div class="spectrum-Textfield">
  <input id="lifestory" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input">
</div>

<label for="lifestory2" class="spectrum-FieldLabel is-disabled">Life Story</label>
<div class="spectrum-Textfield is-disabled">
  <input id="lifestory2" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input" disabled>
</div>

Left
Contribution

A left aligned field label.

Show markup
<label for="lifestory3" class="spectrum-FieldLabel spectrum-FieldLabel--left" style="width: 72px">Life Story</label>

<div class="spectrum-Textfield spectrum-Textfield--multiline">
  <textarea id="lifestory3" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input"></textarea>
</div>

A right aligned field label.

Show markup
<label for="lifestory4" class="spectrum-FieldLabel spectrum-FieldLabel--right" style="width: 72px">Life Story</label>

<div class="spectrum-Textfield spectrum-Textfield--multiline">
  <textarea id="lifestory4" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input"></textarea>
</div>

Required
Contribution

Field label for a required field.



Show markup
<label for="lifestory5" class="spectrum-FieldLabel">Life Story
  <svg class="spectrum-Icon spectrum-UIIcon-Asterisk spectrum-FieldLabel-requiredIcon" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-css-icon-Asterisk" />
  </svg>
</label>
<div class="spectrum-Textfield">
  <input id="lifestory5" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input">
</div>

<label for="lifestory6" class="spectrum-FieldLabel">Life Story (Required)</label>
<div class="spectrum-Textfield">
  <input id="lifestory6" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input">
</div>

<br/>
<br/>

<label for="lifestory7" class="spectrum-FieldLabel spectrum-FieldLabel--left">Life Story
  <svg class="spectrum-Icon spectrum-UIIcon-Asterisk spectrum-FieldLabel-requiredIcon" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-css-icon-Asterisk" />
  </svg>
</label>
<div class="spectrum-Textfield spectrum-Textfield--multiline">
  <textarea id="lifestory7" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input"></textarea>
</div>


<label for="lifestory8" class="spectrum-FieldLabel is-disabled">Life Story
  <svg class="spectrum-Icon spectrum-UIIcon-Asterisk spectrum-FieldLabel-requiredIcon" focusable="false" aria-hidden="true">
    <use xlink:href="#spectrum-css-icon-Asterisk" />
  </svg>
</label>
<div class="spectrum-Textfield is-disabled">
  <input id="lifestory8" placeholder="Enter your life story" name="field" value="" class="spectrum-Textfield-input" disabled>
</div>