@styleless-ui/react
Version:
Completely unstyled, headless and accessible React UI components.
60 lines (59 loc) • 2.02 kB
TypeScript
import * as React from "react";
import { type PopperProps } from "../Popper";
import type { VirtualElement } from "../Popper/helpers";
import type { MergeElementProps } from "../typings";
interface OwnProps {
/**
* The content of the component.
*/
children?: PopperProps["children"];
/**
* The className applied to the component.
*/
className?: PopperProps["className"];
/**
* The anchor element for the tooltip.
*/
anchorElement: React.RefObject<HTMLElement> | HTMLElement | VirtualElement | string;
/**
* Tooltip placement. It will be auto updated when `autoPlacement={true}`.
*
* @default "top"
*/
placement?: PopperProps["side"];
/**
* By enabling this option, tooltip chooses the placement automatically
* (the one with the most space available)
* and ignores the `placement` property value.
*
* @default false
*/
autoPlacement?: PopperProps["autoPlacement"];
/**
* The tooltip will be triggered by this event.\
* **Note**: choosing `"follow-mouse"` will disable `autoPlacement` property.
* @default "full-controlled"
*/
behavior?: "open-on-hover" | "open-on-click" | "follow-mouse" | "full-controlled";
/**
* If `true`, the tooltip will be open.
*/
open?: boolean;
/**
* If `true`, the tooltip will be open on mount. Use when the component is not controlled.
*/
defaultOpen?: boolean;
/**
* The Callback is fired when outside of the tooltip is clicked.
*/
onOutsideClick?: (event: MouseEvent) => void;
/**
* Used to keep mounting when more control is needed.\
* Useful when controlling animation with React animation libraries.
* @default false
*/
keepMounted?: boolean;
}
export type Props = Omit<MergeElementProps<"div", OwnProps>, "defaultValue" | "defaultChecked">;
declare const Tooltip: (props: Props, ref: React.Ref<HTMLDivElement>) => JSX.Element;
export default Tooltip;