最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to render emoji using Unicode in ReactJS? - Stack Overflow

programmeradmin0浏览0评论

In ReactJS, there is unicode table for the emojis and tried following this / so made the attempt to render the rocket emoji (which has unicode: U+1F680 but converted to css content: \01F680) with:

<div style={{content: '\01F680'}}></div>

But I got an error. Is this the right way to do it?

EDIT

I want to create a round/circle button with the emoji centered to the middle of it.

CSS for the button:

#emoji-button {
  border-radius: 19px;
  width: 38px;
  height: 38px;
}

And round/circle button:

<button
  type="submit"
  id="emoji-button"
/>

And is there a way to create just the emoji image itself clickable?

EDIT

With CSS as you suggested:

#emoji-button {
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 30px;
  text-align: center;
  background-color: white;
  border:0;
  position: absolute;
  right: -60px;
}

#emoji-button:before {
  content: "\01F426";
}

In ReactJS, there is unicode table for the emojis http://apps.timwhitlock.info/emoji/tables/unicode and tried following this https://css-tricks./emoji-toggles/ so made the attempt to render the rocket emoji (which has unicode: U+1F680 but converted to css content: \01F680) with:

<div style={{content: '\01F680'}}></div>

But I got an error. Is this the right way to do it?

EDIT

I want to create a round/circle button with the emoji centered to the middle of it.

CSS for the button:

#emoji-button {
  border-radius: 19px;
  width: 38px;
  height: 38px;
}

And round/circle button:

<button
  type="submit"
  id="emoji-button"
/>

And is there a way to create just the emoji image itself clickable?

EDIT

With CSS as you suggested:

#emoji-button {
  font-size: 15px;
  width: 30px;
  height: 30px;
  border-radius: 30px;
  text-align: center;
  background-color: white;
  border:0;
  position: absolute;
  right: -60px;
}

#emoji-button:before {
  content: "\01F426";
}
Share Improve this question edited Sep 10, 2016 at 22:12 asked Sep 9, 2016 at 20:45 user2423124user2423124
Add a ment  | 

3 Answers 3

Reset to default 5

I am not sure if this is what you are looking for but i found this to be a good way to add Emoji in reactJS, especially so you don't have a ESLint fail message:

发布评论

评论列表(0)

  1. 暂无评论