All Projects → SeanMcP → a11y-react-emoji

SeanMcP / a11y-react-emoji

Licence: MIT license
⚛️ An accessible Emoji component for React applications

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to a11y-react-emoji

Dragon Drop
Accessible drag and drop list reorder module
Stars: ✭ 385 (+457.97%)
Mutual labels:  a11y, accessible
Chakra Ui
⚡️Simple, Modular & Accessible UI Components for your React Applications
Stars: ✭ 295 (+327.54%)
Mutual labels:  a11y, accessible
tobii
An accessible, open-source lightbox with no dependencies
Stars: ✭ 132 (+91.3%)
Mutual labels:  a11y, accessible
Handorgel
Accessible W3C conform accordion written in ES6.
Stars: ✭ 239 (+246.38%)
Mutual labels:  a11y, accessible
Bootstrap Vue
BootstrapVue provides one of the most comprehensive implementations of Bootstrap v4 for Vue.js. With extensive and automated WAI-ARIA accessibility markup.
Stars: ✭ 13,603 (+19614.49%)
Mutual labels:  a11y, accessible
Reakit
Toolkit for building accessible rich web apps with React
Stars: ✭ 5,265 (+7530.43%)
Mutual labels:  a11y, accessible
Chakra Ui
⚡️ Simple, Modular & Accessible UI Components for your React Applications
Stars: ✭ 22,745 (+32863.77%)
Mutual labels:  a11y, accessible
A11y accordions
ES5 ARIA Accordion Component
Stars: ✭ 108 (+56.52%)
Mutual labels:  a11y, accessible
Tobi
An accessible, open-source lightbox with no dependencies.
Stars: ✭ 195 (+182.61%)
Mutual labels:  a11y, accessible
mr-emoji
Lightweight emoji picker like SLACK
Stars: ✭ 23 (-66.67%)
Mutual labels:  emoji, emoji-component
purescript-emo8
🍠 A functional 2D game engine that can create emoji games.
Stars: ✭ 47 (-31.88%)
Mutual labels:  emoji
rgaa methodologie
[archivé] Méthodologie de tests pour la version 3 du RGAA
Stars: ✭ 15 (-78.26%)
Mutual labels:  a11y
slack-emoji-import
Simple bulk emoji importer for slack
Stars: ✭ 35 (-49.28%)
Mutual labels:  emoji
emojix
Simple emoji library for Elixir 💩
Stars: ✭ 21 (-69.57%)
Mutual labels:  emoji
spacymoji
💙 Emoji handling and meta data for spaCy with custom extension attributes
Stars: ✭ 174 (+152.17%)
Mutual labels:  emoji
accessibility-resources
Screen reader and WCAG testing resources to maintain a consistent approach to testing and documenting behaviour.
Stars: ✭ 25 (-63.77%)
Mutual labels:  a11y
Tanaguru
Automated accessibility (a11y) testing tool, with emphasis on reliablity and automation
Stars: ✭ 116 (+68.12%)
Mutual labels:  a11y
gifa11y
Gifa11y is a customizable vanilla javascript plugin that easily adds accessible play/pause buttons to animated GIFs.
Stars: ✭ 23 (-66.67%)
Mutual labels:  a11y
EmojiRunner
Search for emojis in Krunner and copy/paste them
Stars: ✭ 33 (-52.17%)
Mutual labels:  emoji
vemdezapbe.be
Vem de zap bb 😏😊😂
Stars: ✭ 33 (-52.17%)
Mutual labels:  emoji

a11y-react-emoji

npm npm bundle size (minified) npm

⚛️ An accessible Emoji component for React applications

Why?

Emojis can add a light playfulness to your project but require some specific formatting in order to ensure they are accessible for all users. a11y-react-emoji's reusable Emoji component helps you do that quickly and painlessly.

How

The Emoji component wraps the provided symbol in a span with a role="img" attribute. If a label is provided, then it is passed as an aria-label to the span. If not, then aria-hidden is set to true.

<span aria-label="a rocket blasting off" role="img">🚀</span>
<span aria-hidden="true" role="img">🤫</span>

This follows the pattern recommended by Léonie Watson and used by eslint-plugin-jsx-a11y.

Installation

Add a11y-react-emoji to your project:

npm install --save a11y-react-emoji
# or
yarn add a11y-react-emoji

Use

Import Emoji, a default export, from a11y-react-emoji and add it to your code:

...
import Emoji from 'a11y-react-emoji'

function HeartFooter() {
    return (
        <footer>
            Made with
            {' '}
            <Emoji symbol="💕" label="love" />
            {' '}
            by Sean McPherson
        </footer>
    )
}

The named EmojiProps type interface is also available for import if needed:

import Emoji, { EmojiProps } from 'a11y-react-emoji'

Emoji component

The Emoji component consumes two props: symbol and label. Every other prop is spread to the top-level JSX element, in this case a <span>.

interface Props extends React.HTMLAttributes<HTMLSpanElement> {
    label?: string; // optional
    symbol: string; // required
}

Considerations

If you are using a11y-react-emoji with a CSS-in-JS library like styled-components or emotion, keep in mind that all additional props are passed to the JSX element.

Styling an Emoji with styled-components

import styled, { css } from 'styled-components'
import Emoji from 'a11y-react-emoji'

const StyledEmoji = styled(({ isSpinning, ...props }) => <Emoji {...props} />)`
    font-size: 32px;

    ${props => props.isSpinning && css`
        animation: spinning 1s linear infinite;
    `}
`

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].