mvriu5

payload icon picker

by mvriu5
Custom fields
v3
^3.84.1

Overview

Summary generated from the README

Adds an iconField() helper that creates a text field rendered as a searchable icon picker in the admin UI. Icons are registered once in the plugin config through adapters for popular React icon libraries, and the selected icon is stored as a string. A client renderer and resolver turn stored values back into icons on the frontend.

Features

  • Searchable icon picker field that stores a plain text value
  • Adapters for Lucide, Tabler, Simple Icons, Heroicons, Phosphor and Hugeicons
  • Prefix, include and exclude options to avoid name collisions across libraries
  • Per-field filters by library prefix or specific icon values
  • IconRenderer component and createIconResolver for rendering stored icons with sanitized SVG
  • Custom icon metadata with keywords, labels and values

Use cases

  • Let editors choose navigation or feature icons for pages and blocks
  • Offer a restricted set of social brand icons for link fields
  • Combine several icon libraries in one site with unique prefixes

From the author

Payload plugin introducing an icon picker into the CMS.

Installation

npm i @mvriu5/payload-icon-picker

1

Stars

0

Forks

6

Open Issues

3 weeks ago

Last Updated

243

Weekly Downloads

v1.1.1

npm Version

65.3 KB

Unpacked Size

1

Dependencies

GitHub stars

1+1 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20261
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20260
Oct 24, 20260
Oct 23, 20260
Oct 22, 20260
Oct 21, 20260
Oct 20, 20260
Oct 19, 20260
Oct 18, 20260
Oct 17, 20260
Oct 16, 20260
Oct 15, 20260
Oct 14, 20260
Oct 13, 20260
Oct 12, 20260
Oct 11, 20260
Oct 10, 20260
Oct 9, 20260
Oct 8, 20260
Oct 7, 20260
Oct 6, 20260
Oct 5, 20260
Oct 4, 20260
Oct 3, 20260
Oct 2, 20260
Oct 1, 20260
Sep 30, 20260
Sep 29, 20260
Sep 28, 20260
Sep 27, 20260
Sep 26, 20260
Sep 25, 20260
Sep 24, 20260
Sep 23, 20260
Sep 22, 20260
Sep 21, 20260
Sep 20, 20260
Sep 19, 20260
Sep 18, 20260
Sep 17, 20260
Sep 16, 20260
Sep 15, 20260
Sep 14, 20260
Sep 13, 20260
Sep 12, 20260
Sep 11, 20260
Sep 10, 20260
Sep 9, 20260
Sep 8, 20260
Sep 7, 20260
npm weekly downloads

234+177 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026234
Dec 5, 2026218
Dec 4, 2026167
Dec 3, 2026118
Dec 2, 202654
Dec 1, 2026120
Nov 30, 2026133
Nov 29, 2026127
Nov 28, 2026119
Nov 27, 2026106
Nov 26, 2026108
Nov 25, 2026101
Nov 24, 202634
Nov 23, 202656
Nov 22, 202656
Nov 21, 202658
Nov 20, 202662
Nov 19, 202661
Nov 18, 202673
Nov 17, 202676
Nov 16, 202661
Nov 15, 2026112
Nov 14, 2026126
Nov 13, 2026123
Nov 12, 2026121
Nov 11, 2026110
Nov 10, 2026118
Nov 9, 202697
Nov 8, 202656
Nov 7, 202643
Nov 6, 202645
Nov 5, 202659
Nov 4, 202657
Nov 3, 202652
Nov 2, 202656
Nov 1, 202642
Oct 31, 202637
Oct 30, 202641
Oct 29, 202625
Oct 28, 202622
Oct 27, 202619
Oct 26, 202618
Oct 25, 202623
Oct 24, 202631
Oct 23, 202624
Oct 22, 202639
Oct 21, 202644
Oct 20, 202641
Oct 19, 202641
Oct 18, 202676
Oct 17, 202668
Oct 16, 202679
Oct 15, 202688
Oct 14, 2026104
Oct 13, 2026138
Oct 12, 2026132
Oct 11, 2026105
Oct 10, 2026137
Oct 9, 2026136
Oct 8, 2026112
Oct 7, 202692
Oct 6, 202657
Oct 5, 202673
Oct 4, 202665
Oct 3, 202651
Oct 2, 202649
Oct 1, 202653
Sep 30, 202655
Sep 29, 202660
Sep 28, 202655
Sep 27, 202657
Sep 26, 202655
Sep 25, 202654
Sep 24, 202657
Sep 23, 202660
Sep 22, 202663
Sep 21, 202671
Sep 20, 202668
Sep 19, 202663
Sep 18, 202672
Sep 17, 202672
Sep 16, 202670
Sep 15, 202668
Sep 14, 202649
Sep 13, 202654
Sep 12, 202673
Sep 11, 202661
Sep 10, 202659
Sep 9, 202658
Sep 8, 202655
Sep 7, 202657

Each point is npm's rolling 7-day download count.

Health Score

53/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1292287451-root.svg)](https://payloaddirectory.dev/plugins/1292287451-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1292287451-root"><img src="https://payloaddirectory.dev/badge/1292287451-root.svg" alt="Payload Directory"></a>
Updated Nov 10, 2026Created Jul 7, 2026Published Jul 21, 2026

README

Payload Icon Picker

Payload plugin for adding an icon picker field to the admin UI. The field stores a string, while editors can search and choose from the icons you register in the plugin config.

Installation

pnpm add @mvriu5/payload-icon-picker

Install the icon library you want to use in your project, for example:

pnpm add lucide-react

Usage

Register all icons once in your Payload config, then use iconField() wherever a Payload text field should become an icon picker.

import { postgresAdapter } from "@payloadcms/db-postgres"
import { lexicalEditor } from "@payloadcms/richtext-lexical"
import * as Icons from "lucide-react"
import { buildConfig } from "payload"
import { iconField, payloadIconPlugin } from "@mvriu5/payload-icon-picker"
import { lucideIconAdapter } from "@mvriu5/payload-icon-picker/adapters/lucide"

export default buildConfig({
    collections: [
        {
            slug: "posts",
            fields: [
                {
                    name: "title",
                    type: "text",
                    required: true,
                },
                iconField({
                    name: "icon",
                    label: "Icon",
                }),
            ],
        },
    ],
    plugins: [
        payloadIconPlugin({
            icons: lucideIconAdapter(Icons),
        }),
    ],
    db: postgresAdapter({
        pool: {
            connectionString: process.env.DATABASE_URL,
        },
    }),
    editor: lexicalEditor(),
    secret: process.env.PAYLOAD_SECRET,
})

Stored Value

iconField() creates a normal Payload text field. The selected icon is resolved to a string and stored in the database.

By default, the stored value is icon.value ?? icon.name. Adapters can prefix generated values so multiple icon libraries do not collide:

payloadIconPlugin({
    icons: lucideIconAdapter(Icons, {
        prefix: "lucide",
    }),
})

Selecting ArrowRight would store:

lucide:ArrowRight

You can still use resolveIcon if you need a custom final storage format.

About resolveIcon

When using payloadIconPlugin(), resolveIcon runs during Payload config setup. The resolved string is passed to the admin field as each icon's final value.

That means normal iconField() usage does not require passing resolveIcon to the admin component manually.

The resolveIcon prop on IconRenderer, IconField, and createIconResolver() is primarily for direct component usage, tests, or advanced cases where you bypass payloadIconPlugin(). If you use a custom resolveIcon for stored values, pass the same resolver when rendering or resolving those values outside the Payload admin UI.

Rendering Stored Icons

Use IconRenderer from the client export to render a stored icon string in your frontend.

import * as Icons from "lucide-react"
import { IconRenderer } from "@mvriu5/payload-icon-picker/client"
import { lucideIconAdapter } from "@mvriu5/payload-icon-picker/adapters/lucide"

const icons = lucideIconAdapter(Icons)

export function PostIcon({ icon }: { icon?: string }) {
    return <IconRenderer value={icon} icons={icons} className="post-icon" />
}

The renderer supports React icon components and adapter-generated SVG metadata. SVG output is sanitized before rendering.

If you need full control over rendering, use createIconResolver() to turn a stored string back into the registered icon.

import * as Icons from "lucide-react"
import { createIconResolver } from "@mvriu5/payload-icon-picker"
import { lucideIconAdapter } from "@mvriu5/payload-icon-picker/adapters/lucide"

const resolveStoredIcon = createIconResolver({
    icons: lucideIconAdapter(Icons),
})

const resolvedIcon = resolveStoredIcon("Home")

Icon Inputs

Use an adapter for supported icon libraries. Adapters convert React icon exports to serializable SVG metadata for the Payload admin UI.

import * as Icons from "lucide-react"
import { lucideIconAdapter } from "@mvriu5/payload-icon-picker/adapters/lucide"

payloadIconPlugin({
    icons: lucideIconAdapter(Icons),
})
import * as TablerIcons from "@tabler/icons-react"
import { tablerIconAdapter } from "@mvriu5/payload-icon-picker/adapters/tabler"

payloadIconPlugin({
    icons: tablerIconAdapter(TablerIcons),
})
import * as SimpleIcons from "@icons-pack/react-simple-icons"
import { simpleIconsAdapter } from "@mvriu5/payload-icon-picker/adapters/simple-icons"

payloadIconPlugin({
    icons: simpleIconsAdapter(SimpleIcons),
})
import * as Heroicons from "@heroicons/react/24/outline"
import { heroiconsAdapter } from "@mvriu5/payload-icon-picker/adapters/heroicons"

payloadIconPlugin({
    icons: heroiconsAdapter(Heroicons),
})
import * as PhosphorIcons from "@phosphor-icons/react"
import { phosphorIconAdapter } from "@mvriu5/payload-icon-picker/adapters/phosphor"

payloadIconPlugin({
    icons: phosphorIconAdapter(PhosphorIcons, {
        weight: "regular",
    }),
})
import * as Hugeicons from "@hugeicons/core-free-icons"
import { hugeiconsIconAdapter } from "@mvriu5/payload-icon-picker/adapters/hugeicons"

payloadIconPlugin({
    icons: hugeiconsIconAdapter(Hugeicons),
})

Adapters support prefix, include, exclude, and optional label/value formatters:

When registering icons from more than one library, use a unique prefix for every adapter. Many icon libraries export generic names such as Home, Search, or User; prefixes keep stored values unique and make it clear which library an icon came from.

import * as SimpleIcons from "@icons-pack/react-simple-icons"
import * as TablerIcons from "@tabler/icons-react"
import { simpleIconsAdapter } from "@mvriu5/payload-icon-picker/adapters/simple-icons"
import { tablerIconAdapter } from "@mvriu5/payload-icon-picker/adapters/tabler"

payloadIconPlugin({
    icons: [
        ...tablerIconAdapter(TablerIcons, {
            label: ({ defaultLabel, prefix }) => `${prefix}:${defaultLabel.replace(/^Icon/, "")}`,
            prefix: "tabler",
        }),
        ...simpleIconsAdapter(SimpleIcons, {
            prefix: "si",
        }),
    ],
})

With prefix, the adapter keeps name as the original library export name and sets value to prefix:name, for example tabler:IconHome.

Without prefixes, duplicate icon values can collide. In development, the plugin warns when multiple registered icons resolve to the same stored value.

Or pass explicit icon metadata:

payloadIconPlugin({
    icons: [
        {
            Icon: Icons.Home,
            keywords: ["house", "start"],
            label: "Home",
            name: "Home",
            value: "home",
        },
    ],
})

Field Options

iconField() accepts normal single-value Payload text field options, plus picker labels and per-field icon filters:

iconField({
    name: "icon",
    label: "Icon",
    required: true,
    placeholder: "Search icons",
    noResultsLabel: "No icons found",
    admin: {
        position: "sidebar",
    },
})

Use libraries to limit a field to icons from selected adapter prefixes:

iconField({
    name: "navigationIcon",
    label: "Navigation Icon",
    libraries: ["lucide"],
})

Use icons to allow only specific stored icon values:

iconField({
    name: "socialIcon",
    label: "Social Icon",
    icons: ["si:SiGithub", "si:SiDiscord"],
})

You can combine both options. The filters are additive, so this example allows all Lucide icons plus the explicit GitHub icon:

iconField({
    name: "featuredIcon",
    libraries: ["lucide"],
    icons: ["si:SiGithub"],
})

Development

The dev Payload config in dev/payload.config.ts registers the plugin with lucide-react, which is installed as a development dependency.

pnpm dev

Generate the Payload import map after changing admin components:

pnpm generate:importmap

Build the package:

pnpm build

Similar plugins