<cs-tooltip>
StableFeedbackSince 0.1

Tooltips display brief contextual information when the user hovers, focuses, or taps a target element.

This is a tooltip Hover Me

Point the for attribute at the id of the element the tooltip describes, and Cornerstone wires up positioning and accessibility for you.

Keep tooltips to text and presentational content.
Tooltips can’t be reliably focused or operated with a keyboard, so avoid buttons, links, and form controls inside one. Reach for a popover or dropdown when you need interactive content.

Examples

Placement

Use the placement attribute to set the tooltip’s preferred position. The actual placement may shift to keep the tooltip inside the viewport.

top-start top top-end left-start right-start left right left-end right-end bottom-start bottom bottom-end

Triggers

The trigger attribute controls how a tooltip is activated. Pass multiple values separated by a space to combine them — the default is hover focus, which shows the tooltip on pointer hover and keyboard focus.

ValueShows the tooltip when
hoverThe pointer moves over the target
focusThe target receives keyboard focus
clickThe target is clicked; clicking again dismisses it
manualOnly when you set open yourself — no built-in activation
Click to Toggle Click again to dismiss

HTML in Tooltips

Use the default slot to add presentational HTML, such as emphasis or line breaks.

Hover me
This tooltip includes formatted content, such as emphasis and line breaks.

Customizing

Use the --max-width custom property to set the width at which the tooltip’s content wraps.

This tooltip will wrap after only 80 pixels. Hover me

Remove the arrow on a single tooltip with the without-arrow attribute.

No Arrow This is a tooltip with no arrow

Resize the arrow on every tooltip with the --cs-tooltip-arrow-size design token. Set it in a :root block after the Cornerstone stylesheet loads — 0 removes arrows globally.

:root {
  --cs-tooltip-arrow-size: 0;
}

Showing & Hiding Manually

Set trigger="manual" and toggle the open attribute to control the tooltip yourself — handy for onboarding hints or surfacing a tooltip in response to your own logic.

This is an avatar! Toggle Manually

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/tooltip/tooltip.js';
import './cornerstone/components/tooltip/tooltip.js';
import CsTooltip from '@cruglobal/cornerstone-components/react/tooltip/index.js';

Slots

Learn more about using slots.

NameDescription
(default)The tooltip's default slot where any content should live. Interactive content should be avoided.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
disableddisabledDisables the tooltip so it won't show when triggered.booleanfalseYes
distancedistanceThe distance in pixels from which to offset the tooltip away from its target.number8
hideDelayhide-delayThe amount of time to wait before hiding the tooltip when the user mouses out.number0
openopenIndicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods.booleanfalseYes
placementplacementThe preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip inside of the viewport.'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end''top'
showDelayshow-delayThe amount of time to wait before showing the tooltip when the user mouses in.number150
skiddingskiddingThe distance in pixels from which to offset the tooltip along its target.number0
triggertriggerControls how the tooltip is activated. Possible options include click, hover, focus, and manual. Multiple options can be passed by separating them with a space. When manual is used, the tooltip must be activated programmatically.string'hover focus'
withoutArrowwithout-arrowRemoves the arrow from the tooltip.booleanfalseYes

Methods

Learn more about methods.

NameDescriptionArguments
hide()Hides the tooltip
show()Shows the tooltip.

Events

Learn more about events.

NameDescription
cs-after-hideEmitted after the tooltip has hidden and all animations are complete.
cs-after-showEmitted after the tooltip has shown and all animations are complete.
cs-hideEmitted when the tooltip begins to hide.
cs-showEmitted when the tooltip begins to show.

CSS Custom Properties

Learn more about CSS custom properties.

NameDescriptionDefault
--max-widthThe maximum width of the tooltip before its content will wrap.

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
bodyThe tooltip's body where its content is rendered.::part(body)
tooltipThe component's outer wrapper.::part(tooltip)
tooltip__arrowThe popup's exported arrow part. Use this to target the tooltip's arrow.::part(tooltip__arrow)
tooltip__popupThe popup's exported popup part. Use this to target the tooltip's popup container.::part(tooltip__popup)

Dependencies

This component automatically imports the following elements. Sub-dependencies, if any exist, are included in this list.