Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/reference/generated/tooltip-arrow.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"description": "Indicates how the popup is aligned relative to specified side.",
"type": "'start' | 'center' | 'end'"
},
"data-instant": {
"description": "Present if animations should be instant.",
"type": "'delay' | 'dismiss' | 'focus'"
},
"data-side": {
"description": "Indicates which side the popup is positioned relative to the trigger.",
"type": "'top' | 'bottom' | 'left' | 'right' | 'inline-end' | 'inline-start'"
Expand Down
32 changes: 18 additions & 14 deletions docs/reference/generated/tooltip-root.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,26 @@
"description": "A ref to imperative actions.\n- `unmount`: When specified, the tooltip will not be unmounted when closed.\nInstead, the `unmount` function must be called to unmount the tooltip manually.\nUseful when the tooltip's animation is controlled by an external library.",
"detailedType": "React.RefObject<Tooltip.Root.Actions> | undefined"
},
"defaultTriggerId": {
"type": "string | null",
"description": "ID of the trigger that the tooltip is associated with.\nThis is useful in conjunction with the `defaultOpen` prop to create an initially open tooltip.",
"detailedType": "string | null | undefined"
},
"handle": {
"type": "TooltipHandle<Payload>",
"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.",
"detailedType": "{} | undefined"
},
"onOpenChangeComplete": {
"type": "((open: boolean) => void)",
"description": "Event handler called after any animations complete when the tooltip is opened or closed.",
"detailedType": "((open: boolean) => void) | undefined"
},
"triggerId": {
"type": "string | null",
"description": "ID of the trigger that the tooltip is associated with.\nThis is useful in conjuntion with the `open` prop to create a controlled tooltip.\nThere's no need to specify this prop when the tooltip is uncontrolled (i.e. when the `open` prop is not set).",
"detailedType": "string | null | undefined"
},
"trackCursorAxis": {
"type": "'none' | 'both' | 'x' | 'y'",
"default": "'none'",
Expand All @@ -40,27 +55,16 @@
"description": "Whether the tooltip is disabled.",
"detailedType": "boolean | undefined"
},
"delay": {
"type": "number",
"default": "600",
"description": "How long to wait before opening the tooltip. Specified in milliseconds.",
"detailedType": "number | undefined"
},
"closeDelay": {
"type": "number",
"default": "0",
"description": "How long to wait before closing the tooltip. Specified in milliseconds.",
"detailedType": "number | undefined"
},
"hoverable": {
"type": "boolean",
"default": "true",
"description": "Whether the tooltip contents can be hovered without closing the tooltip.",
"detailedType": "boolean | undefined"
},
"children": {
"type": "ReactNode",
"detailedType": "React.ReactNode"
"type": "ReactNode | PayloadChildRenderFunction<Payload>",
"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.",
"detailedType": "| React.ReactNode\n| ((arg: { payload: Payload | undefined }) => ReactNode)"
}
},
"dataAttributes": {},
Expand Down
22 changes: 22 additions & 0 deletions docs/reference/generated/tooltip-trigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,32 @@
"name": "TooltipTrigger",
"description": "An element to attach the tooltip to.\nRenders a `<button>` element.",
"props": {
"handle": {
"type": "TooltipHandle<Payload>",
"description": "A handle to associate the trigger with a tooltip.",
"detailedType": "{} | undefined"
},
"payload": {
"type": "Payload",
"description": "A payload to pass to the tooltip when it is opened.",
"detailedType": "Payload | undefined"
},
"style": {
"type": "CSSProperties | ((state: Tooltip.Trigger.State) => CSSProperties | undefined)",
"detailedType": "| React.CSSProperties\n| ((\n state: Tooltip.Trigger.State,\n ) => CSSProperties | undefined)\n| undefined"
},
"delay": {
"type": "number",
"default": "600",
"description": "How long to wait before opening the tooltip. Specified in milliseconds.",
"detailedType": "number | undefined"
},
"closeDelay": {
"type": "number",
"default": "0",
"description": "How long to wait before closing the tooltip. Specified in milliseconds.",
"detailedType": "number | undefined"
},
"className": {
"type": "string | ((state: Tooltip.Trigger.State) => string | undefined)",
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state.",
Expand Down
52 changes: 52 additions & 0 deletions docs/reference/generated/tooltip-viewport.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "TooltipViewport",
"description": "A viewport for displaying content transitions.\nThis component is only required if one popup can be opened by multiple triggers, its content change based on the trigger\nand switching between them is animated.\nRenders a `<div>` element.",
"props": {
"style": {
"type": "CSSProperties | ((state: Tooltip.Viewport.State) => CSSProperties | undefined)",
"detailedType": "| React.CSSProperties\n| ((\n state: Tooltip.Viewport.State,\n ) => CSSProperties | undefined)\n| undefined"
},
"children": {
"type": "ReactNode",
"description": "The content to render inside the transition container.",
"detailedType": "React.ReactNode"
},
"className": {
"type": "string | ((state: Tooltip.Viewport.State) => string | undefined)",
"description": "CSS class applied to the element, or a function that\nreturns a class based on the component’s state.",
"detailedType": "| string\n| ((state: Tooltip.Viewport.State) => string | undefined)"
},
"render": {
"type": "ReactElement | ((props: HTMLProps, state: Tooltip.Viewport.State) => ReactElement)",
"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.",
"detailedType": "| ReactElement\n| ((\n props: HTMLProps,\n state: Tooltip.Viewport.State,\n ) => ReactElement)"
}
},
"dataAttributes": {
"data-activation-direction": {
"description": "Indicates the direction from which the popup was activated.\nThis can be used to create directional animations based on how the popup was triggered.\nContains space-separated values for both horizontal and vertical axes.",
"type": "`${'left' | 'right'} {'top' | 'bottom'}`"
},
"data-current": {
"description": "Applied to the direct child of the viewport when no transitions are present or the new content when it's entering."
},
"data-instant": {
"description": "Present if animations should be instant.",
"type": "'delay' | 'dismiss' | 'focus'"
},
"data-previous": {
"description": "Applied to the direct child of the viewport that contains the exiting content when transitions are present."
},
"data-transitioning": {
"description": "Indicates that the viewport is currently transitioning between old and new content."
}
},
"cssVariables": {
"--popup-height": {
"description": "The height of the parent popup.\nThis variable is placed on the 'previous' container and stores the height of the popup when the previous content was rendered.\nIt can be used to freeze the dimensions of the popup when animating between different content."
},
"--popup-width": {
"description": "The width of the parent popup.\nThis variable is placed on the 'previous' container and stores the width of the popup when the previous content was rendered.\nIt can be used to freeze the dimensions of the popup when animating between different content."
}
}
}
194 changes: 194 additions & 0 deletions docs/src/app/(private)/experiments/tooltip/tooltips.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
.Container {
display: flex;
flex-direction: column;
gap: 0.75rem;
margin-bottom: 2rem;
}

.Panel {
display: flex;
border: 1px solid var(--color-gray-200);
background-color: var(--color-gray-50);
border-radius: 0.375rem;
padding: 0.125rem;
width: max-content;
}

.Button {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
width: 2rem;
height: 2rem;
padding: 0;
margin: 0;
outline: 0;
border: 0;
border-radius: 0.25rem;
background-color: transparent;
color: var(--color-gray-900);
user-select: none;

&[data-popup-open] {
background-color: var(--color-gray-100);
}

&:focus-visible {
background-color: transparent;
outline: 2px solid var(--color-blue);
outline-offset: -1px;
}

@media (hover: hover) {
&:hover {
background-color: var(--color-gray-100);
}
}

&:active {
background-color: var(--color-gray-200);
}
}

.Icon {
width: 1rem;
height: 1rem;
}

.ControlButton {
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.375rem;
height: 2.5rem;
padding: 0 0.875rem;
margin: 0;
outline: 0;
border: 1px solid var(--color-gray-200);
border-radius: 0.375rem;
background-color: var(--color-gray-50);
font-family: inherit;
font-size: 1rem;
font-weight: 500;
line-height: 1.5rem;
color: var(--color-gray-900);
user-select: none;

@media (hover: hover) {
&:hover {
background-color: var(--color-gray-100);
}
}

&:active {
background-color: var(--color-gray-100);
}

&:focus-visible {
outline: 2px solid var(--color-blue);
outline-offset: -1px;
}
}

.Positioner {
--easing: cubic-bezier(0.22, 1, 0.36, 1);
--animation-duration: 0.35s;

width: var(--positioner-width);
height: var(--positioner-height);
max-width: var(--available-width);

transition-property: top, left, right, bottom, transform;
transition-timing-function: var(--easing);
transition-duration: var(--animation-duration);

/* Disable transitions when data-instant is set (used for the initial positioning of the popup) */
&[data-instant] {
transition: none;
}
}

.Popup {
box-sizing: border-box;
font-size: 0.875rem;
line-height: 1.25rem;
display: flex;
flex-direction: column;
padding: 0.25rem 0.5rem;
border-radius: 0.375rem;
background-color: canvas;
transform-origin: var(--transform-origin);
transition:
width 150ms,
height 150ms,
transform 150ms,
opacity 150ms;

/* These are required to make the size animations work */
width: var(--popup-width, auto);
height: var(--popup-height, auto);

&[data-starting-style],
&[data-ending-style] {
opacity: 0;
transform: scale(0.9);
}

&[data-instant] {
transition-duration: 0ms;
}

@media (prefers-color-scheme: light) {
outline: 1px solid var(--color-gray-200);
box-shadow:
0 10px 15px -3px var(--color-gray-200),
0 4px 6px -4px var(--color-gray-200);
}

@media (prefers-color-scheme: dark) {
outline: 1px solid var(--color-gray-300);
outline-offset: -1px;
}
}

.Arrow {
display: flex;

&[data-side='top'] {
bottom: -8px;
rotate: 180deg;
}

&[data-side='bottom'] {
top: -8px;
rotate: 0deg;
}

&[data-side='left'] {
right: -13px;
rotate: 90deg;
}

&[data-side='right'] {
left: -13px;
rotate: -90deg;
}
}

.ArrowFill {
fill: canvas;
}

.ArrowOuterStroke {
@media (prefers-color-scheme: light) {
fill: var(--color-gray-200);
}
}

.ArrowInnerStroke {
@media (prefers-color-scheme: dark) {
fill: var(--color-gray-300);
}
}
Loading
Loading