import type { Meta, StoryObj } from '@storybook/nextjs-vite'; import { Info, HelpCircle, Settings, Copy, Check, Trash2, Download, Share2 } from 'lucide-react'; import { useState } from 'react'; import { Button } from '../components/ui/button'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../components/ui/tooltip'; const meta = { title: 'UI/Tooltip', decorators: [ Story => (
), ], parameters: { layout: 'centered', }, tags: ['autodocs'], } satisfies Meta; export default meta; type Story = StoryObj; /** * Basic tooltip on an icon button. */ export const Default: Story = { render: () => ( Settings ), }; /** * Info icon with an explanatory tooltip — common pattern for forms and dashboards. */ export const InfoHelper: Story = { render: () => (
Monthly active users

Unique users who performed at least one action in the last 30 days.

), }; /** * Tooltip positioning — all four sides. */ export const Placement: Story = { render: () => (
Tooltip on top
Tooltip on left
Tooltip on right
Tooltip on bottom
), }; /** * Icon toolbar with tooltips — common pattern for action bars. */ export const IconToolbar: Story = { render: () => (
{[ { icon: Copy, label: 'Copy' }, { icon: Download, label: 'Download' }, { icon: Share2, label: 'Share' }, { icon: Trash2, label: 'Delete' }, ].map(({ icon: Icon, label }) => ( {label} ))}
), }; /** * Tooltip on a disabled button — uses a wrapper span so the trigger still receives hover events. */ export const DisabledButton: Story = { render: () => ( You need admin permissions to deploy. ), }; /** * Truncated text with a tooltip showing the full value. */ export const TruncatedText: Story = { render: () => (

This is a very long text string that will be truncated in the container

This is a very long text string that will be truncated in the container
), }; /** * Tooltip with rich content — icon + multiline text. */ export const RichContent: Story = { render: () => (

Keyboard shortcut

Press{' '} Ctrl+K {' '} to open the command palette.

), }; /** * Copy-to-clipboard button with tooltip state change on click. */ export const CopyButton: Story = { render: function CopyButtonStory() { const [copied, setCopied] = useState(false); const handleCopy = () => { setCopied(true); setTimeout(() => setCopied(false), 1500); }; return ( {copied ? 'Copied!' : 'Copy to clipboard'} ); }, };