Lordicon
  • Icons
  • Docs
  • Resources
  • Pricing
Log in Sign up Log in
React Native
  • Foundations
  • Icon styles
  • Animation
  • Formats
  • Best practices
  • Integrations
  • Web
  • React
  • React Native
  • Plugins
  • WordPress
  • Figma
  • Google Docs & Slides
  • Support
  • Licenses
  • Account and Billing
  • Library
  • Troubleshooting

React Native

Lordicon React Native makes it easy to add and control animated icons in your iOS and Android applications. It uses the <LordIcon> component to display and interact with icons in Lottie JSON format, powered by a native rendering engine for consistent animations across devices.

The component also supports react-native-web, allowing you to use the same animated icons in both mobile and web applications.

To get started, you need the Lordicon React Native package and your icon's Lottie JSON file.

Building a regular website, not a mobile app? Our React package, or the <lord-icon> element for any other site, will be easier to work with. They're made for the browser: lighter, with triggers that react to hover and to the page as you'd expect.

Quick start

You need React Native 0.82 or newer, with the New Architecture, and React 19.

With Expo:

npx expo install @lordicon/react-native
npx expo run:ios       # or run:android

The package has native code, so it runs in a development build, not in Expo Go. No config plugin is needed.

Without Expo:

npm install @lordicon/react-native
cd ios && pod install

Download the icon's JSON from its page on Lordicon, put it with your app's code and import it:

import { LordIcon } from "@lordicon/react-native";
import lock from "./icons/lock.json";

export function Hero() {
    return <LordIcon icon={lock} trigger="loop" size={48} />;
}

The icon plays over and over. size sets its width and height, 32 by default. Without a trigger, the icon stays still on its first frame.

States

Most icons hold more than one animation. We call them states, and their names tell you what they are for:

  • in-… for an entrance, like in-reveal
  • hover-… for a short effect that plays once, like hover-jump
  • loop-… for an animation that repeats nicely
  • morph-… for a change into another look and back

You can see an icon's states on its page on Lordicon. Pick one with state:

<LordIcon icon={coins} state="loop-spin" trigger="loop" />

Without state the icon plays its default one.

By default Lordicon downloads the icon with only the animation you picked, and with its colors and stroke fixed. That's all you need if you set them on Lordicon before downloading. To use several states of one icon, or to change colors or stroke in your app, choose the "Raw" format when you download it.

Playing an icon

An icon can play in three ways, depending on what it's for:

The icon should…

Use

animate on its own

a trigger, such as in or loop

react to a tap on a button

play() from the button, or LordIcon.Target

show something in your app: on or off, busy, a count

value

In the snippets below, heart, bell and the like are icon files, imported as in Quick start.

On its own

The simplest triggers need nothing else:

// once, when it comes into view
<LordIcon icon={bulb} trigger="in" />
// over and over
<LordIcon icon={spinner} trigger="loop" />
// with a pause between rounds
<LordIcon icon={cog} state="hover-mechanic" trigger="loop(1500)" />

The number in parentheses is the pause in milliseconds. Loops run inside the engine, so they stay smooth even when your JavaScript is busy.

Taps

In React Native a tap belongs to the button, not to what's inside it. So an icon in a button doesn't know it was tapped. There are two ways to tell it.

Any button, including ones from a UI library: play the icon from onPress, with a ref.

import { useRef } from "react";
import { Pressable } from "react-native";
import { LordIcon, type LordIconHandle } from "@lordicon/react-native";
import download from "./icons/download.json";

function DownloadButton() {
    const icon = useRef<LordIconHandle>(null);

    return (
        <Pressable onPress={() => icon.current?.play()}>
            <LordIcon ref={icon} icon={download} />
        </Pressable>
    );
}

A button of your own: use LordIcon.Target in place of its Pressable. It's a Pressable with no look of its own that tells the icons inside when they're tapped. Swap it in once, in your button component:

import type { ReactNode } from "react";
import { Text, type PressableProps } from "react-native";
import { LordIcon } from "@lordicon/react-native";

type ButtonProps = PressableProps & { label: string; children?: ReactNode };

function Button({ label, children, ...props }: ButtonProps) {
    return (
        <LordIcon.Target {...props}>
            {children}
            <Text>{label}</Text>
        </LordIcon.Target>
    );
}

From then on, any icon in that button plays its trigger when the button is tapped, before your onPress runs:

<Button
    label="Share"
    onPress={() => Share.share({ message: "https://lordicon.com" })}
>
    <LordIcon icon={share} trigger="click" />
</Button>

click plays on every tap. For a button that switches something on and off, such as a like, use value instead (see below): the icon then stays in its new look.

On a phone, hover, morph, boomerang and loop-on-hover play on a tap. With a mouse or a keyboard (on the web, on a tablet, on a TV) they react to the pointer and focus, as on a website.

Following your app

This is the most useful one in an app. Give the icon a piece of your state as value. When the value changes, the icon plays what fits, and you never call play().

Start with a toggle. A true or false value with a morph-… state goes to the second look and back:

<LordIcon icon={star} state="morph-select" value={saved} />

When the screen first shows, the icon starts in the look that matches the value, without animating. A post saved earlier shows a filled star right away.

Other values work too:

  • true or false with a loop-… state loops while it's true, and finishes its round when it turns false. For something in progress: <LordIcon icon={upload} state="loop-cycle" value={busy} />
  • A number plays when it goes up. For counts and badges: <LordIcon icon={bell} value={unread} />
  • A string picks a state for each value, for the stages of a task. You name the states in the trigger: trigger="follow(busy=loop-cycle, done=morph-check)", with value={stage}.

Colors and themes

<LordIcon icon={lock} colors={{ primary: '#e5484d', secondary: '#3e63dd' }} />
<LordIcon icon={lock} color="#3e63dd" />
<LordIcon icon={lock} stroke="bold" speed={2} />
  • colors changes the icon's named colors, such as primary and secondary.
  • color draws the whole icon in one color, like a tinted image. It works with every icon file.
  • stroke sets the line width: light, regular or bold.
  • speed speeds it up or slows it down: 2 is twice as fast.

All of them change live, without loading the icon again.

To give every icon in your app the same look, wrap it in LordIconProvider. An icon's own props still win. This is the easy way to handle dark mode:

import { useColorScheme } from "react-native";
import { LordIconProvider } from "@lordicon/react-native";

export default function Root() {
    const dark = useColorScheme() === "dark";

    return (
        <LordIconProvider color={dark ? "#ffffff" : "#121331"}>
            <App />
        </LordIconProvider>
    );
}

In an app

Tab bars

A tab's icon can morph when its tab is chosen and back when it's left. useTabFocus() gives you that as a value, for React Navigation and for Tabs in Expo Router:

import { Tabs } from "expo-router";
import {
    LordIcon,
    useTabFocus,
    type FocusSource,
    type LordIconProps,
} from "@lordicon/react-native";
import home from "@/assets/icons/home.json";
import cart from "@/assets/icons/cart.json";

const icons: Record<string, object> = { index: home, cart };

function TabIcon({
    navigation,
    ...props
}: LordIconProps & { navigation: FocusSource }) {
    return (
        <LordIcon
            {...props}
            state="morph-select"
            value={useTabFocus(navigation)}
        />
    );
}

export default function TabLayout() {
    return (
        <Tabs
            screenOptions={({ route, navigation }) => ({
                tabBarIcon: ({ color, size }) => (
                    <TabIcon
                        icon={icons[route.name]}
                        navigation={navigation}
                        color={color}
                        size={size}
                    />
                ),
            })}
        />
    );
}

icons maps each route to its icon; the tab bar passes its own color and size.

Native tab bars (NativeTabs in Expo Router, which the default Expo template starts with) only take system symbols and images. For animated icons, use Tabs.

Lists

In a list that recycles its rows, such as FlashList or LegendList, give the icon the item's key. A reused row then shows its new item's state right away, instead of animating to it:

<LordIcon
    icon={check}
    state="morph-select"
    value={item.done}
    recyclingKey={item.id}
/>

Each icon file is loaded once, however many rows show it.

Ref and events

You've already seen the ref used for taps. play() also takes a state, and returns a promise that tells you whether the animation played to its end. So you can wait for it before doing something else:

function DeleteButton({ onDelete }: { onDelete: () => void }) {
    const icon = useRef<LordIconHandle>(null);

    async function remove() {
        await icon.current?.play({ state: "morph-trash-full" });
        onDelete(); // runs once the bin has filled
    }

    return (
        <Pressable onPress={remove}>
            <LordIcon ref={icon} icon={trash} />
        </Pressable>
    );
}

The player also has pause(), stop() and seek(). Events have props of their own: onReady, onComplete and onError.

<LordIcon icon={trash} onComplete={() => console.log("finished")} />

The full list is in the package README.

More ways to play

An entrance first

intro plays an entrance once the icon is in view, then the trigger takes over. A growing delay makes a list of cards enter one after another:

function CardList({
    cards,
}: {
    cards: { id: string; title: string; icon: object }[];
}) {
    return cards.map((card, index) => (
        <View key={card.id}>
            <LordIcon
                icon={card.icon}
                intro={`in-reveal, delay=${index * 200}`}
            />
            <Text>{card.title}</Text>
        </View>
    ));
}

A sequence

sequence plays a short script of steps, separated by commas: play a state, wait some milliseconds, and stop. Without stop the script repeats.

<LordIcon
    icon={download}
    trigger="sequence(play in-reveal, wait 600, play hover-slide, stop)"
/>

Your own trigger

When nothing above fits, write a trigger of your own. It listens for signals (a tap, the icon coming into view, the value) and plays the icon:

import {
    BaseTrigger,
    defineTrigger,
    type TriggerContext,
} from "@lordicon/react-native";

class Bin extends BaseTrigger {
    #full = false;

    constructor(context: TriggerContext) {
        super(context);
        this.on("press", () => {
            this.#full = !this.#full;
            this.player.play({
                state: this.#full
                    ? "morph-trash-full"
                    : "morph-trash-full-to-empty",
            });
        });
    }
}

defineTrigger("bin", Bin);
<LordIcon.Target>
    <LordIcon icon={trash} trigger="bin" />
</LordIcon.Target>

Everything a trigger can listen to is in the README.

On the web

With react-native-web, the same icons run in the browser. The engine there is a WebAssembly file and a worker, which ship with the package.

With Vite or webpack there's nothing to do. Expo web doesn't copy these files for you, so add a script that does it after every install:

"scripts": { "postinstall": "lordicon-assets public/lordicon" }

and tell the provider where they are:

<LordIconProvider assets="/lordicon/">…</LordIconProvider>

Performance

You don't need to do anything. Icons are drawn on a background thread, so even many animating icons don't slow your app down. Icons off screen aren't drawn at all, and icons from the same file share one copy in memory. If you need to tune it (frame rate, threads, cache), LordIconProvider takes a render option; see the README.

Examples

The example app has one screen per topic. It runs on Android, iOS and in the browser. Each screen is a single file you can read on GitHub:

Basics

First icon

An icon, still and playing

States

The different animations inside one icon

Colors and stroke

colors, color, stroke and speed

On its own

In view

Icons that play as you scroll to them

Loops

Seamless loops, and loops with a pause

Intro

Cards that enter one after another

Sequence

A script of steps

Taps

Any button

Playing the icon from onPress

Your own button

LordIcon.Target and the tap triggers

Following your app

Toggle

A morph that follows on and off

Busy

A loop while something is in progress

Count

A nudge when a number goes up

Stages

A state for each stage of a task

In an app

Tab bar

Icons that morph with their tab

List

Icons in a recycling list

Search field

Icons that follow a field's focus and text

Theme

Light and dark with LordIconProvider

Further

Ref and events

Playing from code, chaining states, events

Custom trigger

A bin that fills and empties on tap

Accessibility

Labels for screen readers, and less motion

Many icons

A screen full of animating icons

Apps

Expo

A small shop: animated tab bar, likes, a cart, a payment, search and a profile, on Android, iOS and the web

Best practices

One animation or all of them

When you download an icon, the default format keeps only the animation you picked, with its colors and stroke fixed. The file is small and that's usually all you need. Choose "Raw" when you want to switch between the icon's states, or change its colors or stroke in your app.

Reduced motion

When a user has turned on Reduce Motion (iOS) or Remove animations (Android), icons respect it: they don't play one-off animations, morphs jump to their look, and loops stand still. To animate a particular icon anyway, add motion="always" to it.

Screen readers

Screen readers skip icons. If an icon means something on its own, without text next to it, give it an accessibilityLabel.

Troubleshooting

  • "Missing native module", or nothing in Expo Go: the package needs a development build. Run npx expo run:ios or run:android.
  • An empty icon on iOS: run pod install again.
  • After updating the package, build the app again. The engine is native code, so a JavaScript reload doesn't bring in the new version.
  • hover does nothing: put the icon inside a LordIcon.Target, or play it from your button's onPress.
  • colors or stroke change nothing: the icon was downloaded in the default format. Download it again as "Raw".
  • Intro
  • Quick start
  • States
  • Playing an icon
  • Colors and themes
  • In an app
  • Ref and events
  • More ways to play
  • On the web
  • Performance
  • Examples
  • Best practices
  • Troubleshooting
React WordPress