Skip to content

Commit 2a0476d

Browse files
enhance(ui): Extending tooltip to include default content and forceOpen (#5470)
* enhance(ui): Extending tooltip to include default content and forceOpen * enhance(ui): adding editOnly true and helper text to forceOpen prop
1 parent f372409 commit 2a0476d

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apps/frontend/components/ui/tooltip.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,36 @@ type ToolTipProps = {
3636
trigger?: React.ReactElement; // Show this
3737
content?: React.ReactElement; // Show this
3838
side?: ToolTipSide; // Position of the tooltip
39+
forceOpen?: boolean; // Force the tooltip to show
3940
};
4041

4142
const ToolTipMeta: CodeComponentMeta<ToolTipProps> = {
4243
name: "ToolTip",
4344
description: "shadcn/ui tooltip component",
4445
props: {
4546
trigger: "slot",
46-
content: "slot",
47+
content: {
48+
type: "slot",
49+
defaultValue: "Tooltip content",
50+
},
4751
side: {
4852
type: "choice",
4953
options: ["top", "right", "bottom", "left"],
5054
},
55+
forceOpen: {
56+
type: "boolean",
57+
defaultValue: false,
58+
editOnly: true,
59+
helpText: "Force the tooltip content to show.",
60+
},
5161
},
5262
};
5363

5464
function ToolTip(props: ToolTipProps) {
55-
const { className, trigger, content, side } = props;
65+
const { className, trigger, content, side, forceOpen } = props;
5666
return (
5767
<TooltipProvider>
58-
<TooltipRoot>
68+
<TooltipRoot open={forceOpen}>
5969
<TooltipTrigger asChild>
6070
<div className={className}>{trigger}</div>
6171
</TooltipTrigger>

0 commit comments

Comments
 (0)