Skip to content

IconButton

The IconButton component is a variant of the standard button that displays only an icon without text. It's ideal for compact UI elements where space is limited or when the icon alone sufficiently conveys the action.

See all the examples and details in the Storybook.

Usage

tsx
import { IconButton } from "@samgl/graffiti-ui";
import { Heart } from "@phosphor-icons/react"; // your icon library of choice

const MyIconButton = () => {
  return (
    <IconButton icon={<Heart />} size="1rem" onClick={() => alert("Liked!")} />
  );
};

Props

PropTypeDefaultOptionalDescription
iconReactNodeThe icon to display in the button.
onClick() => voidThe function to call when the button is clicked.
sizestring1 remThe size of the IconButton.
classNamestringThe class name of the component, generally used when extending the component with a styled component.