UNPKG

5.12 kBTypeScriptView Raw
1import * as React from 'react';
2import { ReactElement } from 'react';
3import { Props as TippyProps } from '../../helpers/Popper/DeprecatedTippyTypes';
4export declare enum TooltipPosition {
5 auto = "auto",
6 top = "top",
7 bottom = "bottom",
8 left = "left",
9 right = "right",
10 topStart = "top-start",
11 topEnd = "top-end",
12 bottomStart = "bottom-start",
13 bottomEnd = "bottom-end",
14 leftStart = "left-start",
15 leftEnd = "left-end",
16 rightStart = "right-start",
17 rightEnd = "right-end"
18}
19export interface TooltipProps extends Omit<React.HTMLProps<HTMLDivElement>, 'content'> {
20 /** The element to append the tooltip to, defaults to body */
21 appendTo?: HTMLElement | ((ref?: HTMLElement) => HTMLElement);
22 /**
23 * aria-labelledby or aria-describedby for tooltip.
24 * The trigger will be cloned to add the aria attribute, and the corresponding id in the form of 'pf-tooltip-#' is added to the content container.
25 * If you don't want that or prefer to add the aria attribute yourself on the trigger, set aria to 'none'.
26 */
27 aria?: 'describedby' | 'labelledby' | 'none';
28 /**
29 * Determines whether the tooltip is an aria-live region. If the reference prop is passed in the
30 * default behavior is 'polite' in order to ensure the tooltip contents is announced to
31 * assistive technologies. Otherwise the default behavior is 'off'.
32 */
33 'aria-live'?: 'off' | 'polite';
34 /**
35 * The reference element to which the Tooltip is relatively placed to.
36 * If you cannot wrap the reference with the Tooltip, you can use the reference prop instead.
37 * Usage: <Tooltip><Button>Reference</Button></Tooltip>
38 */
39 children?: ReactElement<any>;
40 /**
41 * The reference element to which the Tooltip is relatively placed to.
42 * If you can wrap the reference with the Tooltip, you can use the children prop instead.
43 * Usage: <Tooltip reference={() => document.getElementById('reference-element')} />
44 */
45 reference?: HTMLElement | (() => HTMLElement) | React.RefObject<any>;
46 /** Tooltip additional class */
47 className?: string;
48 /** Tooltip content */
49 content: React.ReactNode;
50 /** Distance of the tooltip to its target, defaults to 15 */
51 distance?: number;
52 /** If true, tries to keep the tooltip in view by flipping it if necessary */
53 enableFlip?: boolean;
54 /** Delay in ms before the tooltip appears */
55 entryDelay?: number;
56 /** Delay in ms before the tooltip disappears */
57 exitDelay?: number;
58 /**
59 * The desired position to flip the tooltip to if the initial position is not possible.
60 * By setting this prop to 'flip' it attempts to flip the tooltip to the opposite side if there is no space.
61 * You can also pass an array of positions that determines the flip order. It should contain the initial position
62 * followed by alternative positions if that position is unavailable.
63 * Example: Initial position is 'top'. Button with tooltip is in the top right corner. 'flipBehavior' is set to
64 * ['top', 'right', 'left']. Since there is no space to the top, it checks if right is available. There's also no
65 * space to the right, so it finally shows the tooltip on the left.
66 */
67 flipBehavior?: 'flip' | ('top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end')[];
68 /** Maximum width of the tooltip (default 18.75rem) */
69 maxWidth?: string;
70 /**
71 * Tooltip position. Note: With 'enableFlip' set to true,
72 * it will change the position if there is not enough space for the starting position.
73 * The behavior of where it flips to can be controlled through the flipBehavior prop.
74 * The 'auto' position chooses the side with the most space.
75 * The 'auto' position requires the 'enableFlip' prop to be true.
76 */
77 position?: TooltipPosition | 'auto' | 'top' | 'bottom' | 'left' | 'right' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-start' | 'left-end' | 'right-start' | 'right-end';
78 /**
79 * Tooltip trigger: click, mouseenter, focus, manual
80 * Set to manual to trigger tooltip programmatically (through the isVisible prop)
81 */
82 trigger?: string;
83 /** Flag to indicate that the text content is left aligned */
84 isContentLeftAligned?: boolean;
85 /** value for visibility when trigger is 'manual' */
86 isVisible?: boolean;
87 /** z-index of the tooltip */
88 zIndex?: number;
89 /** id of the tooltip */
90 id?: string;
91 /** CSS fade transition animation duration */
92 animationDuration?: number;
93 /** @deprecated - no longer used. if you want to constrain the popper to a specific element use the appendTo prop instead */
94 boundary?: 'scrollParent' | 'window' | 'viewport' | HTMLElement;
95 /** @deprecated - no longer used */
96 isAppLauncher?: boolean;
97 /** @deprecated - no longer used */
98 tippyProps?: Partial<TippyProps>;
99}
100export declare const Tooltip: React.FunctionComponent<TooltipProps>;
101//# sourceMappingURL=Tooltip.d.ts.map
\No newline at end of file