Skip to content

Placement & spotlight

Positioning is computed in C# from a measured rectangle. Pick a target near an edge and a placement that cannot fit, and watch the engine slide the popover along the target rather than jumping it to another side; it only flips when sliding is not enough.

Try it

Set the options, then run a five-step tour over the targets in the panel. The panel scrolls: steps four and five sit outside its visible area, which exercises scroll-into-view and the observers that keep the popover glued to a moving target - scroll the panel while a step is up and the card follows. Every option here can be set globally, per tour or per step; the tour below sets them on the tour.

Live
Top left
Top right
Centre
Low left
Low right

What the options do

OptionEffect
Placement The side and alignment to try first. Auto (the default) picks the side with the most free space, and Center ignores the target and centres the card. Left and Right are physical sides; InlineStart and InlineEnd (with their Top and Bottom alignments) are logical ones that swap in a right-to-left page, and Start and End alignments mirror there too.
PlacementFallbacks An explicit order to try when the preferred placement does not fit. Left unset, the engine derives one.
Offset The gap between the spotlight and the popover, in pixels. Default 12.
ViewportPadding, ArrowSize How close the popover may come to the edge of the visible screen (default 16) and how big its arrow is (default 10). The arrow is clamped to stay within both the target and the popover's straight edge, and hidden when the two no longer overlap.
SpotlightShape Rounded, Rectangle, Circle, or None to dim without a cut-out.
SpotlightPadding Breathing room around the target (default 8). It also grows the rectangle the popover is positioned against, so the gap you see is SpotlightPadding + Offset.
SpotlightRadius The corner radius of a Rounded spotlight (default 10); Circle and Rectangle ignore it.
ShowOverlay, OverlayOpacity Whether the page around the target is dimmed, and how much (a fraction, default 0.55). Turn the overlay off to highlight without dimming: the ring around the target remains. ShowSpotlight = false dims without any cut-out.
Interaction Blocked (the default) swallows every click outside the popover and makes the card a modal dialog; TargetOnly makes the spotlight hole click-through, so only the highlighted control can be used; Free leaves the page entirely usable. Try TargetOnly and click a target, then try clicking the dimmed page.
CloseOnOverlayClick, CloseOnEscape Whether a click on the dimmed page ends the tour (default false; there is nothing to click on a Free step) and whether Escape does (default true - keep it on unless the tour is genuinely mandatory).
Scroll, ScrollPadding How an off-screen target is brought into view - Smooth (the default), Instant, Auto, or None to leave it where it is - and the margin kept around it (default 24). Every scrolling ancestor is scrolled, and a target already comfortably in view is left alone.

Very large and very small targets need nothing special: a target larger than the screen is placed against whichever part of it is visible, and a target partly scrolled out of its pane - try it with the panel above - is spotlit only where the pane shows it. The popover is also kept clear of an on-screen keyboard, pinch zoom and a phone's notch.

new BonboardingTourDefinition   // or a single step, or AddBitBonboardingServices(options => ...) for every tour
{
    Placement = BonboardingPlacement.Bottom,
    PlacementFallbacks = [BonboardingPlacement.Top, BonboardingPlacement.InlineEnd],
    Offset = 12,
    SpotlightShape = BonboardingSpotlightShape.Rounded,
    SpotlightPadding = 8,
    SpotlightRadius = 10,
    ShowOverlay = true,
    OverlayOpacity = 0.55,
    Interaction = BonboardingInteractionMode.Blocked,
    CloseOnOverlayClick = false,
    CloseOnEscape = true,
    Scroll = BonboardingScrollMode.Smooth,
    ScrollPadding = 24,
}

Several elements, one spotlight

AdditionalTargets folds more elements into the same spotlight, and the popover is positioned against their bounding union - the right shape for a group of controls that belong together.

Live
new BonboardingStepDefinition
{
    Target = BonboardingStepTarget.Anchor("editor-save"),
    AdditionalTargets = [BonboardingStepTarget.Anchor("editor-undo"), BonboardingStepTarget.Anchor("editor-redo")],
    Title = "Editing controls",
}

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.

An unhandled error has occurred. Reload 🗙