Hey everyone,
I've just started a new payload project and want to let my user choose from the icons from lucide.dev
I'm uncertain how to set this up and wanted to check if there is a best pratice for this in payload.
My ininital though was doing something like:
{
name: 'icon',
type: 'select',
options: [
'AlertCircle',
'ArrowRight',
'Check',
'ChevronDown',
'CreditCard',
'DollarSign',
'ShoppingBag',
'ShoppingCart',
// Add more icon names as needed
],
},```
and then in the component:
```tsx
import type { Page } from '@/payload-types'
import * as LucideIcons from 'lucide-react'
export default function HomePage(props: Page) {
const { title, description, offers } = props
return (
<div>
{offers?.map((offer, i) => {
// Dynamically get icon component
const IconComponent = LucideIcons[offer.icon as keyof typeof LucideIcons]
return (
<div key={i}>
<h3>{offer.title}</h3>
{IconComponent && <IconComponent size={24} />}
</div>
)
})}
</div>
)
} ```
This seems tedious and there would be no way to preview the icon to the user