Skip to content

The open alternative to Salesforce, designed for AI.

Align Tooltip shorthand and parts (#27488)

Raphaël Bosi74e0cea53a59
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
index 47270195797..265102a1995 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/icon-button.mdx
@@ -73,7 +73,7 @@
Distance in pixels between the button and the tooltip.
</ParamField>
-<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="bottom">
+<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="bottom">
Preferred placement of the tooltip relative to the button.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
index 4c3f1b14a14..11ea0e92949 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/input/light-icon-button.mdx
@@ -77,7 +77,7 @@
Distance in pixels between the button and the tooltip.
</ParamField>
-<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
+<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
Preferred placement of the tooltip relative to the button.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
index 3801302622f..30049b6fb2a 100644
--- a/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
@@ -78,7 +78,7 @@
Tooltip content for a string label. Defaults to the label text.
</ParamField>
-<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
+<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
Position of the string-label tooltip.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx b/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
index 378385ba90a..be71e9172a3 100644
--- a/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/surfaces/tooltip.mdx
@@ -17,7 +17,7 @@
- `close`: Closes the tooltip imperatively when called.
</ParamField>
-<ParamField body="align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;">
+<ParamField body="align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="center">
Alignment relative to the trigger. Defaults to center.
</ParamField>
@@ -33,6 +33,10 @@
Displays an arrow pointing to the trigger. Defaults to false.
</ParamField>
+<ParamField body="arrowPadding" type="number" default="5">
+ Minimum distance from the arrow to the popup edges.
+</ParamField>
+
<ParamField body="children" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt;" required>
A single trigger element. Custom components must forward their ref, native attributes, and event handlers.
</ParamField>
@@ -89,8 +93,8 @@
Portal destination. Defaults to the current theme container.
</ParamField>
-<ParamField body="content" type="ReactNode" required>
- Supplementary content displayed in the tooltip.
+<ParamField body="content" type="ReactNode | PayloadChildRenderFunction&lt;TPayload&gt;" required>
+ Supplementary content, or a function receiving the active trigger payload. Strings and numbers use the shorthand title layout.
</ParamField>
<ParamField body="defaultOpen" type="boolean" default="false">
@@ -106,6 +110,10 @@
Delay in milliseconds before opening on hover. Defaults to 600.
</ParamField>
+<ParamField body="description" type="ReactNode">
+ Optional secondary text below the shorthand title.
+</ParamField>
+
<ParamField body="disableAnchorTracking" type="boolean" default="false">
Whether to disable the popup from tracking any layout shift of its positioning anchor.
</ParamField>
@@ -118,6 +126,10 @@
Prevents hovering over the popup from keeping it open.
</ParamField>
+<ParamField body="handle" type="TooltipHandle&lt;TPayload&gt;">
+ Connects detached triggers and preserves their typed payloads.
+</ParamField>
+
<ParamField body="keepMounted" type="boolean">
Keeps the popup mounted while closed.
</ParamField>
@@ -127,7 +139,7 @@
</ParamField>
<ParamField body="onOpenChange" type="((open: boolean, eventDetails: TooltipRootChangeEventDetails) =&gt; void)">
- Called when an interaction requests a visibility change.
+ Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel().
</ParamField>
<ParamField body="onOpenChangeComplete" type="((open: boolean) =&gt; void)">
@@ -138,6 +150,14 @@
Controlled visibility of the tooltip.
</ParamField>
+<ParamField body="portalProps" type="TooltipPortalProps">
+ Full Portal props, including native props, ref and render. Overrides shorthand portal defaults.
+</ParamField>
+
+<ParamField body="positionerProps" type="TooltipPositionerProps">
+ Full Positioner props, including native props, ref and render. Overrides shorthand placement and width defaults.
+</ParamField>
+
<ParamField body="positionMethod" type="&quot;absolute&quot; | &quot;fixed&quot;" default="absolute">
CSS positioning method for the popup.
</ParamField>
@@ -153,7 +173,7 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="side" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
+<ParamField body="side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="top">
Preferred side of the trigger. Defaults to top and may change to avoid collisions.
</ParamField>
@@ -161,6 +181,10 @@
Distance from the trigger in pixels. Defaults to 10.
</ParamField>
+<ParamField body="startIcon" type="ReactNode">
+ Optional node before the shorthand title.
+</ParamField>
+
<ParamField body="sticky" type="boolean" default="false">
Whether to maintain the popup in the viewport after
the anchor element was scrolled out of view.
@@ -180,6 +204,10 @@
There's no need to specify this prop when the tooltip is uncontrolled (that is, when the `open` prop is not set).
</ParamField>
+<ParamField body="triggerProps" type="TooltipTriggerProps&lt;TPayload&gt;">
+ Full Trigger props, including native props, ref, render and payload. Overrides the shorthand trigger defaults.
+</ParamField>
+
<ParamField body="withExitAnimation" type="boolean">
Fades and slides the popup out when it closes instead of hiding it at once.
</ParamField>
@@ -193,8 +221,7 @@
</ParamField>
<ParamField body="Root.children" type="ReactNode | PayloadChildRenderFunction&lt;Payload&gt;">
- The content of the tooltip.
- This can be a regular React node or a render function that receives the `payload` of the active trigger.
+ Parts or a render function receiving the active trigger payload. Root renders no DOM node.
</ParamField>
<ParamField body="Root.defaultOpen" type="boolean" default="false">
@@ -217,13 +244,11 @@
</ParamField>
<ParamField body="Root.handle" type="TooltipHandle&lt;Payload&gt;">
- A handle to associate the tooltip with a trigger.
- If specified, allows external triggers to control the tooltip's open state.
- Can be created with the Tooltip.createHandle() method.
+ Connects detached triggers and imperative open/close actions.
</ParamField>
<ParamField body="Root.onOpenChange" type="((open: boolean, eventDetails: TooltipRootChangeEventDetails) =&gt; void)">
- Event handler called when the tooltip is opened or closed.
+ Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel().
</ParamField>
<ParamField body="Root.onOpenChangeComplete" type="((open: boolean) =&gt; void)">
@@ -264,9 +289,7 @@
</ParamField>
<ParamField body="Trigger.disabled" type="boolean" default="false">
- If `true`, the tooltip will not open when interacting with this trigger.
- Note that this doesn't apply the `disabled` attribute to the trigger element.
- If you want to disable the trigger element itself, you can pass the `disabled` prop to the trigger element via the `render` prop.
+ Disables tooltip interaction for this trigger without disabling its native element.
</ParamField>
<ParamField body="Trigger.handle" type="TooltipHandle&lt;Payload&gt;">
@@ -277,45 +300,85 @@
A payload to pass to the tooltip when it is opened.
</ParamField>
+<ParamField body="Trigger.ref" type="((((instance: HTMLButtonElement | null) =&gt; void | (() =&gt; VoidOrUndefinedOnly)) | RefObject&lt;HTMLButtonElement | null&gt;) &amp; (RefObject&lt;...&gt; | ((instance: HTMLElement | null) =&gt; void | (() =&gt; VoidOrUndefinedOnly)))) | null">
+ Ref to the rendered trigger element, a button by default.
+</ParamField>
+
<ParamField body="Trigger.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipTriggerState&gt;">
+ Composes a native element or a component that forwards attributes, handlers and ref.
+</ParamField>
+
+<ParamField body="Trigger.style" type="CSSProperties | ((state: TooltipTriggerState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Tooltip.Portal
+
+<ParamField body="Portal.className" type="string | ((state: TooltipPortalState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
+</ParamField>
+
+<ParamField body="Portal.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
+ Portal destination. Defaults to the current theme container, then the document body.
+</ParamField>
+
+<ParamField body="Portal.keepMounted" type="boolean" default="false">
+ Whether to keep the portal mounted in the DOM while the popup is hidden.
+</ParamField>
+
+<ParamField body="Portal.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the portal div.
+</ParamField>
+
+<ParamField body="Portal.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipPortalState&gt;">
Allows you to replace the component's HTML element
with a different tag, or compose it with another component.
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Trigger.style" type="CSSProperties | ((state: TooltipTriggerState) =&gt; CSSProperties | undefined)">
+<ParamField body="Portal.style" type="CSSProperties | ((state: TooltipPortalState) =&gt; CSSProperties | undefined)">
Style applied to the element, or a function that
returns a style object based on the component's state.
</ParamField>
-### Tooltip.Popup
+### Tooltip.Positioner
-<ParamField body="Popup.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="center">
- Alignment relative to the trigger. Defaults to center.
+<ParamField body="Positioner.align" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;" default="center">
+ How to align the popup relative to the specified side.
</ParamField>
-<ParamField body="Popup.alignOffset" type="number | OffsetFunction" default="0">
- Offset along the alignment axis in pixels.
-</ParamField>
+<ParamField body="Positioner.alignOffset" type="number | OffsetFunction" default="0">
+ Additional offset along the alignment axis in pixels.
+ Also accepts a function that returns the offset to read the dimensions of the anchor
+ and positioner elements, along with its side and alignment.
-<ParamField body="Popup.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
- An explicit positioning anchor for the popup.
+ The function takes a `data` object parameter with the following properties:
+ - `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.
+ - `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.
+ - `data.side`: which side of the anchor element the positioner is aligned against.
+ - `data.align`: how the positioner is aligned relative to the specified side.
</ParamField>
-<ParamField body="Popup.arrow" type="boolean" default="false">
- Displays an arrow pointing to the trigger. Defaults to false.
+<ParamField body="Positioner.anchor" type="Element | VirtualElement | RefObject&lt;Element | null&gt; | (() =&gt; Element | VirtualElement | null) | null">
+ An element to position the popup against.
+ By default, the popup will be positioned against the trigger.
</ParamField>
-<ParamField body="Popup.children" type="ReactNode">
- Content displayed inside the popup.
+<ParamField body="Positioner.arrowPadding" type="number" default="5">
+ Minimum distance to maintain between the arrow and the edges of the popup.
+
+ Use it to prevent the arrow element from hanging out of the rounded corners of a popup.
</ParamField>
-<ParamField body="Popup.className" type="string | ((state: TooltipPopupState) =&gt; string | undefined)">
- Additional CSS class for the popup.
+<ParamField body="Positioner.className" type="string | ((state: TooltipPositionerState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
-<ParamField body="Popup.collisionAvoidance" type="CollisionAvoidance">
+<ParamField body="Positioner.collisionAvoidance" type="CollisionAvoidance">
Determines how to handle collisions when positioning the popup.
`side` controls overflow on the preferred placement axis (`top`/`bottom` or `left`/`right`):
@@ -343,40 +406,64 @@
If `align` is omitted, it defaults to `'flip'`.
</ParamField>
-<ParamField body="Popup.collisionBoundary" type="Boundary" default="clipping-ancestors">
+<ParamField body="Positioner.collisionBoundary" type="Boundary" default="clipping-ancestors">
An element or a rectangle that delimits the area that the popup is confined to.
</ParamField>
-<ParamField body="Popup.collisionPadding" type="Padding" default="5">
+<ParamField body="Positioner.collisionPadding" type="Padding" default="5">
Additional space to maintain from the edge of the collision boundary.
</ParamField>
-<ParamField body="Popup.container" type="HTMLElement | ShadowRoot | RefObject&lt;HTMLElement | ShadowRoot | null&gt; | null">
- Portal destination. Defaults to the current theme container.
+<ParamField body="Positioner.disableAnchorTracking" type="boolean" default="false">
+ Whether to disable the popup from tracking any layout shift of its positioning anchor.
</ParamField>
-<ParamField body="Popup.content" type="string">
- Supplementary content displayed in the tooltip.
+<ParamField body="Positioner.positionMethod" type="&quot;absolute&quot; | &quot;fixed&quot;" default="absolute">
+ Determines which CSS `position` property to use.
</ParamField>
-<ParamField body="Popup.disableAnchorTracking" type="boolean" default="false">
- Whether to disable the popup from tracking any layout shift of its positioning anchor.
+<ParamField body="Positioner.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the positioning div. Native props, styles and render target this element.
</ParamField>
-<ParamField body="Popup.keepMounted" type="boolean">
- Keeps the popup mounted while closed.
+<ParamField body="Positioner.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipPositionerState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Popup.maxWidth" type="MaxWidth&lt;string | number&gt;" default="300px">
- Maximum popup width. Defaults to 300 pixels.
+<ParamField body="Positioner.side" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="top">
+ Preferred physical or logical side of the anchor. Defaults to top.
</ParamField>
-<ParamField body="Popup.positionMethod" type="&quot;absolute&quot; | &quot;fixed&quot;" default="absolute">
- CSS positioning method for the popup.
+<ParamField body="Positioner.sideOffset" type="number | OffsetFunction" default="0">
+ Distance from the anchor. Defaults to 0 in compound usage. Accepts a number or positioning function.
+</ParamField>
+
+<ParamField body="Positioner.sticky" type="boolean" default="false">
+ Whether to maintain the popup in the viewport after
+ the anchor element was scrolled out of view.
+</ParamField>
+
+<ParamField body="Positioner.style" type="CSSProperties | ((state: TooltipPositionerState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
+
+### Tooltip.Popup
+
+<ParamField body="Popup.children" type="ReactNode">
+ Content rendered as supplied. Does not create a portal, positioner, title layout or arrow.
+</ParamField>
+
+<ParamField body="Popup.className" type="string | ((state: TooltipPopupState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
<ParamField body="Popup.ref" type="Ref&lt;HTMLDivElement&gt;">
- Ref forwarded to the popup element.
+ Ref to the popup div. Native props, styles and render target this element.
</ParamField>
<ParamField body="Popup.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipPopupState&gt;">
@@ -386,50 +473,71 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Popup.side" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;" default="top">
- Preferred side of the trigger. Defaults to top and may change to avoid collisions.
+<ParamField body="Popup.style" type="CSSProperties | ((state: TooltipPopupState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
</ParamField>
-<ParamField body="Popup.sideOffset" type="number | OffsetFunction" default="10">
- Distance from the trigger in pixels. Defaults to 10.
+<ParamField body="Popup.withExitAnimation" type="boolean" default="false">
+ Enables the optional Twenty exit transition.
</ParamField>
-<ParamField body="Popup.sticky" type="boolean" default="false">
- Whether to maintain the popup in the viewport after
- the anchor element was scrolled out of view.
+### Tooltip.Arrow
+
+<ParamField body="Arrow.className" type="string | ((state: TooltipArrowState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
-<ParamField body="Popup.style" type="CSSProperties | ((state: TooltipPopupState) =&gt; CSSProperties | undefined)">
- Inline styles for the popup.
+<ParamField body="Arrow.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the arrow div. Compose inside Popup.
</ParamField>
-<ParamField body="Popup.withExitAnimation" type="boolean" default="false">
- Fades and slides the popup out when it closes instead of hiding it at once.
+<ParamField body="Arrow.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipArrowState&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-### Tooltip.Content
+<ParamField body="Arrow.style" type="CSSProperties | ((state: TooltipArrowState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
+</ParamField>
-<ParamField body="Content.children" type="ReactNode">
- Primary text displayed in the tooltip.
+### Tooltip.Viewport
+
+<ParamField body="Viewport.children" type="ReactNode">
+ The content to render inside the transition container.
</ParamField>
-<ParamField body="Content.description" type="ReactNode">
- Secondary explanation beneath the primary text.
+<ParamField body="Viewport.className" type="string | ((state: TooltipViewportState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
</ParamField>
-<ParamField body="Content.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+<ParamField body="Viewport.ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the content-transition div. Useful when several triggers share changing content.
+</ParamField>
+
+<ParamField body="Viewport.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, TooltipViewportState&gt;">
Allows you to replace the component's HTML element
with a different tag, or compose it with another component.
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
-<ParamField body="Content.startIcon" type="ReactNode">
- An icon displayed before the text.
+<ParamField body="Viewport.style" type="CSSProperties | ((state: TooltipViewportState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
</ParamField>
### Tooltip.Provider
+<ParamField body="Provider.children" type="ReactNode">
+ Tooltips sharing delay, closeDelay and timeout configuration. Provider renders no DOM node.
+</ParamField>
+
<ParamField body="Provider.closeDelay" type="number">
How long to wait before closing a tooltip. Specified in milliseconds.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
index 0f4497e24bd..7135445c80d 100644
--- a/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/typography/overflowing-text-with-tooltip.mdx
@@ -43,6 +43,6 @@
Hover delay in milliseconds.
</ParamField>
-<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
+<ParamField body="tooltipPlace" type="&quot;bottom&quot; | &quot;inline-end&quot; | &quot;inline-start&quot; | &quot;left&quot; | &quot;right&quot; | &quot;top&quot;">
Preferred side of the tooltip.
</ParamField>
diff --git a/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx b/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx
index 7c500cd58f0..acf5cd7cff2 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/tooltip.mdx
@@ -62,7 +62,7 @@ export const ControlledExportHelp = () => {
## Rich content and composition
-`Tooltip.Content` provides a title, optional description, and optional leading icon. Use it as `content` or inside `Tooltip.Popup`.
+Shorthand accepts `description` and `startIcon` beside `content`. Custom node content renders as supplied unless a description or icon requests the title layout.
```tsx
import { IconInfoCircle } from 'twenty-ui/icon';
@@ -70,31 +70,66 @@ import { Button } from 'twenty-ui/primitives/input';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
export const ExportDetails = () => (
- <Tooltip.Root>
- <Tooltip.Trigger render={<span />}>
- <Button>Export records</Button>
- </Tooltip.Trigger>
- <Tooltip.Popup side="right" align="start" arrow>
- <Tooltip.Content
- startIcon={<IconInfoCircle />}
- description="Only the records matching your current filters are included."
- >
- Export visible records
- </Tooltip.Content>
- </Tooltip.Popup>
- </Tooltip.Root>
+ <Tooltip
+ content="Export visible records"
+ description="Only records matching your current filters are included."
+ startIcon={<IconInfoCircle />}
+ arrow
+ >
+ <Button>Export records</Button>
+ </Tooltip>
);
```
-| Part | Purpose |
-| ---------- | ------------------------------------------------------------- |
-| `Root` | Coordinates visibility and trigger interactions. |
-| `Trigger` | Renders the element that opens the tooltip on hover or focus. |
-| `Popup` | Renders positioned content in a portal. |
-| `Content` | Styles primary text, a description, and an icon. |
-| `Provider` | Coordinates opening delays across a group of tooltips. |
+Compound usage exposes every installed Base UI part. Assemble the portal, positioning, popup and optional arrow explicitly. Popup renders its children as supplied.
+
+```tsx
+import { Button } from 'twenty-ui/primitives/input';
+import { Tooltip } from 'twenty-ui/primitives/surfaces';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const ComposedExportDetails = () => (
+ <Tooltip.Provider delay={300} closeDelay={100} timeout={400}>
+ <Tooltip.Root>
+ <Tooltip.Trigger render={<Button>Export records</Button>} />
+ <Tooltip.Portal>
+ <Tooltip.Positioner side="inline-end" sideOffset={10} arrowPadding={8}>
+ <Tooltip.Popup>
+ <Tooltip.Arrow />
+ <Tooltip.Viewport>
+ <Text style={{ fontWeight: 500 }}>Export visible records</Text>
+ <Text>
+ Only records matching your current filters are included.
+ </Text>
+ </Tooltip.Viewport>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ </Tooltip.Provider>
+);
+```
+
+| Part | Native, prop and ref target |
+| ------------ | --------------------------------------------------------------------------------------------------------------------------- |
+| `Root` | State and payload coordination. No DOM node, native props or DOM ref. `actionsRef` exposes `close` and `unmount`. |
+| `Provider` | Shared `delay`, `closeDelay` and `timeout`. No DOM node or DOM ref. |
+| `Trigger` | A button by default. Native props, handlers, `render` and ref target the trigger element. |
+| `Portal` | The portal div. Defaults to the theme container, then document body. |
+| `Positioner` | The positioning div. Owns anchor, physical/logical side, offsets, collision handling, sticky positioning and arrow padding. |
+| `Popup` | The popup div. Owns content, native props, styles, `render` and ref. |
+| `Arrow` | The arrow div inside Popup. |
+| `Viewport` | The optional div for transitions between trigger payloads. |
+
+Every DOM part accepts native props, refs, and element or callback `render` composition. Shorthand's top-level native props, `render` and ref target Popup. Use `triggerProps`, `positionerProps` and `portalProps` to customize the other targets; these override shorthand defaults. Children supply the default trigger render element. Both forms preserve controlled/uncontrolled Root state and Base UI callback event details, including cancellation, reason, original event and active trigger.
+
+`Tooltip.createHandle<TPayload>()` connects detached triggers to either form through `handle`. Compound Root's children or shorthand's `content` can be a function receiving the typed active payload. `Tooltip.Handle` and the public `TooltipHandle` type expose the installed handle contract. Handles support imperative `open(triggerId)` and `close()` while their Root is mounted.
+
+## Migration
+
+Replace `content={<Tooltip.Content description={description} startIcon={icon}>title</Tooltip.Content>}` with `content={title} description={description} startIcon={icon}`. In compound usage, compose title and description nodes directly. `Tooltip.Content` and `TooltipContentProps` are removed.
-`Tooltip.createHandle()` connects detached triggers to a shared `Root` through their `handle` prop. Keep each popup's content supplementary even when several triggers share it.
+Existing compound Popup positioning props move to Positioner. Wrap it in Portal, move `container` and `keepMounted` to Portal, replace `maxWidth` with Positioner `style`, and replace `arrow` with an Arrow child. Preserve the former assembly defaults explicitly with `sideOffset={10}` and `style={{ maxWidth: '300px' }}` when needed. Compound Positioner keeps Base UI's `sideOffset={0}` and does not impose a maximum width.
## Disabled controls
@@ -113,11 +148,11 @@ export const UnavailableExport = () => (
);
```
-Setting `disabled` on `Tooltip` suppresses the tooltip itself. It does not disable the control.
+Setting `disabled` on shorthand or Root suppresses the tooltip itself. Trigger `disabled` suppresses that trigger’s tooltip interaction. Disable the native control through its own props or Trigger’s render element.
## Placement and overflowing text
-The popup defaults to `side="top"`, `align="center"`, `sideOffset={10}`, and a maximum width of `300` pixels. Placement adjusts to available space. Use `arrow` for an arrow and `container` to override the theme's portal destination; see [theming](/ui/theming).
+Shorthand defaults to `side="top"`, `align="center"`, `sideOffset={10}`, and a maximum width of `300` pixels. Placement adjusts to available space. Use `arrow` for an arrow and `container` to override the theme's portal destination; see [theming](/ui/theming).
Use [OverflowingTextWithTooltip](/ui/primitives/typography/overflowing-text-with-tooltip) when a text label should show its full value only when truncated. Its existing `text`, `tooltipContent`, and `tooltipPlace` props remain available.
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 597575175ad..147bd9c5d94 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -101,10 +101,11 @@ attributes so React and Preact forward `true`/`false` instead of empty strings
and remove the attribute when the prop is cleared. `getAttribute` and the
selector engine read the remote properties React and Preact set, and the
selector engine matches the sandbox's custom element tags by their HTML tag
-names and reads live control properties. `TooltipPreact` therefore covers hover
-opening and Escape dismissal. Pointer leave still needs
-`mousemove` delivery from outside the component for the safe polygon, and the
-compound tooltip's title and description are not covered yet.
+names and reads live control properties. `TooltipReact` and `TooltipPreact` cover
+hover opening, keyboard focus,
+Escape dismissal, compound title and description content, and typed detached
+handle payloads through the public Tooltip interface. Pointer leave still needs
+`mousemove` delivery from outside the component for the safe polygon.
A page event crosses to the worker when the element it targets, or one of that
element's ancestors in the component, listens for that event type. It crosses
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tooltip.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tooltip.front-component.tsx
index 3bc73d3369f..50d2fcc637a 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tooltip.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tooltip.front-component.tsx
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { defineFrontComponent } from 'twenty-sdk/define';
import { Button } from 'twenty-ui/primitives/input';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
+import { Text } from 'twenty-ui/primitives/typography';
import { ThemeProvider } from 'twenty-ui/theme';
import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twenty-ui-gallery-card';
@@ -9,6 +10,7 @@ import { TwentyUiGalleryCard } from '@/__stories__/shared/front-components/twent
const TooltipExample = () => {
const [open, setOpen] = useState(false);
const [ready, setReady] = useState(false);
+ const [handle] = useState(() => Tooltip.createHandle<string>());
useEffect(() => {
setReady(true);
@@ -31,12 +33,32 @@ const TooltipExample = () => {
<Tooltip.Trigger render={<span />} delay={0}>
<Button>Export details</Button>
</Tooltip.Trigger>
- <Tooltip.Popup arrow>
- <Tooltip.Content description="Your current filters are applied.">
- Export visible records
- </Tooltip.Content>
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner sideOffset={10} style={{ maxWidth: '300px' }}>
+ <Tooltip.Popup>
+ <Tooltip.Arrow />
+ <Tooltip.Viewport>
+ <Text style={{ fontWeight: 500 }}>
+ Export visible records
+ </Text>
+ <Text>Your current filters are applied.</Text>
+ </Tooltip.Viewport>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
+ <Tooltip.Trigger
+ handle={handle}
+ payload="Detached export help"
+ render={<Button>Detached export</Button>}
+ />
+ <Tooltip<string>
+ handle={handle}
+ content={({ payload }) => payload}
+ triggerProps={{ payload: 'Local export help' }}
+ >
+ <Button>Local export</Button>
+ </Tooltip>
<p role="status" aria-busy={!ready}>
Export help: {open ? 'open' : 'closed'}
</p>
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tooltipEscapeDismissalTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tooltipEscapeDismissalTest.ts
index 624209cd684..344e32d0ccc 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tooltipEscapeDismissalTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tooltipEscapeDismissalTest.ts
@@ -34,5 +34,29 @@ export const tooltipEscapeDismissalTest: TwentyUiGalleryPlayFunction = async ({
expect(canvas.getByRole('status')).toHaveTextContent('Export help: closed'),
);
expect(page.queryByText(TOOLTIP_CONTENT)).not.toBeInTheDocument();
+ await user.tab();
+ expect(canvas.getByRole('button', { name: 'Export details' })).toHaveFocus();
+ await waitFor(() => {
+ expect(page.getByText('Export visible records')).toBeVisible();
+ expect(page.getByText('Your current filters are applied.')).toBeVisible();
+ });
+ await user.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(page.queryByText('Export visible records')).not.toBeInTheDocument(),
+ );
+ await user.tab();
+ expect(canvas.getByRole('button', { name: 'Detached export' })).toHaveFocus();
+ await waitFor(() =>
+ expect(page.getByText('Detached export help')).toBeVisible(),
+ );
+ await user.tab();
+ expect(canvas.getByRole('button', { name: 'Local export' })).toHaveFocus();
+ await waitFor(() =>
+ expect(page.getByText('Local export help')).toBeVisible(),
+ );
+ await user.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(page.queryByText('Local export help')).not.toBeInTheDocument(),
+ );
expect(errorHandler).not.toHaveBeenCalled();
};
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/edit/components/NavigationMenuItemTypeTooltip.tsx b/packages/twenty-front/src/modules/navigation-menu-item/edit/components/NavigationMenuItemTypeTooltip.tsx
index 5cbc5d3f062..c6eeca79846 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/edit/components/NavigationMenuItemTypeTooltip.tsx
+++ b/packages/twenty-front/src/modules/navigation-menu-item/edit/components/NavigationMenuItemTypeTooltip.tsx
@@ -45,18 +45,11 @@ export const NavigationMenuItemTypeTooltip = ({
return (
<Tooltip
delay={TooltipDelay.mediumDelay}
- content={
- <Tooltip.Content
- description={
- type === NavigationMenuItemType.FOLDER
- ? t`Click to edit`
- : undefined
- }
- startIcon={<Icon size={theme.icon.size.sm} />}
- >
- {label}
- </Tooltip.Content>
+ content={label}
+ description={
+ type === NavigationMenuItemType.FOLDER ? t`Click to edit` : undefined
}
+ startIcon={<Icon size={theme.icon.size.sm} />}
sideOffset={theme.spacingMultiplicator}
disabled={hidden}
onOpenChange={(...openChangeArguments) => {
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
index 160b6c53a1c..28a7d3e7829 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/components/FieldDescriptionTooltipProvider.tsx
@@ -1,5 +1,6 @@
import { FieldDescriptionTooltipContext } from '@/object-record/record-field/ui/contexts/FieldDescriptionTooltipContext';
import { type FieldDescriptionTooltipContent } from '@/object-record/record-field/ui/types/FieldDescriptionTooltipContent';
+import { TooltipTextContent } from '@/ui/layout/tooltip/components/TooltipTextContent';
import { type ReactNode, useRef, useState } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
@@ -46,11 +47,20 @@ export const FieldDescriptionTooltipProvider = ({
{({ payload }) => (
<>
{children}
- <Tooltip.Popup side="bottom" positionMethod="fixed">
- <Tooltip.Content description={payload?.description}>
- {payload?.title}
- </Tooltip.Content>
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ side="bottom"
+ positionMethod="fixed"
+ sideOffset={10}
+ style={{ maxWidth: '300px' }}
+ >
+ <Tooltip.Popup>
+ <TooltipTextContent description={payload?.description}>
+ {payload?.title}
+ </TooltipTextContent>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</>
)}
</Tooltip.Root>
diff --git a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
index 0bea62ccd0d..5c2ac472da8 100644
--- a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListFieldTooltip.tsx
@@ -1,4 +1,5 @@
import { useRecordIndexContextOrThrow } from '@/object-record/record-index/contexts/RecordIndexContext';
+import { TooltipTextContent } from '@/ui/layout/tooltip/components/TooltipTextContent';
import { type ReactNode } from 'react';
import { isDefined } from 'twenty-shared/utils';
import { useIcons } from 'twenty-ui/icon';
@@ -28,13 +29,22 @@ export const RecordListFieldTooltip = ({
return (
<>
{children}
- <Tooltip.Popup side="bottom" positionMethod="fixed">
- <Tooltip.Content
- startIcon={isDefined(FieldIcon) ? <FieldIcon /> : undefined}
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ side="bottom"
+ positionMethod="fixed"
+ sideOffset={10}
+ style={{ maxWidth: '300px' }}
>
- {fieldDefinition?.label}
- </Tooltip.Content>
- </Tooltip.Popup>
+ <Tooltip.Popup>
+ <TooltipTextContent
+ startIcon={isDefined(FieldIcon) ? <FieldIcon /> : undefined}
+ >
+ {fieldDefinition?.label}
+ </TooltipTextContent>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</>
);
}}
diff --git a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
index 73ba6266b78..c0207506bc8 100644
--- a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPill.tsx
@@ -14,6 +14,7 @@ import { currentFocusedItemSelector } from '@/ui/utilities/focus/states/currentF
import { FocusComponentType } from '@/ui/utilities/focus/types/FocusComponentType';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
+import { TooltipTextContent } from '@/ui/layout/tooltip/components/TooltipTextContent';
import { styled } from '@linaria/react';
import { plural } from '@lingui/core/macro';
import { useLingui } from '@lingui/react/macro';
@@ -258,31 +259,38 @@ export const OnboardingFreeCreditsPill = ({
<Tooltip.Root
open={!isPopoverShown && !isModalFocused && isDefined(tooltipContent)}
>
- <Tooltip.Popup
- anchor={pillRef}
- side="bottom"
- align="end"
- arrow
- withExitAnimation
- >
- <StyledTooltipContents>
- <AnimatePresence initial={false}>
- {isDefined(tooltipContent) && (
- <StyledTooltipContent
- key={tooltipContent.title}
- initial={{ opacity: 0, y: tooltipSlideOffset }}
- animate={{ opacity: 1, y: 0 }}
- exit={{ opacity: 0, y: -tooltipSlideOffset }}
- transition={{ duration: theme.animation.duration.normal }}
- >
- <Tooltip.Content description={tooltipContent.description}>
- {tooltipContent.title}
- </Tooltip.Content>
- </StyledTooltipContent>
- )}
- </AnimatePresence>
- </StyledTooltipContents>
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ anchor={pillRef}
+ side="bottom"
+ align="end"
+ sideOffset={10}
+ style={{ maxWidth: '300px' }}
+ >
+ <Tooltip.Popup withExitAnimation>
+ <StyledTooltipContents>
+ <AnimatePresence initial={false}>
+ {isDefined(tooltipContent) && (
+ <StyledTooltipContent
+ key={tooltipContent.title}
+ initial={{ opacity: 0, y: tooltipSlideOffset }}
+ animate={{ opacity: 1, y: 0 }}
+ exit={{ opacity: 0, y: -tooltipSlideOffset }}
+ transition={{ duration: theme.animation.duration.normal }}
+ >
+ <TooltipTextContent
+ description={tooltipContent.description}
+ >
+ {tooltipContent.title}
+ </TooltipTextContent>
+ </StyledTooltipContent>
+ )}
+ </AnimatePresence>
+ </StyledTooltipContents>
+ <Tooltip.Arrow />
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
index 505db941cf5..aab11580d41 100644
--- a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelsTable.tsx
@@ -235,16 +235,19 @@ export const SettingsAiModelsTable = <TModel extends AiModelSummary>({
{anchorPrefix && hoveredModel && (
<Tooltip.Root key={hoveredModel.modelId} open>
- <Tooltip.Popup
- anchor={hoveredRowRef}
- side="top"
- align="end"
- sideOffset={8}
- className={hoverCardTooltipClass}
- maxWidth="320px"
- >
- <SettingsAiModelHoverCard model={hoveredModel} />
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ anchor={hoveredRowRef}
+ side="top"
+ align="end"
+ sideOffset={8}
+ style={{ maxWidth: '320px' }}
+ >
+ <Tooltip.Popup className={hoverCardTooltipClass}>
+ <SettingsAiModelHoverCard model={hoveredModel} />
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
)}
</>
diff --git a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
index a4224e2edab..9eafd97b85f 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/search/components/SidePanelSearchRecordsPage.tsx
@@ -121,21 +121,26 @@ export const SidePanelSearchRecordsPage = () => {
{shouldDisplayPreview && (
<Tooltip.Root key={previewedItem.id} open>
- <Tooltip.Popup
- anchor={previewAnchorRef}
- side="left"
- align="start"
- sideOffset={16}
- className={previewTooltipClass}
- maxWidth={`${SIDE_PANEL_SEARCH_RECORD_PREVIEW_WIDTH}px`}
- >
- <SidePanelSearchRecordPreviewCard
- key={previewedItem.recordId}
- objectNameSingular={previewedItem.objectNameSingular}
- recordId={previewedItem.recordId}
- label={previewedItem.label}
- />
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ anchor={previewAnchorRef}
+ side="left"
+ align="start"
+ sideOffset={16}
+ style={{
+ maxWidth: `${SIDE_PANEL_SEARCH_RECORD_PREVIEW_WIDTH}px`,
+ }}
+ >
+ <Tooltip.Popup className={previewTooltipClass}>
+ <SidePanelSearchRecordPreviewCard
+ key={previewedItem.recordId}
+ objectNameSingular={previewedItem.objectNameSingular}
+ recordId={previewedItem.recordId}
+ label={previewedItem.label}
+ />
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
)}
</>
diff --git a/packages/twenty-front/src/modules/ui/layout/tooltip/components/TooltipTextContent.tsx b/packages/twenty-front/src/modules/ui/layout/tooltip/components/TooltipTextContent.tsx
new file mode 100644
index 00000000000..fcac6620ef1
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/layout/tooltip/components/TooltipTextContent.tsx
@@ -0,0 +1,66 @@
+import { styled } from '@linaria/react';
+import { type ReactNode } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledContent = styled.div`
+ display: flex;
+ flex-direction: column;
+ line-height: ${themeCssVariables.spacing[4]};
+`;
+
+const StyledTitle = styled.div`
+ align-items: center;
+ display: flex;
+ font-weight: ${themeCssVariables.font.weight.medium};
+ gap: ${themeCssVariables.spacing[1]};
+ min-inline-size: 0;
+
+ span {
+ min-inline-size: 0;
+ overflow-wrap: anywhere;
+ }
+`;
+
+const StyledIcon = styled.span`
+ align-items: center;
+ display: inline-flex;
+ flex-shrink: 0;
+
+ & > svg {
+ block-size: calc(${themeCssVariables.icon.size.sm} * 1px);
+ inline-size: calc(${themeCssVariables.icon.size.sm} * 1px);
+ }
+`;
+
+const StyledDescription = styled.div`
+ color: ${themeCssVariables.tooltip.descriptionColor};
+ overflow-wrap: anywhere;
+ white-space: pre-wrap;
+`;
+
+type TooltipTextContentProps = {
+ children?: ReactNode;
+ description?: ReactNode;
+ startIcon?: ReactNode;
+};
+
+export const TooltipTextContent = ({
+ children,
+ description,
+ startIcon,
+}: TooltipTextContentProps) => (
+ <StyledContent>
+ {isDefined(children) && children !== '' && (
+ <StyledTitle>
+ {isDefined(startIcon) && (
+ <StyledIcon aria-hidden>{startIcon}</StyledIcon>
+ )}
+ <span>{children}</span>
+ </StyledTitle>
+ )}
+ {isDefined(description) && (
+ <StyledDescription>{description}</StyledDescription>
+ )}
+ </StyledContent>
+);
diff --git a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
index 0231be77719..f04dcaa3c76 100644
--- a/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
+++ b/packages/twenty-front/src/modules/ui/suggestion/components/SuggestionItemPreviewTooltip.tsx
@@ -1,6 +1,9 @@
import { css } from '@linaria/core';
import { type ReactNode } from 'react';
-import { Tooltip, type TooltipPopupProps } from 'twenty-ui/primitives/surfaces';
+import {
+ Tooltip,
+ type TooltipPositionerProps,
+} from 'twenty-ui/primitives/surfaces';
import { themeCssVariables } from 'twenty-ui/theme';
const previewTooltipClass = css`
@@ -15,7 +18,7 @@ const previewTooltipClass = css`
`;
type SuggestionItemPreviewTooltipProps = {
- anchor: TooltipPopupProps['anchor'];
+ anchor: TooltipPositionerProps['anchor'];
width: number;
children: ReactNode;
};
@@ -26,15 +29,18 @@ export const SuggestionItemPreviewTooltip = ({
children,
}: SuggestionItemPreviewTooltipProps) => (
<Tooltip.Root open>
- <Tooltip.Popup
- anchor={anchor}
- side="right"
- align="start"
- sideOffset={16}
- className={previewTooltipClass}
- maxWidth={`${width}px`}
- >
- {children}
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ anchor={anchor}
+ side="right"
+ align="start"
+ sideOffset={16}
+ style={{ maxWidth: `${width}px` }}
+ >
+ <Tooltip.Popup className={previewTooltipClass}>
+ {children}
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
);
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx
index 88003762373..44cded00efa 100644
--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiModelTiersPreview.tsx
@@ -97,23 +97,16 @@ export const SettingsAiModelTiersPreview = () => {
<TableCell color={themeCssVariables.font.color.primary}>
<Tooltip
delay={TooltipDelay.shortDelay}
- content={
- <Tooltip.Content
- startIcon={
- isDefined(ModelIcon) ? <ModelIcon /> : undefined
- }
- description={
- !isDefined(tier.model)
- ? t`No model is available for this mode.`
- : tier.isPinned
- ? t`Manually selected for this mode.`
- : t`Automatically selected by Twenty for this mode.`
- }
- >
- {getAiModelModeDescription(tier, {
- showAutomatic: false,
- })}
- </Tooltip.Content>
+ content={getAiModelModeDescription(tier, {
+ showAutomatic: false,
+ })}
+ startIcon={isDefined(ModelIcon) ? <ModelIcon /> : undefined}
+ description={
+ !isDefined(tier.model)
+ ? t`No model is available for this mode.`
+ : tier.isPinned
+ ? t`Manually selected for this mode.`
+ : t`Automatically selected by Twenty for this mode.`
}
>
<StyledMode tabIndex={0}>
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 28823a2d1eb..46f3eb054b9 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -452,7 +452,16 @@ export const DOCUMENTED_COMPONENTS = [
source: 'primitives/surfaces/Tooltip/Tooltip.tsx',
entryPoint: 'twenty-ui/primitives/surfaces',
slug: 'surfaces/tooltip',
- parts: ['Root', 'Trigger', 'Popup', 'Content', 'Provider'],
+ parts: [
+ 'Root',
+ 'Trigger',
+ 'Portal',
+ 'Positioner',
+ 'Popup',
+ 'Arrow',
+ 'Viewport',
+ 'Provider',
+ ],
propDescriptions: TOOLTIP_PROP_DESCRIPTIONS,
propDefaults: { sideOffset: '10' },
partPropDescriptions: TOOLTIP_PART_PROP_DESCRIPTIONS,
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 93f9dbd5204..07609cf11c9 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -917,13 +917,28 @@
"PopoverTitleProps": "primitives/surfaces/Popover/types/PopoverTitleProps",
"PopoverTriggerProps": "primitives/surfaces/Popover/types/PopoverTriggerProps",
"TooltipAlign": "primitives/surfaces/Tooltip/types/TooltipAlign",
- "TooltipContentProps": "primitives/surfaces/Tooltip/types/TooltipContentProps",
+ "TooltipArrowProps": "primitives/surfaces/Tooltip/types/TooltipArrowProps",
+ "TooltipArrowState": "primitives/surfaces/Tooltip/types/TooltipArrowState",
+ "TooltipHandle": "primitives/surfaces/Tooltip/types/TooltipHandle",
"TooltipPopupProps": "primitives/surfaces/Tooltip/types/TooltipPopupProps",
+ "TooltipPopupState": "primitives/surfaces/Tooltip/types/TooltipPopupState",
+ "TooltipPortalProps": "primitives/surfaces/Tooltip/types/TooltipPortalProps",
+ "TooltipPortalState": "primitives/surfaces/Tooltip/types/TooltipPortalState",
+ "TooltipPositionerProps": "primitives/surfaces/Tooltip/types/TooltipPositionerProps",
+ "TooltipPositionerState": "primitives/surfaces/Tooltip/types/TooltipPositionerState",
"TooltipProps": "primitives/surfaces/Tooltip/types/TooltipProps",
"TooltipProviderProps": "primitives/surfaces/Tooltip/types/TooltipProviderProps",
+ "TooltipProviderState": "primitives/surfaces/Tooltip/types/TooltipProviderState",
+ "TooltipRootActions": "primitives/surfaces/Tooltip/types/TooltipRootActions",
+ "TooltipRootChangeEventDetails": "primitives/surfaces/Tooltip/types/TooltipRootChangeEventDetails",
+ "TooltipRootChangeEventReason": "primitives/surfaces/Tooltip/types/TooltipRootChangeEventReason",
"TooltipRootProps": "primitives/surfaces/Tooltip/types/TooltipRootProps",
+ "TooltipRootState": "primitives/surfaces/Tooltip/types/TooltipRootState",
"TooltipSide": "primitives/surfaces/Tooltip/types/TooltipSide",
- "TooltipTriggerProps": "primitives/surfaces/Tooltip/types/TooltipTriggerProps"
+ "TooltipTriggerProps": "primitives/surfaces/Tooltip/types/TooltipTriggerProps",
+ "TooltipTriggerState": "primitives/surfaces/Tooltip/types/TooltipTriggerState",
+ "TooltipViewportProps": "primitives/surfaces/Tooltip/types/TooltipViewportProps",
+ "TooltipViewportState": "primitives/surfaces/Tooltip/types/TooltipViewportState"
}
},
"primitives/typography": {
diff --git a/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts b/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
index fabb5432c52..8753f8ce8c0 100644
--- a/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
+++ b/packages/twenty-ui/docs/tooltipPartPropDescriptions.ts
@@ -1,13 +1,43 @@
-import { TOOLTIP_PROP_DESCRIPTIONS } from './tooltipPropDescriptions';
-
export const TOOLTIP_PART_PROP_DESCRIPTIONS = {
+ Root: {
+ children:
+ 'Parts or a render function receiving the active trigger payload. Root renders no DOM node.',
+ handle: 'Connects detached triggers and imperative open/close actions.',
+ onOpenChange:
+ 'Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel().',
+ },
+ Trigger: {
+ ref: 'Ref to the rendered trigger element, a button by default.',
+ disabled:
+ 'Disables tooltip interaction for this trigger without disabling its native element.',
+ render:
+ 'Composes a native element or a component that forwards attributes, handlers and ref.',
+ },
+ Portal: {
+ container:
+ 'Portal destination. Defaults to the current theme container, then the document body.',
+ ref: 'Ref to the portal div.',
+ },
+ Positioner: {
+ ref: 'Ref to the positioning div. Native props, styles and render target this element.',
+ sideOffset:
+ 'Distance from the anchor. Defaults to 0 in compound usage. Accepts a number or positioning function.',
+ side: 'Preferred physical or logical side of the anchor. Defaults to top.',
+ },
Popup: {
- ...TOOLTIP_PROP_DESCRIPTIONS,
- children: 'Content displayed inside the popup.',
+ children:
+ 'Content rendered as supplied. Does not create a portal, positioner, title layout or arrow.',
+ ref: 'Ref to the popup div. Native props, styles and render target this element.',
+ withExitAnimation: 'Enables the optional Twenty exit transition.',
+ },
+ Arrow: {
+ ref: 'Ref to the arrow div. Compose inside Popup.',
+ },
+ Viewport: {
+ ref: 'Ref to the content-transition div. Useful when several triggers share changing content.',
},
- Content: {
- children: 'Primary text displayed in the tooltip.',
- description: 'Secondary explanation beneath the primary text.',
- startIcon: 'An icon displayed before the text.',
+ Provider: {
+ children:
+ 'Tooltips sharing delay, closeDelay and timeout configuration. Provider renders no DOM node.',
},
};
diff --git a/packages/twenty-ui/docs/tooltipPropDescriptions.ts b/packages/twenty-ui/docs/tooltipPropDescriptions.ts
index 1725ac1c02b..c73abb40a31 100644
--- a/packages/twenty-ui/docs/tooltipPropDescriptions.ts
+++ b/packages/twenty-ui/docs/tooltipPropDescriptions.ts
@@ -1,7 +1,18 @@
export const TOOLTIP_PROP_DESCRIPTIONS = {
children:
'A single trigger element. Custom components must forward their ref, native attributes, and event handlers.',
- content: 'Supplementary content displayed in the tooltip.',
+ content:
+ 'Supplementary content, or a function receiving the active trigger payload. Strings and numbers use the shorthand title layout.',
+ description: 'Optional secondary text below the shorthand title.',
+ startIcon: 'Optional node before the shorthand title.',
+ handle: 'Connects detached triggers and preserves their typed payloads.',
+ triggerProps:
+ 'Full Trigger props, including native props, ref, render and payload. Overrides the shorthand trigger defaults.',
+ positionerProps:
+ 'Full Positioner props, including native props, ref and render. Overrides shorthand placement and width defaults.',
+ portalProps:
+ 'Full Portal props, including native props, ref and render. Overrides shorthand portal defaults.',
+ arrowPadding: 'Minimum distance from the arrow to the popup edges.',
delay: 'Delay in milliseconds before opening on hover. Defaults to 600.',
closeDelay:
'Delay in milliseconds before closing after hover ends. Defaults to 0.',
@@ -16,7 +27,8 @@ export const TOOLTIP_PROP_DESCRIPTIONS = {
positionMethod: 'CSS positioning method for the popup.',
open: 'Controlled visibility of the tooltip.',
defaultOpen: 'Initial visibility when the tooltip manages its own state.',
- onOpenChange: 'Called when an interaction requests a visibility change.',
+ onOpenChange:
+ 'Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel().',
disabled: 'Prevents the tooltip from opening.',
disableHoverablePopup:
'Prevents hovering over the popup from keeping it open.',
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index d924b7426d1..1e5e799294f 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -1410,7 +1410,7 @@
},
{
"name": "tooltipPlace",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
"defaultValue": null,
"description": "Preferred side of the tooltip."
@@ -1536,7 +1536,7 @@
},
{
"name": "tooltipPlace",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
"defaultValue": null,
"description": "Preferred placement of the tooltip relative to the button."
@@ -1662,7 +1662,7 @@
},
{
"name": "tooltipPlace",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
"defaultValue": "bottom",
"description": "Preferred placement of the tooltip relative to the button."
@@ -7046,7 +7046,7 @@
"name": "align",
"type": "\"center\" | \"end\" | \"start\"",
"required": false,
- "defaultValue": null,
+ "defaultValue": "center",
"description": "Alignment relative to the trigger. Defaults to center."
},
{
@@ -7070,6 +7070,13 @@
"defaultValue": null,
"description": "Displays an arrow pointing to the trigger. Defaults to false."
},
+ {
+ "name": "arrowPadding",
+ "type": "number",
+ "required": false,
+ "defaultValue": "5",
+ "description": "Minimum distance from the arrow to the popup edges."
+ },
{
"name": "children",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>>",
@@ -7128,10 +7135,10 @@
},
{
"name": "content",
- "type": "ReactNode",
+ "type": "ReactNode | PayloadChildRenderFunction<TPayload>",
"required": true,
"defaultValue": null,
- "description": "Supplementary content displayed in the tooltip."
+ "description": "Supplementary content, or a function receiving the active trigger payload. Strings and numbers use the shorthand title layout."
},
{
"name": "defaultOpen",
@@ -7154,6 +7161,13 @@
"defaultValue": "600",
"description": "Delay in milliseconds before opening on hover. Defaults to 600."
},
+ {
+ "name": "description",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional secondary text below the shorthand title."
+ },
{
"name": "disableAnchorTracking",
"type": "boolean",
@@ -7175,6 +7189,13 @@
"defaultValue": "false",
"description": "Prevents hovering over the popup from keeping it open."
},
+ {
+ "name": "handle",
+ "type": "TooltipHandle<TPayload>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Connects detached triggers and preserves their typed payloads."
+ },
{
"name": "keepMounted",
"type": "boolean",
@@ -7194,7 +7215,7 @@
"type": "((open: boolean, eventDetails: TooltipRootChangeEventDetails) => void)",
"required": false,
"defaultValue": null,
- "description": "Called when an interaction requests a visibility change."
+ "description": "Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel()."
},
{
"name": "onOpenChangeComplete",
@@ -7210,6 +7231,20 @@
"defaultValue": null,
"description": "Controlled visibility of the tooltip."
},
+ {
+ "name": "portalProps",
+ "type": "TooltipPortalProps",
+ "required": false,
+ "defaultValue": null,
+ "description": "Full Portal props, including native props, ref and render. Overrides shorthand portal defaults."
+ },
+ {
+ "name": "positionerProps",
+ "type": "TooltipPositionerProps",
+ "required": false,
+ "defaultValue": null,
+ "description": "Full Positioner props, including native props, ref and render. Overrides shorthand placement and width defaults."
+ },
{
"name": "positionMethod",
"type": "\"absolute\" | \"fixed\"",
@@ -7233,9 +7268,9 @@
},
{
"name": "side",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
- "defaultValue": null,
+ "defaultValue": "top",
"description": "Preferred side of the trigger. Defaults to top and may change to avoid collisions."
},
{
@@ -7245,6 +7280,13 @@
"defaultValue": "10",
"description": "Distance from the trigger in pixels. Defaults to 10."
},
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional node before the shorthand title."
+ },
{
"name": "sticky",
"type": "boolean",
@@ -7273,6 +7315,13 @@
"defaultValue": null,
"description": "ID of the trigger that the tooltip is associated with.\nThis is useful in conjunction with the `open` prop to create a controlled tooltip.\nThere's no need to specify this prop when the tooltip is uncontrolled (that is, when the `open` prop is not set)."
},
+ {
+ "name": "triggerProps",
+ "type": "TooltipTriggerProps<TPayload>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Full Trigger props, including native props, ref, render and payload. Overrides the shorthand trigger defaults."
+ },
{
"name": "withExitAnimation",
"type": "boolean",
@@ -7297,7 +7346,7 @@
"type": "ReactNode | PayloadChildRenderFunction<Payload>",
"required": false,
"defaultValue": null,
- "description": "The content of the tooltip.\nThis can be a regular React node or a render function that receives the `payload` of the active trigger."
+ "description": "Parts or a render function receiving the active trigger payload. Root renders no DOM node."
},
{
"name": "defaultOpen",
@@ -7332,14 +7381,14 @@
"type": "TooltipHandle<Payload>",
"required": false,
"defaultValue": null,
- "description": "A handle to associate the tooltip with a trigger.\nIf specified, allows external triggers to control the tooltip's open state.\nCan be created with the Tooltip.createHandle() method."
+ "description": "Connects detached triggers and imperative open/close actions."
},
{
"name": "onOpenChange",
"type": "((open: boolean, eventDetails: TooltipRootChangeEventDetails) => void)",
"required": false,
"defaultValue": null,
- "description": "Event handler called when the tooltip is opened or closed."
+ "description": "Receives the requested open state and unchanged Base UI event details, including reason, event, trigger and cancel()."
},
{
"name": "onOpenChangeComplete",
@@ -7407,7 +7456,7 @@
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "If `true`, the tooltip will not open when interacting with this trigger.\nNote that this doesn't apply the `disabled` attribute to the trigger element.\nIf you want to disable the trigger element itself, you can pass the `disabled` prop to the trigger element via the `render` prop."
+ "description": "Disables tooltip interaction for this trigger without disabling its native element."
},
{
"name": "handle",
@@ -7423,12 +7472,19 @@
"defaultValue": null,
"description": "A payload to pass to the tooltip when it is opened."
},
+ {
+ "name": "ref",
+ "type": "((((instance: HTMLButtonElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLButtonElement | null>) & (RefObject<...> | ((instance: HTMLElement | null) => void | (() => VoidOrUndefinedOnly)))) | null",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the rendered trigger element, a button by default."
+ },
{
"name": "render",
"type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipTriggerState>",
"required": false,
"defaultValue": null,
- "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
+ "description": "Composes a native element or a component that forwards attributes, handlers and ref."
},
{
"name": "style",
@@ -7440,49 +7496,89 @@
]
},
{
- "name": "Popup",
+ "name": "Portal",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: TooltipPortalState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "container",
+ "type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
+ "required": false,
+ "defaultValue": null,
+ "description": "Portal destination. Defaults to the current theme container, then the document body."
+ },
+ {
+ "name": "keepMounted",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether to keep the portal mounted in the DOM while the popup is hidden."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the portal div."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipPortalState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: TooltipPortalState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Positioner",
"props": [
{
"name": "align",
"type": "\"center\" | \"end\" | \"start\"",
"required": false,
"defaultValue": "center",
- "description": "Alignment relative to the trigger. Defaults to center."
+ "description": "How to align the popup relative to the specified side."
},
{
"name": "alignOffset",
"type": "number | OffsetFunction",
"required": false,
"defaultValue": "0",
- "description": "Offset along the alignment axis in pixels."
+ "description": "Additional offset along the alignment axis in pixels.\nAlso accepts a function that returns the offset to read the dimensions of the anchor\nand positioner elements, along with its side and alignment.\n\nThe function takes a `data` object parameter with the following properties:\n- `data.anchor`: the dimensions of the anchor element with properties `width` and `height`.\n- `data.positioner`: the dimensions of the positioner element with properties `width` and `height`.\n- `data.side`: which side of the anchor element the positioner is aligned against.\n- `data.align`: how the positioner is aligned relative to the specified side."
},
{
"name": "anchor",
"type": "Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null) | null",
"required": false,
"defaultValue": null,
- "description": "An explicit positioning anchor for the popup."
- },
- {
- "name": "arrow",
- "type": "boolean",
- "required": false,
- "defaultValue": "false",
- "description": "Displays an arrow pointing to the trigger. Defaults to false."
+ "description": "An element to position the popup against.\nBy default, the popup will be positioned against the trigger."
},
{
- "name": "children",
- "type": "ReactNode",
+ "name": "arrowPadding",
+ "type": "number",
"required": false,
- "defaultValue": null,
- "description": "Content displayed inside the popup."
+ "defaultValue": "5",
+ "description": "Minimum distance to maintain between the arrow and the edges of the popup.\n\nUse it to prevent the arrow element from hanging out of the rounded corners of a popup."
},
{
"name": "className",
- "type": "string | ((state: TooltipPopupState) => string | undefined)",
+ "type": "string | ((state: TooltipPositionerState) => string | undefined)",
"required": false,
"defaultValue": null,
- "description": "Additional CSS class for the popup."
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
},
{
"name": "collisionAvoidance",
@@ -7505,20 +7601,6 @@
"defaultValue": "5",
"description": "Additional space to maintain from the edge of the collision boundary."
},
- {
- "name": "container",
- "type": "HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null> | null",
- "required": false,
- "defaultValue": null,
- "description": "Portal destination. Defaults to the current theme container."
- },
- {
- "name": "content",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Supplementary content displayed in the tooltip."
- },
{
"name": "disableAnchorTracking",
"type": "boolean",
@@ -7526,54 +7608,40 @@
"defaultValue": "false",
"description": "Whether to disable the popup from tracking any layout shift of its positioning anchor."
},
- {
- "name": "keepMounted",
- "type": "boolean",
- "required": false,
- "defaultValue": null,
- "description": "Keeps the popup mounted while closed."
- },
- {
- "name": "maxWidth",
- "type": "MaxWidth<string | number>",
- "required": false,
- "defaultValue": "300px",
- "description": "Maximum popup width. Defaults to 300 pixels."
- },
{
"name": "positionMethod",
"type": "\"absolute\" | \"fixed\"",
"required": false,
"defaultValue": "absolute",
- "description": "CSS positioning method for the popup."
+ "description": "Determines which CSS `position` property to use."
},
{
"name": "ref",
"type": "Ref<HTMLDivElement>",
"required": false,
"defaultValue": null,
- "description": "Ref forwarded to the popup element."
+ "description": "Ref to the positioning div. Native props, styles and render target this element."
},
{
"name": "render",
- "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipPopupState>",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipPositionerState>",
"required": false,
"defaultValue": null,
"description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
},
{
"name": "side",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
"defaultValue": "top",
- "description": "Preferred side of the trigger. Defaults to top and may change to avoid collisions."
+ "description": "Preferred physical or logical side of the anchor. Defaults to top."
},
{
"name": "sideOffset",
"type": "number | OffsetFunction",
"required": false,
- "defaultValue": "10",
- "description": "Distance from the trigger in pixels. Defaults to 10."
+ "defaultValue": "0",
+ "description": "Distance from the anchor. Defaults to 0 in compound usage. Accepts a number or positioning function."
},
{
"name": "sticky",
@@ -7582,58 +7650,145 @@
"defaultValue": "false",
"description": "Whether to maintain the popup in the viewport after\nthe anchor element was scrolled out of view."
},
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: TooltipPositionerState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Popup",
+ "props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Content rendered as supplied. Does not create a portal, positioner, title layout or arrow."
+ },
+ {
+ "name": "className",
+ "type": "string | ((state: TooltipPopupState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the popup div. Native props, styles and render target this element."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipPopupState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
+ },
{
"name": "style",
"type": "CSSProperties | ((state: TooltipPopupState) => CSSProperties | undefined)",
"required": false,
"defaultValue": null,
- "description": "Inline styles for the popup."
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
},
{
"name": "withExitAnimation",
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Fades and slides the popup out when it closes instead of hiding it at once."
+ "description": "Enables the optional Twenty exit transition."
}
]
},
{
- "name": "Content",
+ "name": "Arrow",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: TooltipArrowState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the arrow div. Compose inside Popup."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipArrowState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: TooltipArrowState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
+ },
+ {
+ "name": "Viewport",
"props": [
{
"name": "children",
"type": "ReactNode",
"required": false,
"defaultValue": null,
- "description": "Primary text displayed in the tooltip."
+ "description": "The content to render inside the transition container."
},
{
- "name": "description",
- "type": "ReactNode",
+ "name": "className",
+ "type": "string | ((state: TooltipViewportState) => string | undefined)",
"required": false,
"defaultValue": null,
- "description": "Secondary explanation beneath the primary text."
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the content-transition div. Useful when several triggers share changing content."
},
{
"name": "render",
- "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, TooltipViewportState>",
"required": false,
"defaultValue": null,
"description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
},
{
- "name": "startIcon",
- "type": "ReactNode",
+ "name": "style",
+ "type": "CSSProperties | ((state: TooltipViewportState) => CSSProperties | undefined)",
"required": false,
"defaultValue": null,
- "description": "An icon displayed before the text."
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
}
]
},
{
"name": "Provider",
"props": [
+ {
+ "name": "children",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Tooltips sharing delay, closeDelay and timeout configuration. Provider renders no DOM node."
+ },
{
"name": "closeDelay",
"type": "number",
@@ -8023,7 +8178,7 @@
},
{
"name": "tooltipPlace",
- "type": "\"bottom\" | \"left\" | \"right\" | \"top\"",
+ "type": "\"bottom\" | \"inline-end\" | \"inline-start\" | \"left\" | \"right\" | \"top\"",
"required": false,
"defaultValue": null,
"description": "Position of the string-label tooltip."
diff --git a/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalMenusExample.tsx b/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalMenusExample.tsx
index e01df0c60a8..a2c251b6f90 100644
--- a/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalMenusExample.tsx
+++ b/packages/twenty-ui/src/components/__stories__/reading-direction/DirectionalMenusExample.tsx
@@ -63,7 +63,11 @@ export const DirectionalMenusExample = ({
</Dropdown.Root>
<Tooltip.Root>
<Tooltip.Trigger render={<Button>Tooltip target</Button>} />
- <Tooltip.Popup>Directional tooltip</Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner sideOffset={10} style={{ maxWidth: '300px' }}>
+ <Tooltip.Popup>Directional tooltip</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
</div>
</ThemeProvider>
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.tsx
index e54bf03cc8b..848325451d5 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/Tooltip.tsx
@@ -1,14 +1,20 @@
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+import { TooltipArrow } from './internal/TooltipArrow';
import { TooltipComponent } from './internal/TooltipComponent';
-import { TooltipContent } from './internal/TooltipContent';
import { TooltipPopup } from './internal/TooltipPopup';
+import { TooltipPortal } from './internal/TooltipPortal';
+import { TooltipPositioner } from './internal/TooltipPositioner';
export const Tooltip = Object.assign(TooltipComponent, {
Root: TooltipPrimitive.Root,
Trigger: TooltipPrimitive.Trigger,
+ Portal: TooltipPortal,
+ Positioner: TooltipPositioner,
Popup: TooltipPopup,
- Content: TooltipContent,
+ Arrow: TooltipArrow,
+ Viewport: TooltipPrimitive.Viewport,
Provider: TooltipPrimitive.Provider,
+ Handle: TooltipPrimitive.Handle,
createHandle: TooltipPrimitive.createHandle,
});
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx
index c7a8d7719f2..bc99768f979 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__stories__/Tooltip.stories.tsx
@@ -1,9 +1,10 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { useState } from 'react';
+import { useRef, useState } from 'react';
import { expect, userEvent, waitFor, within } from 'storybook/test';
import { IconInfoCircle } from '@ui/icon';
import { Button } from '@ui/primitives/input/Button/Button';
+import { Text } from '@ui/primitives/typography/Text/Text';
import { ComponentDecorator } from '@ui/testing';
import { Tooltip } from '../Tooltip';
@@ -29,9 +30,7 @@ const meta: Meta<typeof Tooltip> = {
},
render: (args) => (
<Tooltip {...args}>
- <span>
- <Button>Show details</Button>
- </span>
+ <Button>Show details</Button>
</Tooltip>
),
};
@@ -62,25 +61,15 @@ export const WithExitAnimation: Story = {
export const WithDescription: Story = {
...Default,
args: {
- content: (
- <Tooltip.Content description="The amount of this opportunity">
- Amount
- </Tooltip.Content>
- ),
+ description: 'The amount of this opportunity',
},
};
export const WithIcon: Story = {
...Default,
args: {
- content: (
- <Tooltip.Content
- startIcon={<IconInfoCircle />}
- description="The amount of this opportunity"
- >
- Amount
- </Tooltip.Content>
- ),
+ startIcon: <IconInfoCircle />,
+ description: 'The amount of this opportunity',
},
};
@@ -153,11 +142,8 @@ export const WithMaxWidth: Story = {
...Default,
args: {
maxWidth: '200px',
- content: (
- <Tooltip.Content description="A longer description that wraps naturally within the maximum tooltip width.">
- Amount
- </Tooltip.Content>
- ),
+ description:
+ 'A longer description that wraps naturally within the maximum tooltip width.',
},
};
@@ -177,7 +163,11 @@ export const SharedPopup: Story = {
<Tooltip.Trigger payload="Second amount" render={<span />}>
<Button>Second field</Button>
</Tooltip.Trigger>
- <Tooltip.Popup>{payload}</Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner sideOffset={10} style={{ maxWidth: '300px' }}>
+ <Tooltip.Popup>{payload}</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</>
)}
</Tooltip.Root>
@@ -207,3 +197,283 @@ export const Hidden: Story = {
).not.toBeInTheDocument();
},
};
+
+const PartContractExample = () => {
+ const popupRef = useRef<HTMLDivElement>(null);
+ const [reason, setReason] = useState('closed');
+
+ return (
+ <Tooltip.Provider delay={80} closeDelay={80} timeout={200}>
+ <Tooltip.Root
+ onOpenChange={(...changeArguments) => {
+ const [open, details] = changeArguments;
+ setReason(open ? details.reason : 'closed');
+ }}
+ >
+ <Tooltip.Trigger render={<Button>Compound details</Button>} />
+ <Tooltip.Portal data-tooltip-portal="compound">
+ <Tooltip.Positioner
+ side="inline-end"
+ sideOffset={12}
+ arrowPadding={8}
+ >
+ <Tooltip.Popup ref={popupRef} aria-label="Compound help">
+ <Tooltip.Arrow />
+ <Tooltip.Viewport>Compound amount</Tooltip.Viewport>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ <Tooltip
+ content="Shorthand amount"
+ side="inline-end"
+ arrow
+ arrowPadding={8}
+ triggerProps={{ 'aria-label': 'Shorthand details' }}
+ positionerProps={{ 'aria-label': 'Shorthand positioner' }}
+ portalProps={{ 'aria-label': 'Shorthand portal' }}
+ >
+ <Button>Shorthand details</Button>
+ </Tooltip>
+ <Text role="status">{reason}</Text>
+ </Tooltip.Provider>
+ );
+};
+
+export const PartsAndProvider: Story = {
+ render: () => <PartContractExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const compound = canvas.getByRole('button', { name: 'Compound details' });
+ await userEvent.hover(compound);
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument();
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Compound amount',
+ );
+ expect(canvas.getByRole('status')).toHaveTextContent('trigger-hover');
+ await userEvent.hover(page.getByRole('tooltip'));
+ expect(page.getByRole('tooltip')).toBeVisible();
+ await userEvent.unhover(page.getByRole('tooltip'));
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await userEvent.hover(
+ canvas.getByRole('button', { name: 'Shorthand details' }),
+ );
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Shorthand amount',
+ );
+ expect(page.getByLabelText('Shorthand positioner')).toBeVisible();
+ expect(page.getByLabelText('Shorthand portal')).toBeVisible();
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ await userEvent.tab();
+ expect(compound).toHaveFocus();
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Compound amount',
+ );
+ expect(canvas.getByRole('status')).toHaveTextContent('trigger-focus');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ expect(compound).toHaveFocus();
+ },
+};
+
+const ShorthandHandleExample = () => {
+ const [handle] = useState(() => Tooltip.createHandle<string>());
+ return (
+ <>
+ <Tooltip.Trigger
+ handle={handle}
+ payload="Detached amount"
+ render={<Button>Detached details</Button>}
+ />
+ <Tooltip<string>
+ handle={handle}
+ content={({ payload }) => payload}
+ triggerProps={{ payload: 'Local amount' }}
+ >
+ <Button>Local details</Button>
+ </Tooltip>
+ </>
+ );
+};
+
+export const ShorthandHandle: Story = {
+ render: () => <ShorthandHandleExample />,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await userEvent.tab();
+ expect(
+ canvas.getByRole('button', { name: 'Detached details' }),
+ ).toHaveFocus();
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Detached amount',
+ );
+ await userEvent.tab();
+ expect(canvas.getByRole('button', { name: 'Local details' })).toHaveFocus();
+ await waitFor(() =>
+ expect(
+ within(canvasElement.ownerDocument.body).getByRole('tooltip'),
+ ).toHaveTextContent('Local amount'),
+ );
+ },
+};
+
+const PositionedExample = () => {
+ const anchorRef = useRef<HTMLButtonElement>(null);
+
+ return (
+ <>
+ <Button ref={anchorRef}>Positioning anchor</Button>
+ <Tooltip.Root defaultOpen>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ anchor={anchorRef}
+ positionMethod="fixed"
+ side="bottom"
+ sideOffset={({ anchor }) => anchor.height / 2}
+ alignOffset={({ anchor }) => anchor.width / 4}
+ collisionAvoidance={{ side: 'none', align: 'none' }}
+ sticky
+ disableAnchorTracking
+ arrowPadding={12}
+ aria-label="Compound positioner"
+ >
+ <Tooltip.Popup>
+ Positioned compound hint
+ <Tooltip.Arrow />
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ <Tooltip
+ content="Positioned shorthand hint"
+ defaultOpen
+ anchor={anchorRef}
+ positionMethod="fixed"
+ side="top"
+ sideOffset={({ anchor }) => anchor.height / 2}
+ collisionAvoidance={{ side: 'none', align: 'none' }}
+ arrowPadding={12}
+ arrow
+ positionerProps={{ 'aria-label': 'Shorthand positioner' }}
+ >
+ <Button>Shorthand anchor</Button>
+ </Tooltip>
+ </>
+ );
+};
+
+export const AdvancedPositioning: Story = {
+ render: () => <PositionedExample />,
+ play: async ({ canvasElement }) => {
+ const page = within(canvasElement.ownerDocument.body);
+ const anchor = within(canvasElement).getByRole('button', {
+ name: 'Positioning anchor',
+ });
+ await waitFor(() => {
+ const anchorBounds = anchor.getBoundingClientRect();
+ const compound = page.getByLabelText('Compound positioner');
+ const shorthand = page.getByLabelText('Shorthand positioner');
+ expect(page.getByText('Positioned compound hint')).toBeVisible();
+ expect(page.getByText('Positioned shorthand hint')).toBeVisible();
+ expect(compound).toHaveAttribute('data-side', 'bottom');
+ expect(shorthand).toHaveAttribute('data-side', 'top');
+ expect(compound.style.position).toBe('fixed');
+ expect(compound.getBoundingClientRect().top).toBeCloseTo(
+ anchorBounds.bottom + anchorBounds.height / 2,
+ 0,
+ );
+ expect(shorthand.getBoundingClientRect().bottom).toBeCloseTo(
+ anchorBounds.top - anchorBounds.height / 2,
+ 0,
+ );
+ });
+ },
+};
+
+export const CompoundDisabledControl: Story = {
+ render: () => (
+ <Tooltip.Root>
+ <Tooltip.Trigger
+ render={<span tabIndex={0} aria-label="Unavailable export" />}
+ >
+ <Button disabled>Export records</Button>
+ </Tooltip.Trigger>
+ <Tooltip.Portal>
+ <Tooltip.Positioner>
+ <Tooltip.Popup>Select a record first</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ ),
+ play: async ({ canvasElement }) => {
+ await userEvent.tab();
+ expect(
+ within(canvasElement).getByLabelText('Unavailable export'),
+ ).toHaveFocus();
+ expect(within(canvasElement).getByRole('button')).toBeDisabled();
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Select a record first',
+ );
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(
+ within(canvasElement.ownerDocument.body).queryByRole('tooltip'),
+ ).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const ProviderDelays: Story = {
+ render: () => (
+ <Tooltip.Provider delay={200} closeDelay={200} timeout={400}>
+ <Tooltip content="Delayed shorthand" disableHoverablePopup>
+ <Button>Delayed shorthand trigger</Button>
+ </Tooltip>
+ <Tooltip.Root disableHoverablePopup>
+ <Tooltip.Trigger render={<Button>Delayed compound trigger</Button>} />
+ <Tooltip.Portal>
+ <Tooltip.Positioner>
+ <Tooltip.Popup>Delayed compound</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ </Tooltip.Provider>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const page = within(canvasElement.ownerDocument.body);
+ const shorthand = canvas.getByRole('button', {
+ name: 'Delayed shorthand trigger',
+ });
+ await userEvent.hover(shorthand);
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument();
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Delayed shorthand',
+ );
+ await userEvent.unhover(shorthand);
+ expect(page.getByRole('tooltip')).toBeVisible();
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ const compound = canvas.getByRole('button', {
+ name: 'Delayed compound trigger',
+ });
+ await userEvent.hover(compound);
+ expect(await findTooltip(canvasElement)).toHaveTextContent(
+ 'Delayed compound',
+ );
+ await userEvent.unhover(compound);
+ expect(page.getByRole('tooltip')).toBeVisible();
+ await waitFor(() =>
+ expect(page.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__tests__/Tooltip.test.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__tests__/Tooltip.test.tsx
index ffe177acedc..cc51bfba289 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/__tests__/Tooltip.test.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/__tests__/Tooltip.test.tsx
@@ -1,19 +1,24 @@
-import { render, screen, waitFor } from '@testing-library/react';
+import { act, render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import { type ReactNode, useState } from 'react';
+import { createRef, type ReactNode, useState } from 'react';
import { describe, expect, it, vi } from 'vitest';
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
import { Tooltip } from '../Tooltip';
import styles from '../Tooltip.module.scss';
+import { type TooltipRootActions } from '../types/TooltipRootActions';
const TooltipRootWrapper = ({ children }: { children: ReactNode }) => (
<Tooltip.Root>{children}</Tooltip.Root>
);
const OpenTooltipWrapper = ({ children }: { children: ReactNode }) => (
- <Tooltip.Root open>{children}</Tooltip.Root>
+ <Tooltip.Root open>
+ <Tooltip.Portal>
+ <Tooltip.Positioner>{children}</Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
);
runComponentConformance({
@@ -32,11 +37,44 @@ runComponentConformance({
ownClassName: styles.popup,
});
+const PopupWrapper = ({ children }: { children: ReactNode }) => (
+ <OpenTooltipWrapper>
+ <Tooltip.Popup>{children}</Tooltip.Popup>
+ </OpenTooltipWrapper>
+);
+
runComponentConformance({
- name: 'Tooltip.Content',
- element: <Tooltip.Content>Details</Tooltip.Content>,
+ name: 'Tooltip.Portal',
+ element: <Tooltip.Portal />,
refInstanceOf: HTMLDivElement,
- ownClassName: styles.content,
+ wrapper: ({ children }) => <Tooltip.Root open>{children}</Tooltip.Root>,
+});
+
+runComponentConformance({
+ name: 'Tooltip.Positioner',
+ element: <Tooltip.Positioner />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: ({ children }) => (
+ <Tooltip.Root open>
+ <Tooltip.Portal>{children}</Tooltip.Portal>
+ </Tooltip.Root>
+ ),
+ ownClassName: styles.positioner,
+});
+
+runComponentConformance({
+ name: 'Tooltip.Arrow',
+ element: <Tooltip.Arrow />,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopupWrapper,
+ ownClassName: styles.arrow,
+});
+
+runComponentConformance({
+ name: 'Tooltip.Viewport',
+ element: <Tooltip.Viewport>Details</Tooltip.Viewport>,
+ refInstanceOf: HTMLDivElement,
+ wrapper: PopupWrapper,
});
runComponentConformance({
@@ -138,7 +176,13 @@ describe('Tooltip interactions', () => {
Second
</Tooltip.Trigger>
<Tooltip.Root handle={handle}>
- {({ payload }) => <Tooltip.Popup>{payload}</Tooltip.Popup>}
+ {({ payload }) => (
+ <Tooltip.Portal>
+ <Tooltip.Positioner sideOffset={10} style={{ maxWidth: '300px' }}>
+ <Tooltip.Popup>{payload}</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ )}
</Tooltip.Root>
</>,
);
@@ -171,3 +215,189 @@ describe('Tooltip interactions', () => {
expect(screen.queryByRole('tooltip')).toBeNull();
});
});
+
+describe('Tooltip shorthand configuration', () => {
+ it('shows a description when its title is empty', async () => {
+ const user = userEvent.setup();
+ render(
+ <Tooltip content="" description="Account help">
+ <button type="button">Account</button>
+ </Tooltip>,
+ );
+
+ await user.tab();
+
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Account help',
+ );
+ });
+
+ it('suppresses empty payloads without disconnecting their triggers', async () => {
+ const user = userEvent.setup();
+ const handle = Tooltip.createHandle<string>();
+ render(
+ <>
+ <Tooltip.Trigger handle={handle}>Missing</Tooltip.Trigger>
+ <Tooltip.Trigger handle={handle} payload="">
+ Empty
+ </Tooltip.Trigger>
+ <Tooltip<string>
+ handle={handle}
+ content={({ payload }) => payload}
+ triggerProps={{ payload: 'Account help' }}
+ >
+ <button type="button">Account</button>
+ </Tooltip>
+ </>,
+ );
+
+ await user.tab();
+ await user.tab();
+ await user.tab();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Account help',
+ );
+
+ await user.tab({ shift: true });
+ expect(screen.getByRole('button', { name: 'Empty' })).toHaveFocus();
+ await waitFor(() => expect(screen.queryByRole('tooltip')).toBeNull());
+
+ await user.tab({ shift: true });
+ expect(screen.getByRole('button', { name: 'Missing' })).toHaveFocus();
+ expect(screen.queryByRole('tooltip')).toBeNull();
+
+ await user.tab();
+ await user.tab();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Account help',
+ );
+ });
+
+ it('shows a description when a payload callback returns no title', async () => {
+ const user = userEvent.setup();
+ render(
+ <Tooltip<string>
+ content={({ payload }) => payload}
+ description="Account help"
+ >
+ <button type="button">Account</button>
+ </Tooltip>,
+ );
+
+ await user.tab();
+
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Account help',
+ );
+ });
+
+ it('shares typed payloads with detached triggers and exposes imperative actions', async () => {
+ const user = userEvent.setup();
+ const handle = Tooltip.createHandle<string>();
+ const actionsRef = createRef<TooltipRootActions>();
+ render(
+ <>
+ <Tooltip.Trigger handle={handle} payload="Detached hint">
+ Detached
+ </Tooltip.Trigger>
+ <Tooltip<string>
+ handle={handle}
+ actionsRef={actionsRef}
+ content={({ payload }) => payload}
+ triggerProps={{ payload: 'Local hint' }}
+ >
+ <button type="button">Local</button>
+ </Tooltip>
+ </>,
+ );
+ await user.tab();
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(
+ 'Detached hint',
+ );
+ await user.tab();
+ await waitFor(() =>
+ expect(screen.getByRole('tooltip')).toHaveTextContent('Local hint'),
+ );
+ expect(handle.isOpen).toBe(true);
+ act(() => actionsRef.current?.close());
+ await waitFor(() => expect(screen.queryByRole('tooltip')).toBeNull());
+ expect(handle.isOpen).toBe(false);
+ });
+
+ it('preserves event details and cancellation in both forms', async () => {
+ const user = userEvent.setup();
+ const onOpenChange = vi.fn((...changeArguments) => {
+ const [, details] = changeArguments;
+ details.cancel();
+ });
+ render(
+ <>
+ <Tooltip content="Shorthand hint" onOpenChange={onOpenChange}>
+ <button type="button">Shorthand</button>
+ </Tooltip>
+ <Tooltip.Root onOpenChange={onOpenChange}>
+ <Tooltip.Trigger>Compound</Tooltip.Trigger>
+ <Tooltip.Portal>
+ <Tooltip.Positioner>
+ <Tooltip.Popup>Compound hint</Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
+ </Tooltip.Root>
+ </>,
+ );
+ await user.tab();
+ expect(onOpenChange).toHaveBeenLastCalledWith(
+ true,
+ expect.objectContaining({
+ reason: 'trigger-focus',
+ trigger: screen.getByRole('button', { name: 'Shorthand' }),
+ event: expect.any(Object),
+ cancel: expect.any(Function),
+ }),
+ );
+ await user.tab();
+ expect(onOpenChange).toHaveBeenCalledWith(
+ true,
+ expect.objectContaining({
+ reason: 'trigger-focus',
+ trigger: screen.getByRole('button', { name: 'Compound' }),
+ }),
+ );
+ expect(screen.queryByRole('tooltip')).toBeNull();
+ });
+
+ it('targets native props, render composition and refs at each shorthand part', () => {
+ const triggerRef = createRef<HTMLButtonElement>();
+ const positionerRef = createRef<HTMLDivElement>();
+ const portalRef = createRef<HTMLDivElement>();
+ const popupRef = createRef<HTMLDivElement>();
+ render(
+ <Tooltip
+ content="Hint"
+ open
+ ref={popupRef}
+ render={<section />}
+ aria-label="Popup"
+ triggerProps={{
+ ref: triggerRef,
+ 'aria-label': 'Trigger',
+ render: (props) => <button {...props} type="button" />,
+ }}
+ positionerProps={{
+ ref: positionerRef,
+ 'aria-label': 'Positioner',
+ style: { maxWidth: 240 },
+ }}
+ portalProps={{ ref: portalRef, 'aria-label': 'Portal' }}
+ >
+ <button type="button">Original</button>
+ </Tooltip>,
+ );
+ expect(triggerRef.current).toBe(screen.getByLabelText('Trigger'));
+ expect(positionerRef.current).toBe(screen.getByLabelText('Positioner'));
+ expect(positionerRef.current).toHaveStyle({ maxWidth: '240px' });
+ expect(portalRef.current).toBe(screen.getByLabelText('Portal'));
+ expect(popupRef.current).toBe(screen.getByLabelText('Popup'));
+ expect(popupRef.current?.localName).toBe('section');
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipArrow.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipArrow.tsx
new file mode 100644
index 00000000000..c71cc371c41
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipArrow.tsx
@@ -0,0 +1,13 @@
+import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Tooltip.module.scss';
+import { type TooltipArrowProps } from '../types/TooltipArrowProps';
+
+export const TooltipArrow = ({ className, ...props }: TooltipArrowProps) => (
+ <TooltipPrimitive.Arrow
+ {...props}
+ className={mergeClassNames(styles.arrow, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipBody.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipBody.tsx
new file mode 100644
index 00000000000..c2e54916bf1
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipBody.tsx
@@ -0,0 +1,33 @@
+import { type ReactNode } from 'react';
+
+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
+
+import styles from '../Tooltip.module.scss';
+
+type TooltipBodyProps = {
+ children: ReactNode;
+ description?: ReactNode;
+ startIcon?: ReactNode;
+};
+
+export const TooltipBody = ({
+ children,
+ description,
+ startIcon,
+}: TooltipBodyProps) => (
+ <div className={styles.content}>
+ {isRenderableSlot(children) && (
+ <div className={styles.title}>
+ {isRenderableSlot(startIcon) && (
+ <span className={styles.icon} aria-hidden>
+ {startIcon}
+ </span>
+ )}
+ <span>{children}</span>
+ </div>
+ )}
+ {isRenderableSlot(description) && (
+ <div className={styles.description}>{description}</div>
+ )}
+ </div>
+);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
index c7f01096fc0..e814a6c6ca7 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipComponent.tsx
@@ -1,13 +1,25 @@
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+import { isFunction, isNumber, isString } from '@sniptt/guards';
+import { type ReactNode } from 'react';
+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
import { isDefined } from '@ui/utilities/utils/isDefined';
import { type TooltipProps } from '../types/TooltipProps';
+import { TooltipArrow } from './TooltipArrow';
+import { TooltipBody } from './TooltipBody';
import { TooltipPopup } from './TooltipPopup';
+import { TooltipPortal } from './TooltipPortal';
+import { TooltipPositioner } from './TooltipPositioner';
-export const TooltipComponent = ({
+const DEFAULT_SIDE_OFFSET = 10;
+const DEFAULT_MAX_WIDTH = '300px';
+
+export const TooltipComponent = <TPayload,>({
content,
children,
+ description,
+ startIcon,
open,
defaultOpen,
onOpenChange,
@@ -16,15 +28,100 @@ export const TooltipComponent = ({
disableHoverablePopup,
trackCursorAxis,
actionsRef,
+ handle,
triggerId,
defaultTriggerId,
delay,
closeDelay,
closeOnClick,
- ...props
-}: TooltipProps) => {
+ side = 'top',
+ align = 'center',
+ sideOffset = DEFAULT_SIDE_OFFSET,
+ alignOffset,
+ anchor,
+ positionMethod,
+ collisionBoundary,
+ collisionPadding,
+ collisionAvoidance,
+ sticky,
+ arrowPadding,
+ disableAnchorTracking,
+ arrow = false,
+ maxWidth = DEFAULT_MAX_WIDTH,
+ container,
+ keepMounted,
+ triggerProps,
+ positionerProps,
+ portalProps,
+ ...popupProps
+}: TooltipProps<TPayload>) => {
+ const hasDescription = isRenderableSlot(description);
const isDisabled =
- disabled || !isDefined(content) || content === '' || content === false;
+ disabled ||
+ (!isFunction(content) && !isRenderableSlot(content) && !hasDescription);
+
+ const trigger = (
+ <TooltipPrimitive.Trigger
+ render={children}
+ delay={delay}
+ closeDelay={closeDelay}
+ closeOnClick={closeOnClick}
+ {...triggerProps}
+ />
+ );
+
+ const renderContent = (resolvedContent: ReactNode) => {
+ const hasContent = isRenderableSlot(resolvedContent) || hasDescription;
+
+ if (!hasContent) {
+ return <>{trigger}</>;
+ }
+
+ const hasTextLayout =
+ isString(resolvedContent) ||
+ isNumber(resolvedContent) ||
+ hasDescription ||
+ isRenderableSlot(startIcon);
+
+ return (
+ <>
+ {trigger}
+ <TooltipPortal
+ container={container}
+ keepMounted={keepMounted}
+ {...portalProps}
+ >
+ <TooltipPositioner
+ side={side}
+ align={align}
+ sideOffset={sideOffset}
+ alignOffset={alignOffset}
+ anchor={anchor}
+ positionMethod={positionMethod}
+ collisionBoundary={collisionBoundary}
+ collisionPadding={collisionPadding}
+ collisionAvoidance={collisionAvoidance}
+ sticky={sticky}
+ arrowPadding={arrowPadding}
+ disableAnchorTracking={disableAnchorTracking}
+ style={{ maxWidth }}
+ {...positionerProps}
+ >
+ <TooltipPopup {...popupProps}>
+ {hasTextLayout ? (
+ <TooltipBody description={description} startIcon={startIcon}>
+ {resolvedContent}
+ </TooltipBody>
+ ) : (
+ resolvedContent
+ )}
+ {arrow && <TooltipArrow />}
+ </TooltipPopup>
+ </TooltipPositioner>
+ </TooltipPortal>
+ </>
+ );
+ };
return (
<TooltipPrimitive.Root
@@ -36,16 +133,13 @@ export const TooltipComponent = ({
disableHoverablePopup={disableHoverablePopup}
trackCursorAxis={trackCursorAxis}
actionsRef={actionsRef}
+ handle={handle}
triggerId={triggerId}
defaultTriggerId={defaultTriggerId}
>
- <TooltipPrimitive.Trigger
- render={children}
- delay={delay}
- closeDelay={closeDelay}
- closeOnClick={closeOnClick}
- />
- <TooltipPopup {...props}>{content}</TooltipPopup>
+ {isFunction(content)
+ ? (payloadState) => renderContent(content(payloadState))
+ : renderContent(content)}
</TooltipPrimitive.Root>
);
};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipContent.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipContent.tsx
deleted file mode 100644
index b64235f702c..00000000000
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipContent.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { useRender } from '@base-ui/react/use-render';
-import { clsx } from 'clsx';
-
-import { isDefined } from '@ui/utilities/utils/isDefined';
-
-import styles from '../Tooltip.module.scss';
-import { type TooltipContentProps } from '../types/TooltipContentProps';
-
-export const TooltipContent = ({
- children,
- description,
- startIcon,
- className,
- render,
- ref,
- ...props
-}: TooltipContentProps) =>
- useRender({
- defaultTagName: 'div',
- render,
- ref,
- props: {
- ...props,
- className: clsx(styles.content, className),
- children: (
- <>
- {isDefined(children) && children !== '' && (
- <div className={styles.title}>
- {isDefined(startIcon) && (
- <span className={styles.icon} aria-hidden>
- {startIcon}
- </span>
- )}
- <span>{children}</span>
- </div>
- )}
- {isDefined(description) && (
- <div className={styles.description}>{description}</div>
- )}
- </>
- ),
- },
- });
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
index a5b0c286cc6..0babb465e09 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPopup.tsx
@@ -1,77 +1,19 @@
import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
-import { isNumber, isString } from '@sniptt/guards';
-import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
-import { useThemeContainer } from '@ui/theme';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
import styles from '../Tooltip.module.scss';
import { type TooltipPopupProps } from '../types/TooltipPopupProps';
-import { TooltipContent } from './TooltipContent';
-
-const DEFAULT_SIDE_OFFSET = 10;
-const DEFAULT_MAX_WIDTH = '300px';
export const TooltipPopup = ({
- side = 'top',
- align = 'center',
- sideOffset = DEFAULT_SIDE_OFFSET,
- alignOffset,
- anchor,
- positionMethod,
- collisionBoundary,
- collisionPadding,
- collisionAvoidance,
- sticky,
- disableAnchorTracking,
- arrow = false,
- withExitAnimation = false,
- maxWidth = DEFAULT_MAX_WIDTH,
- container,
- keepMounted,
className,
- children,
+ withExitAnimation = false,
...props
-}: TooltipPopupProps) => {
- const themeContainer = useThemeContainer();
- const direction = useProvidedTextDirection();
- const hasPlainTextContent = isString(children) || isNumber(children);
-
- return (
- <TooltipPrimitive.Portal
- container={container ?? themeContainer ?? undefined}
- keepMounted={keepMounted}
- >
- <TooltipPrimitive.Positioner
- dir={direction}
- side={side}
- align={align}
- sideOffset={sideOffset}
- alignOffset={alignOffset}
- anchor={anchor}
- positionMethod={positionMethod}
- collisionBoundary={collisionBoundary}
- collisionPadding={collisionPadding}
- collisionAvoidance={collisionAvoidance}
- sticky={sticky}
- disableAnchorTracking={disableAnchorTracking}
- className={styles.positioner}
- style={{ maxWidth }}
- >
- <TooltipPrimitive.Popup
- role="tooltip"
- {...props}
- data-with-exit-animation={withExitAnimation || undefined}
- className={mergeClassNames(styles.popup, className)}
- >
- {hasPlainTextContent ? (
- <TooltipContent>{children}</TooltipContent>
- ) : (
- children
- )}
- {arrow && <TooltipPrimitive.Arrow className={styles.arrow} />}
- </TooltipPrimitive.Popup>
- </TooltipPrimitive.Positioner>
- </TooltipPrimitive.Portal>
- );
-};
+}: TooltipPopupProps) => (
+ <TooltipPrimitive.Popup
+ role="tooltip"
+ data-with-exit-animation={withExitAnimation || undefined}
+ {...props}
+ className={mergeClassNames(styles.popup, className)}
+ />
+);
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPortal.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPortal.tsx
new file mode 100644
index 00000000000..5fd040e0fa9
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPortal.tsx
@@ -0,0 +1,16 @@
+import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+import { useThemeContainer } from '@ui/theme';
+
+import { type TooltipPortalProps } from '../types/TooltipPortalProps';
+
+export const TooltipPortal = ({ container, ...props }: TooltipPortalProps) => {
+ const themeContainer = useThemeContainer();
+
+ return (
+ <TooltipPrimitive.Portal
+ {...props}
+ container={container ?? themeContainer ?? undefined}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPositioner.tsx b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPositioner.tsx
new file mode 100644
index 00000000000..9443425bcc6
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/internal/TooltipPositioner.tsx
@@ -0,0 +1,22 @@
+import { Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+import { useProvidedTextDirection } from '@ui/primitives/layout/DirectionProvider/internal/useProvidedTextDirection';
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from '../Tooltip.module.scss';
+import { type TooltipPositionerProps } from '../types/TooltipPositionerProps';
+
+export const TooltipPositioner = ({
+ className,
+ ...props
+}: TooltipPositionerProps) => {
+ const direction = useProvidedTextDirection();
+
+ return (
+ <TooltipPrimitive.Positioner
+ dir={direction}
+ {...props}
+ className={mergeClassNames(styles.positioner, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipAlign.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipAlign.ts
index f9c0e0d6310..96a1f23ef66 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipAlign.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipAlign.ts
@@ -1 +1,3 @@
-export type TooltipAlign = 'start' | 'center' | 'end';
+import { type TooltipPositionerProps } from './TooltipPositionerProps';
+
+export type TooltipAlign = NonNullable<TooltipPositionerProps['align']>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowProps.ts
new file mode 100644
index 00000000000..e8fae9fbd46
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowProps.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipArrowProps = TooltipPrimitive.Arrow.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowState.ts
new file mode 100644
index 00000000000..b58ced3612f
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipArrowState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipArrowState = TooltipPrimitive.Arrow.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipContentProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipContentProps.ts
deleted file mode 100644
index 9675f8d79c7..00000000000
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipContentProps.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { type useRender } from '@base-ui/react/use-render';
-import { type ReactNode } from 'react';
-
-export type TooltipContentProps = useRender.ComponentProps<'div'> & {
- description?: ReactNode;
- startIcon?: ReactNode;
-};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipHandle.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipHandle.ts
new file mode 100644
index 00000000000..f67cbe32427
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipHandle.ts
@@ -0,0 +1,5 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipHandle<TPayload = unknown> = InstanceType<
+ typeof TooltipPrimitive.Handle<TPayload>
+>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
index 2970d3549f3..a89d94614cd 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupProps.ts
@@ -1,27 +1,5 @@
import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
-import { type CSSProperties } from 'react';
-import { type TooltipAlign } from './TooltipAlign';
-import { type TooltipSide } from './TooltipSide';
-
-export type TooltipPopupProps = TooltipPrimitive.Popup.Props &
- Pick<
- TooltipPrimitive.Positioner.Props,
- | 'anchor'
- | 'sideOffset'
- | 'alignOffset'
- | 'positionMethod'
- | 'collisionBoundary'
- | 'collisionPadding'
- | 'collisionAvoidance'
- | 'sticky'
- | 'disableAnchorTracking'
- > & {
- side?: TooltipSide;
- align?: TooltipAlign;
- arrow?: boolean;
- withExitAnimation?: boolean;
- maxWidth?: CSSProperties['maxWidth'];
- container?: TooltipPrimitive.Portal.Props['container'];
- keepMounted?: boolean;
- };
+export type TooltipPopupProps = TooltipPrimitive.Popup.Props & {
+ withExitAnimation?: boolean;
+};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupState.ts
new file mode 100644
index 00000000000..227419821c0
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPopupState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipPopupState = TooltipPrimitive.Popup.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalProps.ts
new file mode 100644
index 00000000000..3d2a826d6c4
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalProps.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipPortalProps = TooltipPrimitive.Portal.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalState.ts
new file mode 100644
index 00000000000..08bb24ac888
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPortalState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipPortalState = TooltipPrimitive.Portal.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerProps.ts
new file mode 100644
index 00000000000..af040a9a850
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerProps.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipPositionerProps = TooltipPrimitive.Positioner.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerState.ts
new file mode 100644
index 00000000000..e56569f52e6
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipPositionerState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipPositionerState = TooltipPrimitive.Positioner.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProps.ts
index 0bf326b7b7e..2dfd418791f 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProps.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProps.ts
@@ -1,14 +1,41 @@
-import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
-import { type ReactElement, type ReactNode } from 'react';
+import { type CSSProperties, type ReactElement, type ReactNode } from 'react';
import { type TooltipPopupProps } from './TooltipPopupProps';
+import { type TooltipPortalProps } from './TooltipPortalProps';
+import { type TooltipPositionerProps } from './TooltipPositionerProps';
+import { type TooltipRootProps } from './TooltipRootProps';
+import { type TooltipTriggerProps } from './TooltipTriggerProps';
-export type TooltipProps = Omit<TooltipPopupProps, 'children' | 'content'> &
- Omit<TooltipPrimitive.Root.Props, 'children' | 'handle'> &
+export type TooltipProps<TPayload = unknown> = Omit<
+ TooltipPopupProps,
+ 'children' | 'content'
+> &
+ Omit<TooltipRootProps<TPayload>, 'children'> &
+ Pick<TooltipTriggerProps<TPayload>, 'delay' | 'closeDelay' | 'closeOnClick'> &
Pick<
- TooltipPrimitive.Trigger.Props,
- 'delay' | 'closeDelay' | 'closeOnClick'
+ TooltipPositionerProps,
+ | 'side'
+ | 'align'
+ | 'anchor'
+ | 'sideOffset'
+ | 'alignOffset'
+ | 'positionMethod'
+ | 'collisionBoundary'
+ | 'collisionPadding'
+ | 'collisionAvoidance'
+ | 'sticky'
+ | 'arrowPadding'
+ | 'disableAnchorTracking'
> & {
- content: ReactNode;
+ content: TooltipRootProps<TPayload>['children'];
children: ReactElement;
+ description?: ReactNode;
+ startIcon?: ReactNode;
+ arrow?: boolean;
+ maxWidth?: CSSProperties['maxWidth'];
+ container?: TooltipPortalProps['container'];
+ keepMounted?: boolean;
+ triggerProps?: TooltipTriggerProps<TPayload>;
+ positionerProps?: TooltipPositionerProps;
+ portalProps?: TooltipPortalProps;
};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProviderState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProviderState.ts
new file mode 100644
index 00000000000..4bc62c730de
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipProviderState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipProviderState = TooltipPrimitive.Provider.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootActions.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootActions.ts
new file mode 100644
index 00000000000..2ad7ca6a0d8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootActions.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipRootActions = TooltipPrimitive.Root.Actions;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventDetails.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventDetails.ts
new file mode 100644
index 00000000000..49564cf9385
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventDetails.ts
@@ -0,0 +1,4 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipRootChangeEventDetails =
+ TooltipPrimitive.Root.ChangeEventDetails;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventReason.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventReason.ts
new file mode 100644
index 00000000000..8164e9467cf
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootChangeEventReason.ts
@@ -0,0 +1,4 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipRootChangeEventReason =
+ TooltipPrimitive.Root.ChangeEventReason;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootState.ts
new file mode 100644
index 00000000000..880bea36fe4
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipRootState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipRootState = TooltipPrimitive.Root.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipSide.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipSide.ts
index 7f8aaa14255..54f87cff5a6 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipSide.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipSide.ts
@@ -1 +1,3 @@
-export type TooltipSide = 'top' | 'right' | 'bottom' | 'left';
+import { type TooltipPositionerProps } from './TooltipPositionerProps';
+
+export type TooltipSide = NonNullable<TooltipPositionerProps['side']>;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipTriggerState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipTriggerState.ts
new file mode 100644
index 00000000000..ca391200660
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipTriggerState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipTriggerState = TooltipPrimitive.Trigger.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportProps.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportProps.ts
new file mode 100644
index 00000000000..2f9b21bb6e7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportProps.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipViewportProps = TooltipPrimitive.Viewport.Props;
diff --git a/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportState.ts b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportState.ts
new file mode 100644
index 00000000000..4e38fb98ecf
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/surfaces/Tooltip/types/TooltipViewportState.ts
@@ -0,0 +1,3 @@
+import { type Tooltip as TooltipPrimitive } from '@base-ui/react/tooltip';
+
+export type TooltipViewportState = TooltipPrimitive.Viewport.State;
diff --git a/packages/twenty-ui/src/primitives/surfaces/index.ts b/packages/twenty-ui/src/primitives/surfaces/index.ts
index b1dffc4446d..5981f458f25 100644
--- a/packages/twenty-ui/src/primitives/surfaces/index.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/index.ts
@@ -57,10 +57,25 @@ export type { PopoverTitleProps } from './Popover/types/PopoverTitleProps';
export type { PopoverTriggerProps } from './Popover/types/PopoverTriggerProps';
export { Tooltip } from './Tooltip/Tooltip';
export type { TooltipAlign } from './Tooltip/types/TooltipAlign';
-export type { TooltipContentProps } from './Tooltip/types/TooltipContentProps';
+export type { TooltipArrowProps } from './Tooltip/types/TooltipArrowProps';
+export type { TooltipArrowState } from './Tooltip/types/TooltipArrowState';
+export type { TooltipHandle } from './Tooltip/types/TooltipHandle';
export type { TooltipPopupProps } from './Tooltip/types/TooltipPopupProps';
+export type { TooltipPopupState } from './Tooltip/types/TooltipPopupState';
+export type { TooltipPortalProps } from './Tooltip/types/TooltipPortalProps';
+export type { TooltipPortalState } from './Tooltip/types/TooltipPortalState';
+export type { TooltipPositionerProps } from './Tooltip/types/TooltipPositionerProps';
+export type { TooltipPositionerState } from './Tooltip/types/TooltipPositionerState';
export type { TooltipProps } from './Tooltip/types/TooltipProps';
export type { TooltipProviderProps } from './Tooltip/types/TooltipProviderProps';
+export type { TooltipProviderState } from './Tooltip/types/TooltipProviderState';
+export type { TooltipRootActions } from './Tooltip/types/TooltipRootActions';
+export type { TooltipRootChangeEventDetails } from './Tooltip/types/TooltipRootChangeEventDetails';
+export type { TooltipRootChangeEventReason } from './Tooltip/types/TooltipRootChangeEventReason';
export type { TooltipRootProps } from './Tooltip/types/TooltipRootProps';
+export type { TooltipRootState } from './Tooltip/types/TooltipRootState';
export type { TooltipSide } from './Tooltip/types/TooltipSide';
export type { TooltipTriggerProps } from './Tooltip/types/TooltipTriggerProps';
+export type { TooltipTriggerState } from './Tooltip/types/TooltipTriggerState';
+export type { TooltipViewportProps } from './Tooltip/types/TooltipViewportProps';
+export type { TooltipViewportState } from './Tooltip/types/TooltipViewportState';
diff --git a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
index e7069606a89..21b186d24b3 100644
--- a/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
+++ b/packages/twenty-ui/src/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip.tsx
@@ -2,6 +2,7 @@ import { memo, useRef, useState, type MouseEvent, type ReactNode } from 'react';
import { isNonEmptyString } from '@sniptt/guards';
import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';
+import { TooltipBody } from '@ui/primitives/surfaces/Tooltip/internal/TooltipBody';
import { type TooltipSide } from '@ui/primitives/surfaces/Tooltip/types/TooltipSide';
import { Text } from '@ui/primitives/typography/Text/Text';
import { LinkifiedText } from './internal/LinkifiedText/LinkifiedText';
@@ -137,15 +138,23 @@ export const OverflowingTextWithTooltip = memo(
</Text>
}
/>
- <Tooltip.Popup
- className={isTooltipMultiline ? styles.multilineTooltip : undefined}
- sideOffset={5}
- side={tooltipPlace}
- positionMethod="absolute"
- onClick={handleTooltipClick}
- >
- {tooltipText}
- </Tooltip.Popup>
+ <Tooltip.Portal>
+ <Tooltip.Positioner
+ sideOffset={5}
+ side={tooltipPlace}
+ positionMethod="absolute"
+ style={{ maxWidth: '300px' }}
+ >
+ <Tooltip.Popup
+ className={
+ isTooltipMultiline ? styles.multilineTooltip : undefined
+ }
+ onClick={handleTooltipClick}
+ >
+ <TooltipBody>{tooltipText}</TooltipBody>
+ </Tooltip.Popup>
+ </Tooltip.Positioner>
+ </Tooltip.Portal>
</Tooltip.Root>
);
},