EmojiText
😃 Render Custom Emoji in Text
Install / Use
/learn @divadretlaw/EmojiTextREADME
EmojiText
Render Custom Emoji in
- SwiftUI with
EmojiText - UIKit with
EmojiLabelorEmojiTextView - AppKit with
EmojiTextFieldorEmojiTextView
Supports local and remote emojis.
Usage
Remote emoji
EmojiText(
verbatim: "Hello :my_emoji:",
emojis: [RemoteEmoji(shortcode: "my_emoji", url: /* URL to emoji */)]
)
Local emoji
EmojiText(
verbatim: "Hello :my_emoji:",
emojis: [LocalEmoji(shortcode: "my_emoji", image: /* some UIImage or NSImage */)]
)
SF Symbol
EmojiText(
verbatim: "Hello Moon & Starts :moon.stars:",
emojis: [SFSymbolEmoji(shortcode: "moon.stars")]
)
Markdown
Also supports Markdown
EmojiText(
markdown: "**Hello** *World* :my_emoji:",
emojis: [RemoteEmoji(shortcode: "my_emoji", url: /* URL to emoji */)]
)
Animated Emoji
[!WARNING] This feature is in beta and therefore is opt-in only. Performance may vary.
Currently only UIKit platforms support animated emoji.
Enable animation by setting adding the .animated() modifier to EmojiText.
EmojiText(
verbatim: "GIF :my_gif:",
emojis: [RemoteEmoji(shortcode: "my_gif", url: /* URL to gif */)]
)
.animated()
Supported formats:
- APNG
- GIF
- WebP
[!INFO] The animation will automatically pause when using low-power mode. To always play animations, even in low-power mode set the animation mode to
AnimatedEmojiMode.alwaysEmojiText( verbatim: "GIF :my_gif:", emojis: [RemoteEmoji(shortcode: "my_gif", url: /* URL to gif */)] ) .animated() .environment(\.emojiText.AnimatedMode, .always)
Configuration
Remote emojis are replaced by a placeholder image when loading. Default is the SF Symbol square.dashed but you can overide the placeholder image with
.emojiText.placeholder(systemName: /* SF Symbol */)
or
.emojiText.placeholder(image: /* some UIImage or NSImage */)
Remote emojis use URLSession.shared to load them, but you can provide a custom URLSession
.environment(\.emojiText.asyncEmojiProvider, DefaultAsyncEmojiProvider(session: myUrlSession))
You can also replace the remote image loading and caching entirely. For example with Nuke
.environment(\.emojiText.asyncEmojiProvider, NukeEmojiProvider())
See NukeEmojiProvider in the Test-App for a reference implementation of a AsyncEmojiProvider using Nuke.
License
See LICENSE
Related Skills
node-connect
346.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
346.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
346.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
