You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

react-lucide-icon-picker

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-lucide-icon-picker

This is a React component that allows you to pick Lucide icons.

1.0.4
latest
Version published
Weekly downloads
11
-45%
Maintainers
0
Weekly downloads
 
Created

React Lucide Icon Picker

This is a React component that allows you to pick Lucide icons.

Installation

To install the React Lucide Icon Picker, you can use npm or yarn:

npm install react-lucide-icon-picker

Usage

To use the React Lucide Icon Picker, simply import it and use it in your React application:

import 'react-lucide-icon-picker/style.css'
import { ReactLucideIconPicker } from 'react-lucide-icon-picker'

function App() {
  return (
    <div>
      <h1>Choose an Icon</h1>
      <ReactLucideIconPicker />
    </div>
  )
}

Importing Components Separately

You can import components separately from the React Lucide Icon Picker. When doing so, ensure that the components are wrapped inside the <ReactLucideIconPicker.Provider> to function correctly.

import 'react-lucide-icon-picker/style.css'
import { ReactLucideIconPicker } from 'react-lucide-icon-picker'
import { IconComponent } from 'react-lucide-icon-picker/components'

const App = () => (
  <ReactLucideIconPicker.Provider>
    <ReactLucideIconPicker.Search />
    <ReactLucideIconPicker.IconList />
  </ReactLucideIconPicker.Provider>
)

Using the onChange Prop

You can pass the onChange prop to either the ReactLucideIconPicker or the ReactLucideIconPicker.IconList component. This allows you to receive the key and SVG element of the selected icon.

Example:

import 'react-lucide-icon-picker/style.css'
import { ReactLucideIconPicker } from 'react-lucide-icon-picker'

const App = () => {
  const handleIconChange = ({ key, icon }) => {
    console.log('Selected Icon Key:', key)
    console.log('Selected Icon SVG Element:', icon)
  }

  return (
    <ReactLucideIconPicker onChange={handleIconChange}>
      {/* Other components can go here */}
    </ReactLucideIconPicker>
  )
}

or

import 'react-lucide-icon-picker/style.css'
import { ReactLucideIconPicker } from 'react-lucide-icon-picker'

const App = () => {
  const handleIconChange = ({ key, icon }) => {
    console.log('Selected Icon Key:', key)
    console.log('Selected Icon SVG Element:', icon)
  }

  return (
    <ReactLucideIconPicker.Provider>
      <ReactLucideIconPicker.IconList onChange={handleIconChange} />
    </ReactLucideIconPicker.Provider>
  )
}

Contributing

We welcome contributions to the React Lucide Icon Picker project. Please see the CONTRIBUTING.md file for guidelines on how to contribute.

License

The React Lucide Icon Picker is open source and available under the MIT License.

FAQs

Package last updated on 28 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts