onChange
Description
Fires when a new tab is selected in the controlUsage
onChange?: (ev: { value: string | number }) => void;
Parameters
- value - (required) the id of the newly selected tab
Example
import { useState } from "react";
function Example() {
const [active, setActive] = useState<number | string>(0);
function handleChange(ev: { value: string | number }) {
setActive(ev.value);
console.log(ev.value);
// => 2
}
return <Tabs options={tabs} value={active} onChange={handleChange} />;
}
Details
The handler function returns the id of a newly selected tab.
Related article: Catching the change of the selected tab
Related sample: Tabs