Skip to main content

click

Description

adds a click handler to a Two State button

Type

function

Example

<script>
function myFunction() {
showNotice({
text: "Two State Button clicked",
});
}
</script>

<div>
<TwoState click={myFunction}>Click Me</TwoState>
</div>

Details

If the name of the handler function matches the name of the property, you can use the {click} shorthand:

<script>
function click() {
// some custom logic
};
</script>

<div>
<TwoState {click}>Click Me</TwoState>
</div>

The click handler allows you to inactivate two state buttons by blocking the default click handling:

<TwoState click={ev => ev.preventDefault()}>
Inactive
</TwoState>

Related articles: Handling a button click, Making a button inactive

Related sample: Two State Button