Tooltip

Tooltip component is a small pop-up box that appears when a user hovers over an element or clicks on it. It provides additional information about the element or offers a call-to-action.

Examples Default tooltip
<dap-ds-tooltip>
  <dap-ds-button slot="trigger">
    Hover me
  </dap-ds-button>
  Tooltip content
</dap-ds-tooltip>
Position
<div style={{ display: 'flex', minHeight: 200, justifyContent: 'center', alignItems: 'center' }}>
  <dap-ds-stack direction="row">
    <dap-ds-tooltip placement="top">
      <dap-ds-button slot="trigger">
        Top
      </dap-ds-button>
      Tooltip content
    </dap-ds-tooltip>
    <dap-ds-tooltip placement="right">
      <dap-ds-button slot="trigger">
        Right
      </dap-ds-button>
      Tooltip content
    </dap-ds-tooltip>
    <dap-ds-tooltip placement="bottom">
      <dap-ds-button slot="trigger">
        Bottom
      </dap-ds-button>
      Tooltip content
    </dap-ds-tooltip>
    <dap-ds-tooltip placement="left">
      <dap-ds-button slot="trigger">
        Left
      </dap-ds-button>
      Tooltip content
    </dap-ds-tooltip>
  </dap-ds-stack>
</div>
Trigger
<dap-ds-tooltip id="custom" trigger="click">
  <dap-ds-button slot="trigger">
    Click me
  </dap-ds-button>
  Tooltip content
</dap-ds-tooltip>
Importing
import { DapDSTooltip } from 'dap-design-system'
Importing React
import { DapDSTooltipReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSTooltip } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
contentstringThe content of the tooltip, supporting text only.
placement'top', 'right' , 'bottom' , 'left''bottom'The position of the tooltip around the trigger element.
openedbooleanfalseSets the tooltip to opened by default (will still be closed on closing events).
mode'tooltip', 'toggle''tooltip'Sets the tooltip to toggle mode.
noArrowbooleanfalseHides the arrow of the tooltip.
floatingStrategy'absolute', 'fixed''absolute'The floating strategy of the tooltip. Default is absolute. Can be absolute or fixed.
triggerSets custom trigger event (hover, focus, click). Default is hover focus.
Slots
NameDescription
(default)The content of the tooltip.
triggerThe trigger element of the tooltip.
Events

No custom events available.

CSS Parts
Part NameDescription
baseThe main tooltip container.
triggerThe trigger element of the tooltip.
popupThe popup of the tooltip.
arrowThe arrow of the tooltip.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-tooltip::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-tooltip::part(base),
.my-custom-dap-ds-tooltip::part(trigger) {
  /* Shared styles */
}

Example usage:

<dap-ds-tooltip class="my-custom-dap-ds-tooltip">
  Tooltip
</dap-ds-tooltip>
.my-custom-dap-ds-tooltip::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-tooltip-max-widthThe maximum width of the tooltip before its content will wrap (default: 14rem)
--dds-tooltip-paddingThe padding inside the tooltip (default: var(--dds-spacing-400))
--dds-tooltip-border-colorThe border color of the tooltip (default: var(--dds-border-neutral-subtle))
--dds-tooltip-bg-colorThe background color of the tooltip (default: var(--dds-background-neutral-base))
--dds-tooltip-text-colorThe text color of the tooltip (default: var(--dds-text-neutral-base))
--dds-tooltip-font-sizeThe font size of the tooltip text (default: var(--dds-font-sm))
--dds-tooltip-box-shadowThe box shadow of the tooltip (default: 0 8px 12px -2px rgb(0 0 0 / 8%), 0 2px 6px -2px rgb(0 0 0 / 6%))
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-tooltip
  style="--dds-tooltip-max-width: value; --dds-tooltip-padding: value;">
  Tooltip
</dap-ds-tooltip>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-tooltip {
  --dds-tooltip-max-width: value;
  --dds-tooltip-padding: value;
  --dds-tooltip-border-color: value;
}
<dap-ds-tooltip class="my-custom-dap-ds-tooltip">
  Tooltip
</dap-ds-tooltip>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-tooltip {
  --dds-tooltip-max-width: value;
  --dds-tooltip-padding: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.