Skip to main content

Tooltip: React

A tooltip is a floating label that provide a brief explanation about a specific user interface element. It can be triggered when users hover or focus.

Installation

Before you can start using the @mediahuis/chameleon-react component, you’ll need to install it, for more information check: Getting started for developers.

With that done, you’re now ready to implement the component in your application.

import { Tooltip } from '@mediahuis/chameleon-react';

export default function Example() {
return <Tooltip>Example</Tooltip>;
}

Properties

PropertyTypeDefaultRequiredDescription
childrenReactNode-NoThe trigger target of the tooltip.
defaultVisibleBoolean-NoThe initial visibility state of the tooltip.
idString-YesNative HTML id attribute. Also affects describedby-id for accessibility reasons.
labelString-NoText displayed within the tooltip.
placementPlacement'top'NoWhere the Tooltip is positioned towards the target element.
usePortalBoolean-NoWhether to use React.createPortal for creating tooltip. A portal in React allows rendering a component's content into a different part of the HTML document, outside its normal parent component hierarchy. It enables rendering components at any point in the DOM tree, even outside the root element of the React application.
tooltipTriggerTriggerType | Unknown | Unknown-NoWhich event or events trigger the tooltip.