Back to Twenty

Icon Picker

packages/twenty-docs/twenty-ui/input/icon-picker.mdx

2.2.01.5 KB
Original Source
<Frame> </Frame>

A dropdown-based icon picker that allows users to select an icon from a list.

<Tabs> <Tab title="Usage">
jsx
import React, { useState } from "react";
import { IconPicker } from "@/ui/input/components/IconPicker";

export const MyComponent = () => {

   const [selectedIcon, setSelectedIcon] = useState("");
   const handleIconChange = ({ iconKey, Icon }) => {
     console.log("Selected Icon:", iconKey);
     setSelectedIcon(iconKey);
   };

  return (
    <IconPicker
      disabled={false}
      onChange={handleIconChange}
      selectedIconKey={selectedIcon}
      variant="primary"
    />
  );
};
</Tab> <Tab title="Props">
PropsTypeDescription
disabledbooleanDisables the icon picker if set to true
onChangefunctionThe callback function triggered when the user selects an icon. It receives an object with iconKey and Icon properties
selectedIconKeystringThe key of the initially selected icon
onClickOutsidefunctionCallback function triggered when the user clicks outside the dropdown
onClosefunctionCallback function triggered when the dropdown is closed
onOpenfunctionCallback function triggered when the dropdown is opened
variantstringThe visual style variant of the clickable icon. Options include: primary, secondary, and tertiary
</Tab> </Tabs>