跳到主要内容

IIconButton

View source on GitHub

A component that displays an interactive icon button with hover and click states.

iconbuttoniconbutton

Example

Simple icon button with click handler

const deleteButton: IIconButton = {
iconName: "delete.svg",
size: 20,
color: "#333333",
hoverColor: "#FF0000",
onClick: async () => {
try {
await deleteItem();
return {
actions: [Actions.showToast],
toastProps: [{
title: "Item deleted successfully",
type: ToastType.success
}]
};
} catch (error) {
return {
actions: [Actions.showToast],
toastProps: [{
title: "Failed to delete item",
type: ToastType.error
}]
};
}
},
isDisabled: false,
title: "Delete item"
}

Properties

PropertyTypeDescription
iconName?stringThe button display icon. The icon image must be uploaded to the assets folder. Only the image name with the extension must be specified in this field. The icon is rendered at the size set in the size field.
iconHoverName?stringThe icon displayed while the cursor is over the button. The icon image must be uploaded to the assets folder. Only the image name with the extension must be specified in this field.
iconClickName?stringThe icon displayed while the button is being clicked. The icon image must be uploaded to the assets folder. Only the image name with the extension must be specified in this field.
color?stringIcon color. Can be "accent" or any CSS color value
hoverColor?stringIcon color on hover action
clickColor?stringIcon color on click action
size?numberButton height and width value. Can be a number (pixels)
isFill?booleanDetermines if icon fill is needed
isStroke?booleanDetermines if icon stroke is needed
isDisabled?booleanSets the button to present a disabled state
isClickable?booleanSets cursor value to indicate clickability
onClick?() => TReturnMessageSets a button callback function triggered when the button is clicked
id?stringSets component id
title?stringData when user hover on icon (tooltip text)
tooltipId?stringTooltip id for advanced tooltip configuration
tooltipContent?stringTooltip content text
className?stringDefines the CSS class for styling the component. Can be used to override or extend the default component styles.