diff --git a/apps/web/vibes/soul/docs/tooltip.mdx b/apps/web/vibes/soul/docs/tooltip.mdx new file mode 100644 index 000000000..2c1c00adf --- /dev/null +++ b/apps/web/vibes/soul/docs/tooltip.mdx @@ -0,0 +1,53 @@ +--- +title: Tooltip +preview: tooltip-example +previewSize: sm +--- + +## Usage + +{/* prettier-ignore-start */} + +{` + +import { Tooltip } from '@/vibes/soul/primitives/tooltip'; + +function Usage() { + return ( + Tooltip trigger}> + Tooltip content + + ); +} +`} + + +{/* prettier-ignore-end */} + +## API Reference + +This comoponent uses the Sonner toast component. For more information, please refer to the [Sonner documentation](https://sonner.emilkowal.ski/). + +### TooltipProps + +| Prop | Type | Default | +| ------------------- | ---------------------------------------- | ---------- | +| `align` | `'center' \| 'end' \| 'start'` | `'center'` | +| `className` | `string` | | +| `delayDuration` | `number` | | +| `skipDelayDuration` | `number` | | +| `trigger` | `React.ReactNode` | | +| `open` | `boolean` | | +| `setOpen` | `(open: boolean) => void` | | +| `side` | `'top' \| 'right' \| 'bottom' \| 'left'` | `'top'` | +| `sideOffset` | `number` | `6` | + +### CSS Variables + +This component supports various CSS variables for theming. Here's a comprehensive list. + +```css +:root { + --tooltip-background: hsl(var(--background)); +} +``` diff --git a/apps/web/vibes/soul/examples.ts b/apps/web/vibes/soul/examples.ts index 55917156b..966216bad 100644 --- a/apps/web/vibes/soul/examples.ts +++ b/apps/web/vibes/soul/examples.ts @@ -1156,6 +1156,13 @@ export const examples = [ files: ['examples/primitives/toaster/index.tsx'], component: lazy(() => import('./examples/primitives/toaster')), }, + { + name: 'tooltip-example', + dependencies: [], + registryDependencies: ['tooltip'], + files: ['examples/primitives/tooltip/index.tsx'], + component: lazy(() => import('./examples/primitives/tooltip')), + }, { name: 'section-layout-example-warm', dependencies: [], diff --git a/apps/web/vibes/soul/examples/primitives/tooltip/index.tsx b/apps/web/vibes/soul/examples/primitives/tooltip/index.tsx new file mode 100644 index 000000000..674cabcd9 --- /dev/null +++ b/apps/web/vibes/soul/examples/primitives/tooltip/index.tsx @@ -0,0 +1,13 @@ +import { Tooltip } from '@/vibes/soul/primitives/tooltip'; + +export default function Preview() { + return ( +
+
+ Hover me!
} delayDuration={0}> +

Put your tooltip content here!

+ +
+ + ); +} diff --git a/apps/web/vibes/soul/navigation.ts b/apps/web/vibes/soul/navigation.ts index 8b4cfdc4b..402ce159f 100644 --- a/apps/web/vibes/soul/navigation.ts +++ b/apps/web/vibes/soul/navigation.ts @@ -159,6 +159,12 @@ const primitivePages: [Page, ...Page[]] = [ file: 'docs/toaster.mdx', component: 'toaster', }, + { + title: 'Tooltip', + slug: 'tooltip', + file: 'docs/tooltip.mdx', + component: 'tooltip', + }, ]; const sectionPages: [Page, ...Page[]] = [ diff --git a/apps/web/vibes/soul/primitives/tooltip/index.tsx b/apps/web/vibes/soul/primitives/tooltip/index.tsx new file mode 100644 index 000000000..7166fd4c0 --- /dev/null +++ b/apps/web/vibes/soul/primitives/tooltip/index.tsx @@ -0,0 +1,62 @@ +import * as TooltipPrimitive from '@radix-ui/react-tooltip'; +import { clsx } from 'clsx'; + +interface TooltipProps extends React.PropsWithChildren { + align?: 'center' | 'end' | 'start'; + className?: string; + delayDuration?: number; + skipDelayDuration?: number; + trigger?: React.ReactNode; + open?: boolean; + setOpen?: (open: boolean) => void; + side?: 'top' | 'right' | 'bottom' | 'left'; + sideOffset?: number; +} + +// eslint-disable-next-line valid-jsdoc +/** + * This component supports various CSS variables for theming. Here's a comprehensive list, along + * with their default values: + * + * ```css + * :root { + * --tooltip-background: hsl(var(--background)); + * ``` + */ +export const Tooltip = ({ + align = 'center', + className = '', + delayDuration, + skipDelayDuration, + trigger, + open, + setOpen, + side = 'top', + sideOffset = 6, + children, +}: TooltipProps) => { + return ( + + + {trigger != null && ( + + {trigger} + + )} + + + {children} + + + + + ); +};