bulma icon indicating copy to clipboard operation
bulma copied to clipboard

Adds is-required to label

Open moladukes opened this issue 4 years ago • 2 comments

Adds .is-required class to label adding a required star. Uses the $danger color variable.

This is a improvement.

Proposed solution

Add a required class option to form labels

<div class="field">
  <label class="label is-required">Email</label>
  <div class="control">
    <input class="input" type="text" placeholder="Text input">
  </div>
  <p class="help is-danger">This email is invalid</p>
</div>
Screen Shot 2020-11-11 at 8 20 39 AM

<div class="field is-horizontal">
  <div class="field-label is-normal">
    <label class="label is-required">Subject</label>
  </div>
  <div class="field-body">
    <div class="field">
      <div class="control">
        <input class="input is-danger" type="text" placeholder="e.g. Partnership opportunity">
      </div>
      <p class="help is-danger">
        This field is required
      </p>
    </div>
  </div>
</div>

Screen Shot 2020-11-11 at 8 25 44 AM

Tradeoffs

May want to style your required labels differently than the classic star pattern and or move the star as an :after element. Perhaps an .is-required class on the .field wrapper could be more elegant?

<div class="field is-required">
  <label class="label">Email</label>
  <div class="control">
    <input class="input" type="text" placeholder="Text input">
  </div>
  <p class="help is-danger">This email is invalid</p>
</div>

Testing Done

Tested on Standard and Horizontal form labels.

Changelog updated?

No.

moladukes avatar Nov 11 '20 16:11 moladukes