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.

<script>
import { Icon } from "@svar-ui/svelte-core";

function handleClick() {
console.log("Icon was clicked");
alert("You clicked the save icon!");
}
</script>

<!-- custom click behavior -->
<Icon title="Save" css="save-icon" onclick={handleClick}>
💾
</Icon>

<style>
.save-icon {
font-size: 24px;
color: seagreen;
}
</style>