amitsolanki24_'s avatar

Add emoji icons on input field

I've added emoji icons on a textarea through unicode characters. My emojis are displaying correctly in india country but some emojis are showing different in different countries (like dark color and shadow and also changed emojis dimensions).

How can i fix this problem.

0 likes
14 replies
gych's avatar

Its normal, emoji icons if used with unicode can be different between devices,browsers and coutnries

If you want the same emojis for all platforms and countries you have to use image emoji icons

1 like
amitsolanki24_'s avatar

@gych if I use image emoji icons so I also need to store emoji images into storage. I think this is not good to store.

Can you provide me any other solution like some js library to display emojis (like Facebook or WhatsApp) but I dont want gif. Only 10-20 emoji are enough for me.

gych's avatar

@amitsolanki24_ Yes twemoji is currently still the best, its originally created by twitter and discord also uses it.

Just a note, I checked the original repository and seems like the original temoji repo by twitter is not longer being maintaned. This is because when twitter became X a lot of devs were removed.

Its better to use this instead https://github.com/jdecked/twemoji

Its a fork from the original twemoji repository maintained by former twitter employee. This also contains the latest update also supports unicode 15.0 spec

1 like
gych's avatar

@amitsolanki24_ You can try by using noto (noto color emoji) font by Google, I think twemoji also has a font available for this but not sure if its still getting maintained so for a font I would choose the font by google.

Check this page for Noto font, it has instructions on how to use it: https://fonts.google.com/selection/embed

You can first test it without downloading the font to see if its works.

amitsolanki24_'s avatar

@gych

I need to store all html of a comment if I want to display emoji same across all browsers and devices right when I using twemoji?

<div contenteditable="true" class="form-control border-0 editableDiv pl-1" data-placeholder="Add comment..."> <img draggable="false" class="emoji" alt="😍" src="https://twemoji.maxcdn.com/v/14.0.2/72x72/1f60d.png"> <img draggable="false" class="emoji" alt="😎" src="https://twemoji.maxcdn.com/v/14.0.2/72x72/1f60e.png"></div>

gych's avatar

@amitsolanki24_

See these examples if you want to use the main twemijo package:

There's also a community project made of twemoji which lets u use classes like font awesome https://github.com/SebastianAigner/twemoji-amazing

And you can also try Noto font from google as I already mentioned in my previous reply

amitsolanki24_'s avatar

@gych when I stored text into database should I save only unicode characters for emoji or stored img tags parse by twemoji and whenever I want to display it than use twemoji parse() function

gych's avatar

@amitsolanki24_ Only save the unicode in the database when using twemoji.parse() it will convert the unicode to twemoji

Please or to participate in this conversation.