Adding a red asterisk to required fields using label in LWC
I am trying to add a double or single asterisk to lightning: input tags in LWC, by using "required" tag inside the tag I am able to see the asterisk, but two issues with this are I have to show a red asterisk to some conditionally mandatory issues.
Solution -
You can use label-hidden variant and put a label.
<template>
<label>Middle Name</label>
<abbr title="required" class="slds-required">**</abbr>
<lightning-input label="Middle Name" variant="label-hidden" aria-required="true" maxlength="80"></lightning-input>
</template>

Comments
Post a Comment