payload-lucide-picker
Version:
A custom field for Payload CMS that allows you to select and configure Lucide icons in your admin panel
92 lines (69 loc) • 1.72 kB
Markdown
A custom field for [Payload CMS](https://payloadcms.com/) that allows you to select and configure [Lucide icons](https://lucide.dev/) in your admin panel.
- 🎨 Select from all available Lucide icons
- 🎯 Configure icon size, color, and stroke width
- ♿ Accessible and keyboard-friendly
- 🔄 Reset to default configuration
```bash
pnpm add payload-lucide-picker
npm install payload-lucide-picker
yarn add payload-lucide-picker
```
1. Import the field in your Payload config:
```typescript
import { LucideIconPicker } from 'payload-lucide-picker';
// In your collection config
{
fields: [
{
name: 'icon',
type: 'lucide-icon',
required: true,
label: 'Select an Icon',
admin: {
description: 'Choose an icon and configure its appearance'
}
}
]
}
```
2. The field will store the icon configuration in the following format:
```typescript
{
name: string;
config: {
size: number;
color: string;
strokeWidth: number;
}
}
```
3. Use the icon in your frontend:
```typescript
import { Icon } from 'lucide-react';
const MyComponent = ({ icon }) => {
const IconComponent = Icon[icon.name];
return (
<IconComponent
size={icon.config.size}
color={icon.config.color}
strokeWidth={icon.config.strokeWidth}
/>
);
};
```
1. Clone the repository
2. Install dependencies: `pnpm install`
3. Build the package: `pnpm build`
4. Run tests: `pnpm test`
Contributions are welcome! Please feel free to submit a Pull Request.
MIT © [Vectras](https://github.com/Vectras)