Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@material/form-field
Advanced tools
Material Components for the web wrapper styles for laying out form fields and labels next to one another
MDC Form Field provides an mdc-form-field
helper class for easily making theme-aware, RTL-aware
form field + label combos.
npm install --save @material/form-field
The mdc-form-field
class can be used as a wrapper element with any input
+ label
combo:
<div class="mdc-form-field">
<input type="checkbox" id="input">
<label for="input">Input Label</label>
</div>
By default, this will position the label after the input. You can change this behavior using the
align-end
modifier class.
<div class="mdc-form-field mdc-form-field--align-end">
<input type="checkbox" id="input">
<label for="input">Input Label</label>
</div>
Now the label will be positioned before the checkbox.
mdc-form-field
will work not just with input
elements, but with any element as long as its
successive sibling is a label element. This means it will work for any MDC-Web form control, such as a
checkbox:
<div class="mdc-form-field">
<div class="mdc-checkbox">
<input type="checkbox"
id="my-checkbox"
class="mdc-checkbox__native-control"/>
<div class="mdc-checkbox__background">
<svg version="1.1"
class="mdc-checkbox__checkmark"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
xml:space="preserve">
<path class="mdc-checkbox__checkmark__path"
fill="none"
stroke="white"
d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
</div>
<label for="my-checkbox" id="my-checkbox-label">This is my checkbox</label>
</div>
mdc-form-field
is automatically RTL-aware, and will re-position elements within an RTL context.
mdc-form-field
will apply RTL styles whenever it, or its ancestors, has a dir="rtl"
attribute.
mdc-form-field
is dark theme aware, and will change the text color to the "primary on dark" text
color when used within a dark theme.
FAQs
Material Components for the web wrapper for laying out form fields and labels next to one another
The npm package @material/form-field receives a total of 688,668 weekly downloads. As such, @material/form-field popularity was classified as popular.
We found that @material/form-field demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.