@base-ui-components/react
Version:
Base UI is a library of headless ('unstyled') React components and low-level hooks. You gain complete control over your app's CSS and accessibility features.
61 lines (60 loc) • 2.48 kB
TypeScript
import * as React from 'react';
import { type FloatingRootContext } from '@floating-ui/react';
import type { TransitionStatus } from '../../utils/useTransitionStatus.js';
import type { GenericHTMLProps } from '../../utils/types.js';
import { type OpenChangeReason } from '../../utils/translateOpenChangeReason.js';
export declare function useTooltipRoot(params: useTooltipRoot.Parameters): useTooltipRoot.ReturnValue;
export declare namespace useTooltipRoot {
interface Parameters {
/**
* Whether the tooltip is initially open.
*
* To render a controlled tooltip, use the `open` prop instead.
* @default false
*/
defaultOpen?: boolean;
/**
* Whether the tooltip is currently open.
*/
open?: boolean;
/**
* Event handler called when the tooltip is opened or closed.
*/
onOpenChange?: (open: boolean, event?: Event, reason?: OpenChangeReason) => void;
/**
* Whether the tooltip contents can be hovered without closing the tooltip.
* @default true
*/
hoverable?: boolean;
/**
* Determines which axis the tooltip should track the cursor on.
* @default 'none'
*/
trackCursorAxis?: 'none' | 'x' | 'y' | 'both';
/**
* How long to wait before opening the tooltip. Specified in milliseconds.
* @default 600
*/
delay?: number;
/**
* How long to wait before closing the tooltip. Specified in milliseconds.
* @default 0
*/
closeDelay?: number;
}
interface ReturnValue {
open: boolean;
setOpen: (value: boolean, event?: Event, reason?: OpenChangeReason) => void;
mounted: boolean;
setMounted: React.Dispatch<React.SetStateAction<boolean>>;
getRootTriggerProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps;
getRootPopupProps: (externalProps?: GenericHTMLProps) => GenericHTMLProps;
floatingRootContext: FloatingRootContext;
instantType: 'delay' | 'dismiss' | 'focus' | undefined;
transitionStatus: TransitionStatus;
positionerElement: HTMLElement | null;
setTriggerElement: React.Dispatch<React.SetStateAction<Element | null>>;
setPositionerElement: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
popupRef: React.RefObject<HTMLElement | null>;
}
}