DlTooltip

Annotate with contextual configurable tooltips

The DlTooltip inline component displays contextual information when hovering or focusing an element. It wraps content (or inline text) and shows a tooltip using the Nuxt UI Tooltip component.

Features

  • šŸ’¬ quick, declarative tooltip composition
  • šŸ“ configurable position
  • 🧩 theme-friendly visual adjustments
  • ♿ keyboard support

Usage

Use :dl-tooltip[...] as an inline component with the trigger content as the default slot, and pass the tooltip text as the tooltip prop.

:dl-tooltip[Read more]{tooltip="Showing extra details"}

Result: Read more

With a label

Use label to render trigger instead of slot. It will be ignored if default slot will be defined.

:dl-tooltip{label="Read more" tooltip="Now using label property"}

Result: Read more

With a different position

You can set the tooltip position using the side prop.

:dl-tooltip[Read more]{tooltip="Now on the bottom"" side="bottom"}

Result: Read more

With code as a trigger

DlTooltip can also display code as the trigger. Since the slot parser may escape special characters, use the label prop with Markdown syntax to render code formatting.

:dl-tooltip{label="`readMore`" tooltip="Now with code trigger"}

Result: readMore

Props

Here are the properties you can use with the DlTooltip component. Each property should be set on an individual component instance; they do not affect the global configuration. More about defining properties in MDC components you can read here.

nametypedefaultdescription
labelstringundefined

Inline content to render as the trigger. Ignored when default slot is provided.

tooltipstringundefined

Tooltip text to display.

side

'top'
'bottom'
'left'
'right'

'top'

Position of the tooltip.

lockWidthbooleanfalse

Whether to lock the tooltip width to the trigger width.

iuiRecord<string, string>undefined

Special property dedicated to inline components, can be used to add TW classes for certain component markup elements.

Slots

namedescription
default

Tooltip label to display.

Styling

Styling from Markdown

Every DocLayer component can be styled directly within your Markdown file using dedicated slot/property configuration. This allows you to customize the appearance of the component's markup elements without modifying global styles. More about components styling you can read here.

Below you'll find the default set of Tailwind classes for the component's dedicated markup elements.

<script lang="ts">const ui = defineDoclayerComponentUi({  base: ['z-10', 'shadow-none'],  insert: [    'uc-tooltip-border-color',    'u-border-radius',    'border',    'border-dashed',    'px-[0.25rem]',    'inline-block',    'relative',    'whitespace-nowrap',    'cursor-pointer',  ],  icon: ['u-background-color-secondary', 'absolute', '-top-[0.5rem]', '-right-[0.4rem]', 'inline-block', 'text-sm'],});</script>

CSS Variables

Here is a set of CSS variables you can use to customize the appearance of the DlTooltip component globally. More about theming and styling with CSS variables, you can read here.

@theme {  --app-tooltip-border-color: light-dark(var(--color-gray-300), var(--color-gray-700));}

CSS Utilities

Below are the CSS utility classes used by the DlTooltip component. They make use of the CSS variables described above and define the default styling for the component's markup elements.

@utility uc-tooltip-border-color {  border-color: var(--app-tooltip-border-color);}/* Class used to control tooltip while `lockWidth` property is set */@utility uc-tooltip-appearance {  @apply min-w-[20rem] max-w-[20rem] h-auto whitespace-normal;  span {    @apply u-space-p/2 whitespace-normal leading-[1.7rem];    /* helps prevent unwanted width shrinking */    text-overflow: unset !important;  }  ul,  li {    @apply mt-0 pt-0;  }}