Last active
September 1, 2022 07:46
-
-
Save luismartinezs/48269bd43c9fc3139c824edea314a0be to your computer and use it in GitHub Desktop.
React a11y emoji #react #a11y
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://medium.com/@seanmcp/%EF%B8%8F-how-to-use-emojis-in-react-d23bbf608bf7 | |
import React from 'react'; | |
const Emoji = props => ( | |
<span | |
className="emoji" | |
role="img" | |
aria-label={props.label ? props.label : ""} | |
aria-hidden={props.label ? "false" : "true"} | |
> | |
{props.symbol} | |
</span> | |
); | |
export default Emoji; | |
// Usage | |
<> | |
<Emoji symbol="🐑" label="sheep"/> | |
{/* or */} | |
<Emoji symbol="🐑"/> | |
</> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment