Skip to main content

onClick

Description

Fires when the icon is clicked

Usage

onClick?: (ev: MouseEvent) => void;

Example

When a user clicks on the icon, the handleClick function is executed, logging a message and showing an alert.

import { Icon } from "@svar-ui/react-core";

export default function Example() {
function handleClick() {
console.log("Icon was clicked");
alert("You clicked the save icon!");
}

return (
// custom click behavior
<Icon title="Save" className="save-icon" onClick={handleClick}>
💾
</Icon>
);
}
.save-icon {
font-size: 24px;
color: seagreen;
}