1 ---
2 sidebar_label: "Conditional Tooltip"
3 ---
4
5 import { TypeList } from "docs-ui"
6
7 export const metadata = {
8 title: `ConditionalTooltip - Admin Components`,
9 }
10
11 # {metadata.title}
12
13 <Note>
14
15 This component is available since Medusa [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0).
16
17 </Note>
18
19 The `ConditionalTooltip` component wraps its children in a [Tooltip](!ui!/components/tooltip) only when a condition is met, and renders them unchanged otherwise. The Medusa Admin uses it for elements whose tooltip is only useful in some states, such as truncated table cells and disabled action menu items.
20
21 ```tsx
22 import {
23 ConditionalTooltip,
24 } from "@medusajs/dashboard/components"
25 ```
26
27 ---
28
29 ## Example
30
31 Show a tooltip on a product's title only when the title is too long to fit:
32
33 ```tsx
34 import { defineWidgetConfig } from "@medusajs/admin-sdk"
35 import {
36 ConditionalTooltip,
37 } from "@medusajs/dashboard/components"
38 import { Container, Text } from "@medusajs/ui"
39
40 const ProductTitleWidget = () => {
41 const title = "A very long product title"
42
43 return (
44 <Container>
45 <ConditionalTooltip
46 content={title}
47 showTooltip={title.length > 20}
48 >
49 <Text className="truncate">{title}</Text>
50 </ConditionalTooltip>
51 </Container>
52 )
53 }
54
55 export const config = defineWidgetConfig({
56 zone: "product.details.before",
57 })
58
59 export default ProductTitleWidget
60 ```
61
62 ---
63
64 ## Props
65
66 The component accepts all props of the [Tooltip](!ui!/components/tooltip) component from Medusa UI, in addition to the following prop:
67
68 <TypeList
69 types={[
70 {
71 name: "showTooltip",
72 type: "`boolean`",
73 optional: true,
74 defaultValue: "false",
75 description:
76 "Whether to wrap the children in a tooltip. When `false`, the children render without a tooltip.",
77 },
78 {
79 name: "children",
80 type: "`React.ReactNode`",
81 optional: false,
82 description: "The element that the tooltip is shown for.",
83 },
84 {
85 name: "content",
86 type: "`React.ReactNode`",
87 optional: false,
88 description: `The tooltip's content. This prop is passed to the underlying [Tooltip](!ui!/components/tooltip) component.`,
89 },
90 ]}
91 />