IconButton

January 26, 2026 ยท View on GitHub

A versatile button component that displays an icon and handles various interaction states.

Features

  • Supports hover and click states with different icons and colors
  • Customizable size and colors
  • Supports both fill and stroke styles
  • Touch device support
  • Tooltip support
  • Custom icon node support
  • Comprehensive mouse event handling

Usage

import { IconButton } from "@docspace/ui-kit/components/icon-button";
import SearchReactSvgUrl from "PUBLIC_DIR/images/search.react.svg?url";

Basic Usage

<IconButton
  size={25}
  iconName={SearchReactSvgUrl}
  onClick={() => console.log("Clicked")}
/>

With Hover and Click States

<IconButton
  iconName={SearchReactSvgUrl}
  iconHoverName={EyeReactSvgUrl}
  iconClickName={InfoReactSvgUrl}
  color="#333"
  hoverColor="#666"
  clickColor="#999"
  onClick={() => console.log("Clicked")}
/>

With Custom Icon Node

<IconButton
  size={25}
  iconNode={<CustomIcon />}
  onClick={() => console.log("Clicked")}
/>

With Tooltip

<IconButton
  iconName={SearchReactSvgUrl}
  dataTip="Search"
  title="Search button"
/>

Properties

PropsTypeRequiredDefaultDescription
classNamestring--Custom CSS class
colorstring--Default icon color
hoverColorstring--Icon color on hover
clickColorstring--Icon color on click
sizenumber-25Button size (width and height)
isFillboolean-trueWhether to fill the icon
isStrokeboolean-falseWhether to apply stroke to the icon
isDisabledboolean-falseDisables the button
isClickableboolean-falseShows clickable cursor
iconNodeReactNode--Custom icon component
iconNamestring--Main icon URL/path
iconHoverNamestring--Icon URL/path for hover state
iconClickNamestring--Icon URL/path for click state
onClickfunction--Click handler
onMouseEnterfunction--Mouse enter handler
onMouseDownfunction--Mouse down handler
onMouseUpfunction--Mouse up handler
onMouseLeavefunction--Mouse leave handler
idstring--Button ID
styleCSSProperties--Custom inline styles
dataTipstring--Tooltip text
titlestring--HTML title attribute

Touch Device Support

The component automatically detects touch devices and adjusts its behavior accordingly:

  • On touch devices, hover states are disabled
  • Click states are handled appropriately for touch interactions

Accessibility

The component supports:

  • Keyboard navigation
  • ARIA attributes
  • Title tooltips
  • Disabled states

Examples

Search Button with Hover Effect

<IconButton
  iconName={SearchReactSvgUrl}
  iconHoverName={SearchHoverSvgUrl}
  size={25}
  hoverColor="#0066cc"
  title="Search"
  dataTip="Click to search"
/>

Disabled Button

<IconButton
  iconName={EditSvgUrl}
  isDisabled={true}
  size={20}
  title="Edit disabled"
/>

Custom Styled Button

<IconButton
  iconName={CustomSvgUrl}
  style={{ margin: "8px", borderRadius: "4px" }}
  className="custom-icon-button"
  isFill={false}
  isStroke={true}
/>