p-sw 90960ff800 feat: add Controlled tooltip example
Added a new example, 'Controlled', for the Tooltip component in the documentation. The 'Controlled' example demonstrates how to use tooltip with controlled states. The change includes the update of examples index and documentation MDX page.
2024-06-11 20:14:05 +09:00

17 lines
469 B
TypeScript

import { Button } from "@components/Button";
import { Tooltip, TooltipContent } from "@components/Tooltip";
import { useState } from "react";
export function Controlled() {
const [opened, setOpened] = useState(false);
return (
<Tooltip position="top" controlled opened={opened}>
<TooltipContent delay={"early"}>
<p>Tooltip!</p>
</TooltipContent>
<Button onClick={() => setOpened((p) => !p)}>Open hover</Button>
</Tooltip>
);
}