How To Implement Emoji In Angular

What Is Emoji And Why We Need It?

“An emoji is a pictogram, logogram, ideogram, or smiley embedded in the text and used in electronic messages and web pages. The primary function of emoji is to fill in emotional cues otherwise missing from the typed conversation.” —Wikipedia.

An emoji is a visual representation of objects, symbols, and emotions. It helps to replace your words with graphical representation. Because of their rich emotional meaning, emoji is very useful for online conversation.

Now a day, people are using emojis for giving personality to the messages. In the modern era such as smartphones and other social media platforms like Facebook, Instagram, Snapchat, etc are using a large number of emojis in daily communications.

Get Started.

Step 1: Create a new Angular project.

ng new Emoji-Icon

We use here an Angular Material. If you want to learn about how to implement Angular Material to your project then click here.

Step 2: Install emoji-picker-element

Using CLI.

npm install emoji-picker-element

Using <script> tag.

<script type="module" src="^1/index.js"></script>

Step 3: Import the Picker in your app.component.ts

import { Component } from '@angular/core';
import { Picker } from 'emoji-picker-element';

  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
export class AppComponent {

  picker = new Picker();
  emojiInput: string = '';

  addEmoji(event: any) {
    this.emojiInput += event?.detail?.unicode;

  emojiPreventClose($event: any) {

Step 4: Define <emoji-picker> in your app.component.html

<div class="main-icon">
  <mat-form-field appearance="outline">
    <mat-label>Emoji Picker</mat-label>
    <input matInput [(ngModel)]="emojiInput">
    <mat-icon matSuffix [matMenuTriggerFor]="emojiIcon">sentiment_very_satisfied</mat-icon>
  <mat-menu #emojiIcon="matMenu" class="emoji-menu">
    <emoji-picker class="light" (emoji-click)="addEmoji($event)" (click)="emojiPreventClose($event);"></emoji-picker>

Now, you have done all things. You can run the project and you will be able to use the emoji icons.

You can also give custom styles to your emoji.


emoji-picker-element uses Shadow Dom. So you can style the emoji only from the global CSS Stylesheet.


emoji-picker-element has a default size. But you can change it whatever you want.

 width: 500px;
 height: 500px;

To expand the size of emoji in whatever container you give.


Dark mode:

By default, the emoji picker has a light mode. But you can easily switch it into dark mode by prefers-color-scheme. Or you can also give class to forcibly switch modes.

<emoji-picker class="dark"></emoji-picker>

<emoji-picker class="light"></emoji-picker>


Here we learn what is emoji, use and how to implement emoji in our Angular project. We also see that how to style the emoji-picker-element. Remember that emoji-picker-element uses Shadow DOM, so you need to style the main stylesheet. You can also switch dark and light modes.

1 Comment

  1. Andongwisye

    I like this article, saved my application performance issue. I looked to the emoji package to use for my web apps in angular this is the best


Submit a Comment

Your email address will not be published. Required fields are marked *


Select Categories