Mark
The Mark
component can is a styled version of the
mark HTMLElement.
Typical use cases for
<mark>
include:
When used in a quotation (
<q>
) or block quote (<blockquote>
), it generally indicates text which is of special interest but is not marked in the original source material, or material which needs special scrutiny even though the original author didn't think it was of particular importance. Think of this like using a highlighter pen in a book to mark passages that you find of interest.Otherwise,
<mark>
indicates a portion of the document's content which is likely to be relevant to the user's current activity. This might be used, for example, to indicate the words that matched a search operation.Don't use
<mark>
for syntax highlighting purposes; instead, use the<span>
element with appropriate CSS applied to it.Note: Don't confuse
<mark>
with the<strong>
element;<mark>
is used to denote content which has a degree of relevance, while<strong>
indicates spans of text of importance.
Simple Example
Wrap any children with the Mark
component to apply the styles.
Search results for "salamander":
Several species of salamander inhabit the temperate rainforest of the Pacific Northwest.
Most salamanders are nocturnal, and hunt for insects, worms, and other small creatures.
import { Divider } from "@react-md/core/divider/Divider";
import { Mark } from "@react-md/core/typography/Mark";
import { Typography } from "@react-md/core/typography/Typography";
import { type ReactElement } from "react";
export default function SimpleExample(): ReactElement {
return (
<div>
<Typography>{'Search results for "salamander":'}</Typography>
<Divider />
<Typography>
Several species of <Mark>salamander</Mark> inhabit the temperate
rainforest of the Pacific Northwest.
</Typography>
<Typography>
Most <Mark>salamander</Mark>s are nocturnal, and hunt for insects,
worms, and other small creatures.
</Typography>
</div>
);
}
Customizing Styles Example
The mark styles can be updated just like the Typography component:
- there is a core.$mark-recommended-styles map that will be merged with a
configurable core.$mark-custom-styles map where the
mark-custom-styles
would override any values in themark-recommended-styles
. - if all styles should be customized, configure the core.$mark-styles map instead
Search results for "salamander":
Several species of salamander inhabit the temperate rainforest of the Pacific Northwest.
Most salamanders are nocturnal, and hunt for insects, worms, and other small creatures.