2.13.0
Microcopy augments a label to describe a form element in greater detail.
See Forms for guidance on composing full forms.
Use to describe a form element in greater detail.
<span class="mds-form__microcopy" id="password-help-text"> Your password must contain a letter and a number. </span>
<mds-microcopy id="password-help-text">Your password must contain a letter and a number.</mds-microcopy>
mds-form__field-group
container.<div class="mds-form__field-group">
<label class="mds-form__label" for="password">Password</label>
<span class="mds-form__microcopy" id="password-help-text"> Your password must contain a letter and a number. </span>
<input class="mds-form__input" aria-describedby="password-help-text" type="password" id="password" />
</div>
Sizing affects text size. The default size is medium, and you can use modifier classes or props to make the microcopy smaller or larger.
<span class="mds-form__microcopy mds-form__microcopy--small" id="small-microcopy"> This is example microcopy text. </span>
<mds-microcopy size="small" id="small-microcopy">This is example microcopy text.</mds-microcopy>
Class
|
Applies to
|
Outcome
|
---|---|---|
|
|
Adjusts styling to render small microcopy. |
|
|
Adjusts styling to render large microcopy. |
Prop
|
Type
|
Validation
|
Default
|
Description
|
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
String |
Required |
— |
The |
|
String |
Enum: |
|
Alters the size of the microcopy. |
|
String |
Required |
— |
The text for the microcopy. Can also be passed via the default slot. |
Any text or markup passed in between the <mds-microcopy></mds-microcopy>
tags will be used as the microcopy’s text content. This slot can accept plain text, or a combination of text and any tags where appropriate. If no content is passed in via the slot and the text
prop is empty, the microcopy text content will be empty.
Setting the text and size:
<!-- Using Props -->
<mds-microcopy text="Your password must contain a letter and a number." size="small"></mds-microcopy>
<!-- Using Slots -->
<mds-microcopy size="small"> Your password must contain a letter and a number. </mds-microcopy>
aria-describedby
attribute on each input
, textarea
, or select
that has an .mds-form__microcopy
component providing additional information. The value of the aria-describedby
attribute must match the id
attribute on the .mds-form__microcopy
component.