FishSoup25

payload plugin icons

by FishSoup25
Custom fields
v3
^3.37.0
MIT

Overview

Summary generated from the README

Adds an icon picker field to Payload 3 that stores the provider and icon name. Icons are discovered from the Lucide and Phosphor packages installed in your app and served as serialized SVGs from plugin endpoints, so provider modules stay out of client bundles. It requires Payload 3.37 or newer, React 19, and a Next.js config wrapper.

Features

  • Searchable, paginated icon picker in the admin panel
  • Lucide and Phosphor providers with optional custom server-side providers
  • Provider and icon preview in collection list cells
  • Client Icon component for rendering stored icons on the frontend
  • Batched and cached icon preview requests
  • Per-field options for provider subset, default provider and labels

Use cases

  • Let editors choose an icon for feature blocks, menu items or cards
  • Offer a restricted set of icon libraries per field
  • Render stored icons on a Next.js frontend without bundling icon packages

From the author

Icon picker field for Payload CMS with Lucide and Phosphor providers.

Installation

npm i payload-plugin-icons

2

Stars

0

Forks

0

Open Issues

3 months ago

Last Updated

23

Weekly Downloads

v1.1.5

npm Version

170.7 KB

Unpacked Size

0

Dependencies

GitHub stars

20 since Sep 6

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

3−14 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 20263
Dec 4, 20263
Dec 3, 20265
Dec 2, 202611
Dec 1, 202612
Nov 30, 202612
Nov 29, 202612
Nov 28, 202613
Nov 27, 202613
Nov 26, 202613
Nov 25, 20267
Nov 24, 20266
Nov 23, 20266
Nov 22, 20267
Nov 21, 20266
Nov 20, 20267
Nov 19, 20267
Nov 18, 20267
Nov 17, 20269
Nov 16, 202610
Nov 15, 20268
Nov 14, 20268
Nov 13, 20268
Nov 12, 202615
Nov 11, 202614
Nov 10, 202612
Nov 9, 202615
Nov 8, 202616
Nov 7, 202622
Nov 6, 202620
Nov 5, 202612
Nov 4, 202612
Nov 3, 202613
Nov 2, 202612
Nov 1, 202621
Oct 31, 202616
Oct 30, 202616
Oct 29, 202615
Oct 28, 202615
Oct 27, 202615
Oct 26, 202613
Oct 25, 20264
Oct 24, 20266
Oct 23, 20266
Oct 22, 202621
Oct 21, 202622
Oct 20, 202623
Oct 19, 202623
Oct 18, 202628
Oct 17, 202626
Oct 16, 202637
Oct 15, 202630
Oct 14, 202630
Oct 13, 202629
Oct 12, 202642
Oct 11, 202637
Oct 10, 202636
Oct 9, 202627
Oct 8, 202619
Oct 7, 202618
Oct 6, 202626
Oct 5, 202612
Oct 4, 202619
Oct 3, 202619
Oct 2, 202620
Oct 1, 202620
Sep 30, 202623
Sep 29, 202615
Sep 28, 202615
Sep 27, 20269
Sep 26, 202613
Sep 25, 202612
Sep 24, 202612
Sep 23, 202611
Sep 22, 202619
Sep 21, 202620
Sep 20, 202622
Sep 19, 202624
Sep 18, 202623
Sep 17, 202626
Sep 16, 202630
Sep 15, 202622
Sep 14, 202623
Sep 13, 202620
Sep 12, 202614
Sep 11, 202614
Sep 10, 202611
Sep 9, 20268
Sep 8, 202615
Sep 7, 202618
Sep 6, 202617

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

Health Score

55/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/1197210288-root.svg)](https://payloaddirectory.dev/plugins/1197210288-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1197210288-root"><img src="https://payloaddirectory.dev/badge/1197210288-root.svg" alt="Payload Directory"></a>
Updated Aug 24, 2026Created Mar 31, 2026Published Aug 14, 2026

README

payload-plugin-icons

An icon picker field for Payload 3. It stores { provider, name }, discovers icons from the provider versions installed in your app, and renders provider-neutral serialized SVGs.

Sponsor

BrainyBuilds

payload-plugin-icons is sponsored by BrainyBuilds. Thank you for supporting the project!

Features

  • Lucide and Phosphor icon providers
  • Searchable, paginated admin picker
  • Provider and icon preview in collection cells
  • Typed field data and React rendering component
  • Server-side custom provider support
  • No Lucide or Phosphor modules in admin or frontend client bundles
  • Batched, cached picker previews

Installation

npm install payload-plugin-icons lucide-react @phosphor-icons/react

Requirements: Payload ^3.37.0, React 19, Lucide React >=0.400.0, and Phosphor React >=2.0.0.

Configuration

import { buildConfig } from 'payload'
import { createIconPlugin } from 'payload-plugin-icons'

const { iconField, iconPlugin } = createIconPlugin()

export default buildConfig({
  plugins: [iconPlugin],
  collections: [
    {
      slug: 'pages',
      fields: [
        iconField({
          name: 'icon',
          label: 'Icon',
          required: false,
        }),
      ],
    },
  ],
})

Configure next.config so provider packages are loaded natively only when an icon endpoint runs. (Lucide uses Node runtime loading because Next optimizes it by default; other providers are added to serverExternalPackages.)

import { withPayload } from '@payloadcms/next/withPayload'
import { withPayloadIcons } from 'payload-plugin-icons'

const nextConfig = {}

export default withPayload(
  withPayloadIcons(nextConfig),
  { devBundleServerPackages: false },
)

Standalone and Docker deployments

Next.js output tracing cannot discover the provider packages because the plugin loads them through opaque runtime imports. This does not affect next dev or a conventional next start deployment where the project's complete node_modules remains available. However, output: 'standalone' copies only files discovered by output tracing into .next/standalone.

Explicitly include each configured provider package when building a standalone deployment:

import { withPayload } from '@payloadcms/next/withPayload'
import type { NextConfig } from 'next'
import { withPayloadIcons } from 'payload-plugin-icons'

const nextConfig: NextConfig = {
  output: 'standalone',
  outputFileTracingIncludes: {
    '/*': [
      './node_modules/lucide-react/**/*',
      './node_modules/@phosphor-icons/react/**/*',
    ],
  },
}

export default withPayload(
  withPayloadIcons(nextConfig),
  { devBundleServerPackages: false },
)

If the plugin is configured with only one built-in provider, include only that provider's package. Add equivalent patterns for custom provider packages. Patterns are resolved from the Next.js project root; monorepos may also need Next.js's outputFileTracingRoot setting.

withPayloadIcons configures provider packages for native server loading, but opaque runtime imports still require these explicit tracing includes in standalone builds.

packageImport defaults to payload-plugin-icons. Set it when the package is exposed through a different monorepo alias:

createIconPlugin({ packageImport: '@acme/payload-icons' })

After changing the field configuration, regenerate Payload's import map and types:

payload generate:importmap
payload generate:types

Rendering an icon

Icon is a Client Component. It fetches a small serialized SVG definition from the plugin endpoint; provider packages stay on the server. Requests mounted in the same turn are automatically batched and definitions are shared in a module-level cache.

'use client'

import type { IconData } from 'payload-plugin-icons'
import { Icon } from 'payload-plugin-icons/client'

export function FeatureIcon({ icon }: { icon?: IconData | null }) {
  return <Icon aria-hidden className="feature-icon" icon={icon} size={24} />
}

SVG props and event handlers are applied to the outer <svg>. Phosphor's weight is included in the request and cache key.

Customization

Use a subset of the built-in providers or change their labels:

import { createIconPlugin, lucideProvider } from 'payload-plugin-icons'

const { iconField, iconPlugin } = createIconPlugin({
  providers: [lucideProvider({ label: 'Interface icons' })],
})

Field options:

  • name: stored field name
  • label: admin label
  • required: require an icon name
  • defaultProviderId: provider selected for new documents
  • providerIds: provider subset for this field
  • labelsById: field-specific provider labels
  • packageImport: field-specific package name or alias
  • admin: additional Payload field admin options

Custom providers

A custom provider implements the server-only IconProvider contract. Keep its package import inside loadCatalog / loadIcons, serialize only validated names from your catalog, and add the package name to withPayloadIcons.

import type { IconProvider } from 'payload-plugin-icons'
import { createIconPlugin, serializeIconComponent } from 'payload-plugin-icons'

const customProvider: IconProvider = {
  id: 'custom',
  label: 'Custom',
  packageName: '@acme/icon-library',
  async loadCatalog() {
    return { provider: this.id, version: '1', icons: [{ name: 'Home' }] }
  },
  async loadIcons({ names }) {
    const icons = await import('@acme/icon-library')
    return Object.fromEntries(names.flatMap((name) =>
      name === 'Home' ? [[name, serializeIconComponent(icons.Home)]] : [],
    ))
  },
}

const { iconField, iconPlugin } = createIconPlugin({
  providers: [customProvider],
})

Call withPayloadIcons(nextConfig, ['@acme/icon-library']) for this provider.

Troubleshooting

Icon endpoints return 500 only in standalone or Docker

If /api/payload-icons/:provider/catalog or /api/payload-icons/:provider/icons works in development but returns 500 from a container that copies only .next/standalone, the provider package was probably omitted by Next.js output tracing. The endpoint may report that it is unable to load the icon catalog or icons.

Add the provider package to outputFileTracingIncludes as shown in Standalone and Docker deployments, rebuild the image, and confirm that its directory exists under the deployed node_modules. A typical standalone image copies .next/standalone and .next/static; copying .next/static does not add missing server dependencies.

Development

npm ci
npm run dev

The development app uses a local SQLite database at dev/payload.db, so no external database is required. You can optionally copy dev/.env.example to dev/.env to set PAYLOAD_SECRET or override DATABASE_URL. The development admin runs at http://localhost:2515.

Useful commands:

  • npm run check: lint and create a clean package build
  • npm run generate:importmap: regenerate the development import map
  • npm run generate:types: regenerate development Payload types
  • npm run build:next: build the development application

dist is committed and verified in CI.

License

MIT

Similar plugins