2.12.0
Tags provide contextualizing information, such as filtering criteria or object metadata.
That combination of options is invalid.
Use to display information that clarifies the content on the page, such as object metadata.
<div class="mds-tag"> Shared </div>
<mds-tag>Shared</mds-tag>
Use to enable the tag text to navigate to other pages or additional information.
<a class="mds-tag mds-tag--link" href="#"> Alphabet Inc </a>
<mds-tag href="#">Alphabet Inc</mds-tag>
Use to enable tags to be removed.
<div class="mds-tag"> Equity <button class="mds-button mds-button--icon-only mds-tag--dismissible__button">
<svg class="mds-icon mds-button__icon mds-button__icon--left">
<use xlink:href="/icons/mds.svg#remove--s">
<title>Dismiss Tag</title>
</use>
</svg>
</button>
</div>
<mds-tag dismissible=true>Equity</mds-tag>
remove-s
icon within the tag.Apply the mds-tag-group
class to a wrapping container to add $mds-space-1-x
as right and bottom margin to each tag.
<div class="mds-tag-group">
<div class="mds-tag"> Equity </div>
<div class="mds-tag"> Manager </div>
<div class="mds-tag"> Macro </div>
<div class="mds-tag"> Retirement </div>
<div class="mds-tag"> Fixed Income </div>
<div class="mds-tag"> Managed Investments </div>
</div>
<mds-tag-group>
<mds-tag>Equity</mds-tag>
<mds-tag>Manager</mds-tag>
<mds-tag>Macro</mds-tag>
<mds-tag>Retirement</mds-tag>
<mds-tag>Fixed Income</mds-tag>
<mds-tag>Managed Investments</mds-tag>
</mds-tag-group>
Sizing affects text size and internal padding. The default size is small, and you can use modifier classes or props to make the tag smaller or larger.
<div class="mds-tag"> Shared </div>
<mds-tag>Shared</mds-tag>
Class |
Applies to |
Outcome |
---|---|---|
|
|
Increases text size and internal padding. |
|
|
Adds Link styling to tag text. |
|
|
Dismisses the alert by animating a fade-out effect. |
|
|
Initializes a wrapping container to properly space a group of tags. |
Tags are comprised of two separate web components, each with a dedicated API:
<mds-tag>
elements to present them as a group. Prop | Type | Validation | Default | Description |
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
Boolean |
Only valid when |
|
If true, renders a dismissibile tag. Link tags cannot be made dismissible. |
|
String |
— |
|
Allows alternate icon markup to be passed within a dismissible tag. |
|
String, Boolean |
— |
|
This switches the parent element for the tag from a |
|
String |
— |
— |
The |
|
Boolean |
Only valid when |
|
When true, removes the Tag from the DOM after the dismiss animation completes. If false, Tag is simply hidden when dismissed, not removed. |
|
String |
|
|
Alters the size of the tag. |
|
String |
Required |
— |
Sets the text that appears within the tag. Text can also be set using the default slot. If text is set via the default slot AND via the text prop, the text prop wins. |
dismissIcon
would be written as dismiss-icon
. Any text passed in between the <mds-tag></mds-tag>
tags will be used as the tag's content. This slot can only accept plain text. If no content is passed in via the slot and the text
prop is empty, the tag's text will be "undefined".
Method Name | Description |
---|---|
|
This is the same method called internally when the dismiss “X” on the tag is clicked. May be useful for a Product to querySelectorAll(‘.mds-tag’) and programatically call |
Event Name | Description |
---|---|
|
If |
|
If |
Creating a tag and making it dismissible:
<!-- Using Props -->
<mds-tag text="Components" dismissible="true"></mds-tag>
<!-- Using Slots -->
<mds-tag dismissible="true"> Components </mds-tag>
Making a tag a link and setting its size:
<!-- Using Props -->
<mds-tag text="Quantitative Research" href="/quant-research.html" size="medium"></mds-tag>
<!-- Using Slots -->
<mds-tag href="/quant-research.html" size="medium"> Quantitative Research </mds-tag>
Prop | Type | Validation | Default | Description |
---|---|---|---|---|
|
String |
— |
— |
A space-separated list of class names that will be appended to the default |
|
String |
Required |
— |
Accepts a string of HTML that will override the default slot. |
|
String |
— |
— |
The |
Pass two or more <mds-tag>
elements between the <mds-tag-group></mds-tag-group>
to set the content of the tag group. This slot can be overridden using the content
prop.
Creating a group of link tags:
<!-- Using Props -->
<mds-tag-group content='<mds-tag href="#"> Quantitative Research </mds-tag> <mds-tag href="#"> Global </mds-tag> <mds-tag href="#"> Asset Manager </mds-tag>'></mds-tag-group>
<!-- Using Slots -->
<mds-tag-group>
<mds-tag href="#"> Quantitative Research </mds-tag>
<mds-tag href="#"> Global </mds-tag>
<mds-tag href="#"> Asset Manager </mds-tag>
</mds-tag-group>
title
tag on the dismiss icon with appropriate text for screen readers like “Remove Tag” or “Dismiss Tag.” See the accessibility guidelines for MDS icons for more information.