0.2.0

The placement field on each step controls where the tooltip appears relative to its target element. Borda uses a 3×3 grid system with 9 named positions.

Values

PlacementPosition
TOP_STARTAbove the target, aligned to its left edge
TOP_CENTERAbove the target, centered
TOP_ENDAbove the target, aligned to its right edge
MIDDLE_STARTLeft of the target, vertically centered
MIDDLE_CENTERCentered on the target
MIDDLE_ENDRight of the target, vertically centered
BOTTOM_STARTBelow the target, aligned to its left edge
BOTTOM_CENTERBelow the target, centered
BOTTOM_ENDBelow the target, aligned to its right edge
import { ComponentPlacement } from '@retoo/borda';

await borda.mount({
  steps: [
    {
      target: '#sidebar',
      title: 'Navigation',
      description: 'Browse sections here.',
      placement: ComponentPlacement.MIDDLE_END,
    },
    {
      target: '#header',
      title: 'Header',
      description: 'Sits below the target, aligned left.',
      placement: ComponentPlacement.BOTTOM_START,
    },
    {
      target: '#hero-banner',
      title: 'Hero',
      description: 'Centered directly on top of the target.',
      placement: ComponentPlacement.MIDDLE_CENTER,
    },
  ],
});

Auto-placement

When the requested placement doesn't fit in the viewport, Borda can automatically flip the tooltip to a fallback position. This is enabled by default. The default fallback chain tries the mirrored side first, then centered variants, then the opposite-alignment sides, and finally the perpendicular (middle-*) sides.

The tooltip never overlaps its target. If no candidate placement fits the viewport, Borda shifts the least-overflowing one to whichever non-overlapping side has room — even if that means the tooltip ends up partially outside the viewport.

Configure the fallback chain through the tooltip's autoPlacement option:

await borda.mount({
  steps: [
    {
      target: '#element',
      title: 'Title',
      description: 'Description',
      placement: ComponentPlacement.TOP_CENTER,
    },
  ],
  tourTooltip: {
    autoPlacement: {
      fallback: [
        ComponentPlacement.BOTTOM_CENTER,
        ComponentPlacement.MIDDLE_END,
      ],
    },
  },
});

The first placement from the fallback list that fits in the viewport wins. If none fit, Borda falls back to whichever candidate overflows the least, then shifts it to stay attached to the target without ever overlapping it.

Disable auto-placement to use the requested position as-is:

tourTooltip: {
  autoPlacement: false,
}