Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: Can I set my own Icons? #31

Open
alinianitchii opened this issue Apr 21, 2023 · 2 comments
Open

[Question]: Can I set my own Icons? #31

alinianitchii opened this issue Apr 21, 2023 · 2 comments
Labels

Comments

@alinianitchii
Copy link

alinianitchii commented Apr 21, 2023

Hi,

I would like to set my own Icons I'm using in my system.

Can adapt the library to accept other Icons?

Thank you

Funding

  • You can sponsor this specific effort via a Polar.sh pledge below
  • We receive the pledge once the issue is completed & verified
Fund with Polar
@polar-sh polar-sh bot added the polar label Jul 15, 2023
@Rahuletto
Copy link

Yes, but no at the same time. React CMDK supports React-Icons library and HeroIcons. So you can't use ur selected library but you can do it using react-icons package. If that package doesn't support your desired icons, you are screwed.

@ahmadassaf
Copy link

You can use whatever you want by overriding how the <CommandPalette.ListItem> is rendered.

For example; I want to show some social icons from react-icons/pi (can be any source or direct svg)

import { PiLinkedinLogo } from 'react-icons/pi';

  const socialItems = filterItems(
    [
      {
        'heading': 'Contact Me',
        'id': 'contact',
        'items': [
          {
            'children': 'Linkedin',
            'closeOnSelect': false,
            'heroIcon': <PiLinkedinLogo/>,
            'id': 'linkedin',
            'onClick': () => {
              window.open('https://linkedin.com/in/.....', '_blank').focus();
            },
            'title': 'My Linkedin Profile'
          },
          .....

then when you are specifying your list:

          <CommandPalette.List key={ list.id } heading={ list.heading }>
            {list.items.map(({ id, title, heroIcon, ...rest }) => (
              <CommandPalette.ListItem
                key={ id }
                index={ getItemIndex(socialItems, id) }
                { ...rest }
              >
                <div className='flex items-center w-full'>
                  {heroIcon}
                  <div className='mx-2 text-md'>{ title }</div>
                </div>
              </CommandPalette.ListItem>
            ))}
          </CommandPalette.List>
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants