Tooltips are very useful to communicate extra information related to an element on the screen. The information should be contextual, useful, and nonessential.
How to use Tooltip
- Even though it's possible to pass any ReactNode as a content of the Tooltip, we do not recommend passing very complex components try to use only Phrasing content
Code examples
Content guidelines
- Use short and clear messages as the Tooltip’s content
Accessibility
- Do not put essential information in Tooltipcomponent
- Add unique idproperty to the tooltip, so appropriate a11y attributes could be used.
Props
- Namechildren(required)DescriptionChild nodes to be rendered in the component and that will show the tooltip when they are hovered ReactNode
- NameasDescriptionHTML element used to wrap the target of the tooltip HTML Tag or React Component (e.g. div, span, etc)
- NameclassNameDescriptionCSS class to be appended to the root element string
- NamecontentDescriptionContent of the tooltip string
- NamehideDelayDescriptionIt sets a delay period for the tooltip Defaultnumber0
- NameidDescriptionA unique id of the tooltip string
- NameisDisabledDescriptionPrevents showing the tooltip Defaultfalsetruefalse
- NameisVisibleDescriptionIt controls the initial visibility of the tooltip falsetrue
- NamemaxWidthDescriptionIt sets a max-width for the tooltip Defaultnumber"-moz-initial""inherit""initial""revert""unset""-moz-fit-content""-moz-max-content""-moz-min-content""-webkit-fit-content""-webkit-max-content""-webkit-min-content""fit-content""intrinsic""max-content""min-content""none"string & {}360
- NameonBlurDescriptionFunction that will be called when target gets blurred (evt: FocusEvent<Element>) => void
- NameonFocusDescriptionFunction that will be called when target gets focused (evt: FocusEvent<Element>) => void
- NameonKeyDownDescriptionFunction that will be called when the user uses a keyboard key on the target (evt: KeyboardEvent) => void
- NameonMouseLeaveDescriptionFunction that will be called when the user move the mouse out of the target (evt: MouseEvent<Element, MouseEvent>) => void
- NameonMouseOverDescriptionFunction that will be called when the user move the mouse over of the target (evt: MouseEvent<Element, MouseEvent>) => void
- NameplacementDescriptionIt sets the "preferred" position of the tooltip Default"auto""auto-start""auto-end""top""bottom""right""left""top-start""top-end""bottom-start""bottom-end""right-start""right-end""left-start""left-end"auto
- NametargetWrapperClassNameDescriptionClass names to be appended to the className prop of the tooltip’s target string
- NametestIdDescriptionA [data-test-id] attribute used for testing purposes Defaultstringcf-ui-tooltip
- NameusePortalDescriptionBoolean to control whether or not to render the tooltip in a React Portal. Rendering content inside a Portal allows the tooltip to escape the bounds of its parent while still being positioned correctly. Using a Portal is necessary if an ancestor of the tooltip hides overflow. Defaults to `false` Defaultfalsetruefalse