No description
  • JavaScript 51.9%
  • TypeScript 43.3%
  • Dockerfile 4.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Marie Lucca 552633566c
Merge pull request #87 from github/dependabot/npm_and_yarn/npm_and_yarn-b448f38fe0
Bump ws from 8.17.1 to 8.21.1 in the npm_and_yarn group across 1 directory
2026-07-14 23:33:28 -04:00
.devcontainer Add a .devcontainer 2022-02-28 17:04:42 +00:00
.github/workflows Update publish.yml 2026-05-08 13:19:11 -07:00
examples Add script tag for gh-pages 2020-06-01 18:07:15 -04:00
script Convert to TypeScript 2020-05-21 17:43:22 -04:00
src Export tone modifiers 2024-08-23 14:02:15 +00:00
test Fix CI: remove chromium devDep, update workflow to Node 20, update actions 2026-03-13 20:51:45 +00:00
.eslintrc.json Turn off github/no-inner-html for tests 2022-04-05 12:33:39 +01:00
.gitignore Initial commit 2018-07-25 16:51:57 -04:00
CODEOWNERS move AOR to primer 2022-09-23 18:39:08 +01:00
LICENSE Initial commit 2018-07-25 16:51:57 -04:00
package-lock.json Fix CI: add skipLibCheck to tsconfig.json to handle @types/ws compatibility 2026-07-15 03:23:05 +00:00
package.json Fix CI: remove chromium devDep, update workflow to Node 20, update actions 2026-03-13 20:51:45 +00:00
README.md Replace image with glyph for clarity 2019-10-24 18:52:37 -04:00
rollup.config.js Convert to TypeScript 2020-05-21 17:43:22 -04:00
tsconfig.json Fix CI: add skipLibCheck to tsconfig.json to handle @types/ws compatibility 2026-07-15 03:23:05 +00:00

<g-emoji> element

Backports native emoji characters to browsers that don't support them by replacing the characters with fallback images.

Installation

$ npm install @github/g-emoji-element

Usage

import '@github/g-emoji-element'
<g-emoji fallback-src="t-rex.png" alias="T-Rex">🦖</g-emoji>

If a browser supports emoji, nothing happens. If a browser does not support emoji, a fallback image tag is created:

<g-emoji fallback-src="t-rex.png" alias="T-Rex">
  <img class="emoji" alt="T-Rex" height="20" width="20" src="t-rex.png">
</g-emoji>

Skin tones

The tone attribute renders the emoji with a skin tone modifier between 1-5. Use 0 to display the default tone.

<g-emoji tone="0">👋</g-emoji>
<g-emoji tone="1">👋🏻</g-emoji>
<g-emoji tone="2">👋🏼</g-emoji>
<g-emoji tone="3">👋🏽</g-emoji>
<g-emoji tone="4">👋🏾</g-emoji>
<g-emoji tone="5">👋🏿</g-emoji>
> const emoji = document.createElement('g-emoji')
> emoji.textContent = '👋'
> emoji.tone = '5'
> document.body.append(emoji)
> emoji.textContent
"👋🏿"

The tone attribute accepts a space separated list of skin tone modifiers to apply to each base emoji in a sequence. Some platforms will display these sequences as a single glyph while others will render each emoji in the sequence.

<g-emoji tone="4 5">🧑🏾<200d>🤝<200d>🧑🏿</g-emoji>

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.