mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-30 08:04:18 +00:00
# Conflicts: # apps/v4/app/(create)/components/customizer.tsx # apps/v4/app/(create)/components/item-picker.tsx # apps/v4/app/(create)/components/lock-button.tsx # apps/v4/app/(create)/components/picker.tsx # apps/v4/app/(create)/components/preview-controls.tsx # apps/v4/app/(create)/components/preview.tsx # apps/v4/app/(create)/components/random-button.tsx # apps/v4/app/(create)/components/reset-button.tsx # apps/v4/app/(create)/components/toolbar-controls.tsx # apps/v4/app/(create)/create/page.tsx # apps/v4/components/docs-sidebar.tsx # apps/v4/components/site-header.tsx # apps/v4/examples/base/ui-rtl/tooltip.tsx # apps/v4/examples/base/ui/tooltip.tsx # apps/v4/examples/radix/ui-rtl/tooltip.tsx # apps/v4/examples/radix/ui/tooltip.tsx # apps/v4/package.json # apps/v4/public/r/styles/base-lyra/chatgpt.json # apps/v4/public/r/styles/base-lyra/elevenlabs.json # apps/v4/public/r/styles/base-lyra/github.json # apps/v4/public/r/styles/base-lyra/input-group.json # apps/v4/public/r/styles/base-lyra/preview.json # apps/v4/public/r/styles/base-lyra/tooltip-example.json # apps/v4/public/r/styles/base-lyra/tooltip.json # apps/v4/public/r/styles/base-lyra/vercel.json # apps/v4/public/r/styles/base-maia/chatgpt.json # apps/v4/public/r/styles/base-maia/elevenlabs.json # apps/v4/public/r/styles/base-maia/github.json # apps/v4/public/r/styles/base-maia/preview.json # apps/v4/public/r/styles/base-maia/tooltip-example.json # apps/v4/public/r/styles/base-maia/tooltip.json # apps/v4/public/r/styles/base-maia/vercel.json # apps/v4/public/r/styles/base-mira/chatgpt.json # apps/v4/public/r/styles/base-mira/elevenlabs.json # apps/v4/public/r/styles/base-mira/github.json # apps/v4/public/r/styles/base-mira/input-group.json # apps/v4/public/r/styles/base-mira/preview.json # apps/v4/public/r/styles/base-mira/tooltip-example.json # apps/v4/public/r/styles/base-mira/tooltip.json # apps/v4/public/r/styles/base-mira/vercel.json # apps/v4/public/r/styles/base-nova/chatgpt.json # apps/v4/public/r/styles/base-nova/elevenlabs.json # apps/v4/public/r/styles/base-nova/github.json # apps/v4/public/r/styles/base-nova/preview.json # apps/v4/public/r/styles/base-nova/tooltip-example.json # apps/v4/public/r/styles/base-nova/tooltip.json # apps/v4/public/r/styles/base-nova/vercel.json # apps/v4/public/r/styles/base-vega/chatgpt.json # apps/v4/public/r/styles/base-vega/elevenlabs.json # apps/v4/public/r/styles/base-vega/github.json # apps/v4/public/r/styles/base-vega/preview.json # apps/v4/public/r/styles/base-vega/tooltip-example.json # apps/v4/public/r/styles/base-vega/tooltip.json # apps/v4/public/r/styles/base-vega/vercel.json # apps/v4/public/r/styles/radix-lyra/chatgpt.json # apps/v4/public/r/styles/radix-lyra/elevenlabs.json # apps/v4/public/r/styles/radix-lyra/github.json # apps/v4/public/r/styles/radix-lyra/input-group.json # apps/v4/public/r/styles/radix-lyra/preview.json # apps/v4/public/r/styles/radix-lyra/tooltip-example.json # apps/v4/public/r/styles/radix-lyra/tooltip.json # apps/v4/public/r/styles/radix-lyra/vercel.json # apps/v4/public/r/styles/radix-maia/chatgpt.json # apps/v4/public/r/styles/radix-maia/elevenlabs.json # apps/v4/public/r/styles/radix-maia/github.json # apps/v4/public/r/styles/radix-maia/preview.json # apps/v4/public/r/styles/radix-maia/tooltip-example.json # apps/v4/public/r/styles/radix-maia/tooltip.json # apps/v4/public/r/styles/radix-maia/vercel.json # apps/v4/public/r/styles/radix-mira/chatgpt.json # apps/v4/public/r/styles/radix-mira/elevenlabs.json # apps/v4/public/r/styles/radix-mira/github.json # apps/v4/public/r/styles/radix-mira/input-group.json # apps/v4/public/r/styles/radix-mira/preview.json # apps/v4/public/r/styles/radix-mira/tooltip-example.json # apps/v4/public/r/styles/radix-mira/tooltip.json # apps/v4/public/r/styles/radix-mira/vercel.json # apps/v4/public/r/styles/radix-nova/chatgpt.json # apps/v4/public/r/styles/radix-nova/elevenlabs.json # apps/v4/public/r/styles/radix-nova/github.json # apps/v4/public/r/styles/radix-nova/preview.json # apps/v4/public/r/styles/radix-nova/tooltip-example.json # apps/v4/public/r/styles/radix-nova/tooltip.json # apps/v4/public/r/styles/radix-nova/vercel.json # apps/v4/public/r/styles/radix-vega/chatgpt.json # apps/v4/public/r/styles/radix-vega/elevenlabs.json # apps/v4/public/r/styles/radix-vega/github.json # apps/v4/public/r/styles/radix-vega/preview.json # apps/v4/public/r/styles/radix-vega/tooltip-example.json # apps/v4/public/r/styles/radix-vega/tooltip.json # apps/v4/public/r/styles/radix-vega/vercel.json # apps/v4/registry/bases/base/blocks/chatgpt.tsx # apps/v4/registry/bases/base/blocks/elevenlabs.tsx # apps/v4/registry/bases/base/blocks/github.tsx # apps/v4/registry/bases/base/blocks/preview.tsx # apps/v4/registry/bases/base/blocks/vercel.tsx # apps/v4/registry/bases/radix/blocks/chatgpt.tsx # apps/v4/registry/bases/radix/blocks/elevenlabs.tsx # apps/v4/registry/bases/radix/blocks/github.tsx # apps/v4/registry/bases/radix/blocks/preview.tsx # apps/v4/registry/bases/radix/blocks/vercel.tsx
192 lines
4.7 KiB
TypeScript
192 lines
4.7 KiB
TypeScript
"use client"
|
|
|
|
import {
|
|
Example,
|
|
ExampleWrapper,
|
|
} from "@/registry/bases/base/components/example"
|
|
import { Button } from "@/registry/bases/base/ui/button"
|
|
import { Kbd } from "@/registry/bases/base/ui/kbd"
|
|
import {
|
|
Tooltip,
|
|
TooltipContent,
|
|
TooltipTrigger,
|
|
} from "@/registry/bases/base/ui/tooltip"
|
|
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"
|
|
|
|
export default function TooltipExample() {
|
|
return (
|
|
<ExampleWrapper>
|
|
<TooltipBasic />
|
|
<TooltipSides />
|
|
<TooltipWithIcon />
|
|
<TooltipLongContent />
|
|
<TooltipDisabled />
|
|
<TooltipWithKeyboard />
|
|
<TooltipOnLink />
|
|
<TooltipFormatted />
|
|
</ExampleWrapper>
|
|
)
|
|
}
|
|
|
|
function TooltipBasic() {
|
|
return (
|
|
<Example title="Basic">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<Button variant="outline" className="w-fit" />}>
|
|
Show Tooltip
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
<p>Add to library</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipSides() {
|
|
return (
|
|
<Example title="Sides">
|
|
<div className="flex flex-wrap gap-2">
|
|
{(
|
|
[
|
|
"inline-start",
|
|
"left",
|
|
"top",
|
|
"bottom",
|
|
"right",
|
|
"inline-end",
|
|
] as const
|
|
).map((side) => (
|
|
<Tooltip key={side}>
|
|
<TooltipTrigger
|
|
render={<Button variant="outline" className="w-fit capitalize" />}
|
|
>
|
|
{side.replace("-", " ")}
|
|
</TooltipTrigger>
|
|
<TooltipContent side={side}>
|
|
<p>Add to library</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
))}
|
|
</div>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipWithIcon() {
|
|
return (
|
|
<Example title="With Icon">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<Button variant="ghost" size="icon" />}>
|
|
<IconPlaceholder
|
|
lucide="InfoIcon"
|
|
tabler="IconInfoCircle"
|
|
hugeicons="AlertCircleIcon"
|
|
phosphor="InfoIcon"
|
|
remixicon="RiInformationLine"
|
|
/>
|
|
<span className="sr-only">Info</span>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
<p>Additional information</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipLongContent() {
|
|
return (
|
|
<Example title="Long Content">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<Button variant="outline" className="w-fit" />}>
|
|
Show Tooltip
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
To learn more about how this works, check out the docs. If you have
|
|
any questions, please reach out to us.
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipDisabled() {
|
|
return (
|
|
<Example title="Disabled">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<span className="inline-block w-fit" />}>
|
|
<Button variant="outline" disabled>
|
|
Disabled
|
|
</Button>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
<p>This feature is currently unavailable</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipWithKeyboard() {
|
|
return (
|
|
<Example title="With Keyboard Shortcut">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<Button variant="outline" size="icon-sm" />}>
|
|
<IconPlaceholder
|
|
lucide="SaveIcon"
|
|
tabler="IconDeviceFloppy"
|
|
hugeicons="FloppyDiskIcon"
|
|
phosphor="FloppyDiskIcon"
|
|
remixicon="RiSaveLine"
|
|
/>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
Save Changes <Kbd>S</Kbd>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipOnLink() {
|
|
return (
|
|
<Example title="On Link">
|
|
<Tooltip>
|
|
<TooltipTrigger
|
|
render={
|
|
<a
|
|
href="#"
|
|
className="w-fit text-sm text-primary underline-offset-4 hover:underline"
|
|
onClick={(e) => e.preventDefault()}
|
|
/>
|
|
}
|
|
>
|
|
Learn more
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
<p>Click to read the documentation</p>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|
|
|
|
function TooltipFormatted() {
|
|
return (
|
|
<Example title="Formatted Content">
|
|
<Tooltip>
|
|
<TooltipTrigger render={<Button variant="outline" className="w-fit" />}>
|
|
Status
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
<div className="flex flex-col gap-1">
|
|
<p className="font-semibold">Active</p>
|
|
<p className="text-xs opacity-80">Last updated 2 hours ago</p>
|
|
</div>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
</Example>
|
|
)
|
|
}
|