body
#root
View Compiled
@import url("https://fonts.googleapis.com/css2?family=Wix+Madefor+Display:wght@800&display=swap");
$page-background: linear-gradient(
100deg,
color(display-p3 0.1137 0.5686 0.9882) 13.57%,
color(display-p3 0.3529 0.2118 0.7529) 98.38%
);
html {
background: $page-background;
height: 100vh;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
body {
font-family: "Wix Madefor Display", sans-serif;
color: white;
overflow: hidden;
}
h2 {
font-size: 3rem;
margin-bottom: 1rem;
margin-top: 0;
text-shadow: 2px 4px 3px rgba(0,0,0,0.3);
}
.emoji-selector {
text-align: center;
font-size: 48px;
.emoji-dropdown {
display: inline-block;
position: relative;
cursor: pointer;
width: 80px;
transition: width .6s ease-in-out;
overflow-x: wrap;
&-trigger {
border: 2px solid white;
padding: 10px;
border-radius: 4px;
}
&.open {
width: 70%;
.emoji-list {
display: block;
height: 286px;
}
.emoji-dropdown-trigger {
border-radius: 0;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
}
}
.emoji-list {
background-color: #444857;
border-bottom: 2px solid white;
border-left: 2px solid white;
border-right: 2px solid white;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
padding: 5px 0;
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
z-index: 1;
overflow-y: auto;
position: relative;
display: flex;
flex-wrap: wrap;
gap: 2ch;
.emoji {
display: inline-block;
font-size: 48px;
height: 60px;
width: 48px;
margin: 6px;
cursor: pointer;
flex: 0 0 calc(33.33% - 1ch);
&.selected {
border: 1px solid #f0f0f0;
background: $page-background;
}
}
}
.selected-emoji {
margin-bottom: auto;
flex: 1;
display: flex;
align-items: center;
justify-content: center;
}
}
lottie-player {
margin: 0 auto;
width: 50%;
}
@media (min-height: 769px) {
lottie-player {
margin: 0 auto;
width: 60%;
}
}
@media (min-height: 1026px) {
lottie-player {
width: 95%;
}
.emoji-selector .emoji-list {
max-height: 432px;
}
}
View Compiled
const { useState } = React;
const emojis = [
{
key: "1f600",
value: "๐"
},
{
key: "1f603",
value: "๐"
},
{
key: "1f604",
value: "๐"
},
{
key: "1f601",
value: "๐"
},
{
key: "1f606",
value: "๐"
},
{
key: "1f605",
value: "๐
"
},
{
key: "1f602",
value: "๐"
},
{
key: "1f923",
value: "๐คฃ"
},
{
key: "1f62d",
value: "๐ญ"
},
{
key: "1f609",
value: "๐"
},
{
key: "1f617",
value: "๐"
},
{
key: "1f619",
value: "๐"
},
{
key: "1f61a",
value: "๐"
},
{
key: "1f618",
value: "๐"
},
{
key: "1f970",
value: "๐ฅฐ"
},
{
key: "1f60d",
value: "๐"
},
{
key: "1f929",
value: "๐คฉ"
},
{
key: "1f973",
value: "๐ฅณ"
},
{
key: "1fae0",
value: "๐ซ "
},
{
key: "1f643",
value: "๐"
},
{
key: "1f642",
value: "๐"
},
{
key: "1f972",
value: "๐ฅฒ"
},
{
key: "1f979",
value: "๐ฅน"
},
{
key: "1f60a",
value: "๐"
},
{
key: "1f60c",
value: "๐"
},
{
key: "1f60f",
value: "๐"
},
{
key: "1f634",
value: "๐ด"
},
{
key: "1f62a",
value: "๐ช"
},
{
key: "1f924",
value: "๐คค"
},
{
key: "1f60b",
value: "๐"
},
{
key: "1f61b",
value: "๐"
},
{
key: "1f61d",
value: "๐"
},
{
key: "1f61c",
value: "๐"
},
{
key: "1f92a",
value: "๐คช"
},
{
key: "1f974",
value: "๐ฅด"
},
{
key: "1f614",
value: "๐"
},
{
key: "1f97a",
value: "๐ฅบ"
},
{
key: "1f62c",
value: "๐ฌ"
},
{
key: "1f611",
value: "๐"
},
{
key: "1f610",
value: "๐"
},
{
key: "1f636",
value: "๐ถ"
},
{
key: "1fae5",
value: "๐ซฅ"
},
{
key: "1f910",
value: "๐ค"
},
{
key: "1fae1",
value: "๐ซก"
},
{
key: "1f914",
value: "๐ค"
},
{
key: "1f92b",
value: "๐คซ"
},
{
key: "1fae2",
value: "๐ซข"
},
{
key: "1f92d",
value: "๐คญ"
},
{
key: "1f971",
value: "๐ฅฑ"
},
{
key: "1f917",
value: "๐ค"
},
{
key: "1fae3",
value: "๐ซฃ"
},
{
key: "1f631",
value: "๐ฑ"
},
{
key: "1f928",
value: "๐คจ"
},
{
key: "1f9d0",
value: "๐ง"
},
{
key: "1f612",
value: "๐"
},
{
key: "1f644",
value: "๐"
},
{
key: "1f624",
value: "๐ค"
},
{
key: "1f620",
value: "๐ "
},
{
key: "1f621",
value: "๐ก"
},
{
key: "1f92c",
value: "๐คฌ"
},
{
key: "1f61e",
value: "๐"
},
{
key: "1f613",
value: "๐"
},
{
key: "1f61f",
value: "๐"
},
{
key: "1f625",
value: "๐ฅ"
},
{
key: "1f622",
value: "๐ข"
},
{
key: "1f641",
value: "๐"
},
{
key: "1fae4",
value: "๐ซค"
},
{
key: "1f615",
value: "๐"
},
{
key: "1f630",
value: "๐ฐ"
},
{
key: "1f628",
value: "๐จ"
},
{
key: "1f627",
value: "๐ง"
},
{
key: "1f626",
value: "๐ฆ"
},
{
key: "1f62e",
value: "๐ฎ"
},
{
key: "1f62f",
value: "๐ฏ"
},
{
key: "1f632",
value: "๐ฒ"
},
{
key: "1f633",
value: "๐ณ"
},
{
key: "1f92f",
value: "๐คฏ"
},
{
key: "1f616",
value: "๐"
},
{
key: "1f623",
value: "๐ฃ"
},
{
key: "1f629",
value: "๐ฉ"
},
{
key: "1f62b",
value: "๐ซ"
},
{
key: "1f635",
value: "๐ต"
},
{
key: "1fae8",
value: "๐ซจ"
},
{
key: "1f976",
value: "๐ฅถ"
},
{
key: "1f975",
value: "๐ฅต"
},
{
key: "1f922",
value: "๐คข"
},
{
key: "1f92e",
value: "๐คฎ"
},
{
key: "1f927",
value: "๐คง"
},
{
key: "1f912",
value: "๐ค"
},
{
key: "1f915",
value: "๐ค"
},
{
key: "1f637",
value: "๐ท"
},
{
key: "1f925",
value: "๐คฅ"
},
{
key: "1f607",
value: "๐"
},
{
key: "1f920",
value: "๐ค "
},
{
key: "1f911",
value: "๐ค"
},
{
key: "1f913",
value: "๐ค"
},
{
key: "1f60e",
value: "๐"
},
{
key: "1f978",
value: "๐ฅธ"
},
{
key: "1f921",
value: "๐คก"
},
{
key: "1f608",
value: "๐"
},
{
key: "1f47f",
value: "๐ฟ"
},
{
key: "1f47b",
value: "๐ป"
},
{
key: "1f383",
value: "๐"
},
{
key: "1f4a9",
value: "๐ฉ"
},
{
key: "1f916",
value: "๐ค"
},
{
key: "1f47d",
value: "๐ฝ"
},
{
key: "1f31b",
value: "๐"
},
{
key: "1f31c",
value: "๐"
},
{
key: "1f31e",
value: "๐"
},
{
key: "1f525",
value: "๐ฅ"
},
{
key: "1f4af",
value: "๐ฏ"
},
{
key: "1f31f",
value: "๐"
},
{
key: "1f4a5",
value: "๐ฅ"
},
{
key: "1f389",
value: "๐"
},
{
key: "1f648",
value: "๐"
},
{
key: "1f649",
value: "๐"
},
{
key: "1f64a",
value: "๐"
},
{
key: "1f63a",
value: "๐บ"
},
{
key: "1f638",
value: "๐ธ"
},
{
key: "1f639",
value: "๐น"
},
{
key: "1f63b",
value: "๐ป"
},
{
key: "1f63c",
value: "๐ผ"
},
{
key: "1f63d",
value: "๐ฝ"
},
{
key: "1f640",
value: "๐"
},
{
key: "1f63f",
value: "๐ฟ"
},
{
key: "1f63e",
value: "๐พ"
},
{
key: "1f9e1",
value: "๐งก"
},
{
key: "1f49b",
value: "๐"
},
{
key: "1f49a",
value: "๐"
},
{
key: "1fa75",
value: "๐ฉต"
},
{
key: "1f499",
value: "๐"
},
{
key: "1f49c",
value: "๐"
},
{
key: "1f90e",
value: "๐ค"
},
{
key: "1f5a4",
value: "๐ค"
},
{
key: "1fa76",
value: "๐ฉถ"
},
{
key: "1f90d",
value: "๐ค"
},
{
key: "1fa77",
value: "๐ฉท"
},
{
key: "1f498",
value: "๐"
},
{
key: "1f49d",
value: "๐"
},
{
key: "1f496",
value: "๐"
},
{
key: "1f497",
value: "๐"
},
{
key: "1f493",
value: "๐"
},
{
key: "1f49e",
value: "๐"
},
{
key: "1f495",
value: "๐"
},
{
key: "1f48c",
value: "๐"
},
{
key: "1f494",
value: "๐"
},
{
key: "1f48b",
value: "๐"
},
{
key: "1f463",
value: "๐ฃ"
},
{
key: "1fac0",
value: "๐ซ"
},
{
key: "1fa78",
value: "๐ฉธ"
},
{
key: "1f9a0",
value: "๐ฆ "
},
{
key: "1f480",
value: "๐"
},
{
key: "1f440",
value: "๐"
},
{
key: "1fae6",
value: "๐ซฆ"
},
{
key: "1f9bf",
value: "๐ฆฟ"
},
{
key: "1f9be",
value: "๐ฆพ"
},
{
key: "1f4aa",
value: "๐ช"
},
{
key: "1f44f",
value: "๐"
},
{
key: "1f44d",
value: "๐"
},
{
key: "1f44e",
value: "๐"
},
{
key: "1f64c",
value: "๐"
},
{
key: "1f44b",
value: "๐"
},
{
key: "1f91e",
value: "๐ค"
},
{
key: "1f64f",
value: "๐"
},
{
key: "1f483",
value: "๐"
},
{
key: "1f339",
value: "๐น"
},
{
key: "1f940",
value: "๐ฅ"
},
{
key: "1f342",
value: "๐"
},
{
key: "1f331",
value: "๐ฑ"
},
{
key: "1f340",
value: "๐"
},
{
key: "1f30b",
value: "๐"
},
{
key: "1f305",
value: "๐
"
},
{
key: "1f304",
value: "๐"
},
{
key: "1f308",
value: "๐"
},
{
key: "26a1",
value: "โก"
},
{
key: "1f4ab",
value: "๐ซ"
},
{
key: "1f30d",
value: "๐"
},
{
key: "1f984",
value: "๐ฆ"
},
{
key: "1f98e",
value: "๐ฆ"
},
{
key: "1f409",
value: "๐"
},
{
key: "1f996",
value: "๐ฆ"
},
{
key: "1f422",
value: "๐ข"
},
{
key: "1f40d",
value: "๐"
},
{
key: "1f438",
value: "๐ธ"
},
{
key: "1f407",
value: "๐"
},
{
key: "1f400",
value: "๐"
},
{
key: "1f415",
value: "๐"
},
{
key: "1f416",
value: "๐"
},
{
key: "1f40e",
value: "๐"
},
{
key: "1facf",
value: "๐ซ"
},
{
key: "1f402",
value: "๐"
},
{
key: "1f410",
value: "๐"
},
{
key: "1f998",
value: "๐ฆ"
},
{
key: "1f405",
value: "๐
"
},
{
key: "1f412",
value: "๐"
},
{
key: "1f9a6",
value: "๐ฆฆ"
},
{
key: "1f987",
value: "๐ฆ"
},
{
key: "1f413",
value: "๐"
},
{
key: "1f423",
value: "๐ฃ"
},
{
key: "1f424",
value: "๐ค"
},
{
key: "1f425",
value: "๐ฅ"
},
{
key: "1f985",
value: "๐ฆ
"
},
{
key: "1fabf",
value: "๐ชฟ"
},
{
key: "1f99a",
value: "๐ฆ"
},
{
key: "1f9ad",
value: "๐ฆญ"
},
{
key: "1f42c",
value: "๐ฌ"
},
{
key: "1f433",
value: "๐ณ"
},
{
key: "1f421",
value: "๐ก"
},
{
key: "1f980",
value: "๐ฆ"
},
{
key: "1f419",
value: "๐"
},
{
key: "1fabc",
value: "๐ชผ"
},
{
key: "1f40c",
value: "๐"
},
{
key: "1f41c",
value: "๐"
},
{
key: "1f99f",
value: "๐ฆ"
},
{
key: "1f41d",
value: "๐"
},
{
key: "1f98b",
value: "๐ฆ"
},
{
key: "1f43e",
value: "๐พ"
},
{
key: "1f345",
value: "๐
"
},
{
key: "1f37f",
value: "๐ฟ"
},
{
key: "1f37b",
value: "๐ป"
},
{
key: "1f942",
value: "๐ฅ"
},
{
key: "1f37e",
value: "๐พ"
},
{
key: "1f377",
value: "๐ท"
},
{
key: "1f379",
value: "๐น"
},
{
key: "1f6a8",
value: "๐จ"
},
{
key: "1f6f8",
value: "๐ธ"
},
{
key: "1f680",
value: "๐"
},
{
key: "1f6eb",
value: "๐ซ"
},
{
key: "1f6ec",
value: "๐ฌ"
},
{
key: "1f3a2",
value: "๐ข"
},
{
key: "1f38a",
value: "๐"
},
{
key: "1f388",
value: "๐"
},
{
key: "1f382",
value: "๐"
},
{
key: "1f386",
value: "๐"
},
{
key: "1faa9",
value: "๐ชฉ"
},
{
key: "26bd",
value: "โฝ"
},
{
key: "1f3af",
value: "๐ฏ"
},
{
key: "1f3bb",
value: "๐ป"
},
{
key: "1f941",
value: "๐ฅ"
},
{
key: "1fa87",
value: "๐ช"
},
{
key: "1f50b",
value: "๐"
},
{
key: "1faab",
value: "๐ชซ"
},
{
key: "1f4b8",
value: "๐ธ"
},
{
key: "1f4a1",
value: "๐ก"
},
{
key: "1f393",
value: "๐"
},
{
key: "1f48e",
value: "๐"
},
{
key: "23f0",
value: "โฐ"
},
{
key: "1f514",
value: "๐"
},
{
key: "274c",
value: "โ"
},
{
key: "1f3b6",
value: "๐ถ"
},
{
key: "1f192",
value: "๐"
},
{
key: "1f3c1",
value: "๐"
},
{
key: "2615",
value: "โ"
},
{
key: "2705",
value: "โ
"
},
{
key: "2728",
value: "โจ"
},
{
key: "2648",
value: "โ"
},
{
key: "2649",
value: "โ"
},
{
key: "2650",
value: "โ"
},
{
key: "2651",
value: "โ"
},
{
key: "2652",
value: "โ"
},
{
key: "2653",
value: "โ"
},
{
key: "2795",
value: "โ"
},
{
key: "264a",
value: "โ"
},
{
key: "264b",
value: "โ"
},
{
key: "264c",
value: "โ"
},
{
key: "264d",
value: "โ"
},
{
key: "264e",
value: "โ"
},
{
key: "264f",
value: "โ"
},
{
key: "26ce",
value: "โ"
}
];
const EmojiDropdown = ({
isDropdownOpen,
toggleDropdown,
emojis,
selectedEmoji,
handleEmojiSelect
}) => {
const currentEmoji =
emojis?.find((emoji) => emoji.key === selectedEmoji)?.value || "";
return (
<div className={`emoji-dropdown ${isDropdownOpen ? "open" : ""}`}>
<div className="emoji-dropdown-trigger" onClick={toggleDropdown}>
{currentEmoji}
</div>
{isDropdownOpen && (
<div className="emoji-list">
{emojis.map(({ key, value }) => (
<span
key={key}
className={`emoji ${selectedEmoji === key ? "selected" : ""}`}
onClick={() => handleEmojiSelect(key)}
>
{value}
</span>
))}
</div>
)}
</div>
);
};
const EmojiDisplay = ({ selectedEmoji }) => {
return (
<div className="selected-emoji">
{selectedEmoji && (
<div key={selectedEmoji}>
<lottie-player
key={`lottie-${selectedEmoji}`}
src={`https://fonts.gstatic.com/s/e/notoemoji/latest/${selectedEmoji}/lottie.json`}
autoplay
loop
/>
</div>
)}
</div>
);
};
const EmojiSelector = () => {
const [selectedEmoji, setSelectedEmoji] = useState("1f92f");
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const handleEmojiSelect = (unicodeValue) => {
setSelectedEmoji(unicodeValue);
setIsDropdownOpen(false);
};
const toggleDropdown = () => {
setIsDropdownOpen((prevIsOpen) => !prevIsOpen);
};
return (
<div className="emoji-selector">
<h2>Select an Emoji...</h2>
<EmojiDropdown
isDropdownOpen={isDropdownOpen}
toggleDropdown={toggleDropdown}
emojis={emojis}
selectedEmoji={selectedEmoji}
handleEmojiSelect={handleEmojiSelect}
/>
{!isDropdownOpen && <EmojiDisplay selectedEmoji={selectedEmoji} />}
</div>
);
};
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<EmojiSelector />);
View Compiled
This Pen doesn't use any external CSS resources.