Coachmark
A guided-tour step that spotlights an element already on the page.
Workspace settings
Members
3 of 10 seats used
Usage this month
Resets May 1Usage guidelines
- Use
Coachmarkto walk users through controls that already exist on the page. UsePopoverfor explanatory content anchored to a trigger, andDialogfor a task that does not point at a page element. - The caller owns the tour. Control
open, pass the currenttargetas an element or a selector that matches one element, and advance the step in your own state. Coachmark has no Trigger: a tour starts from product logic or from a button that sets the step. - Pass the step data as
payloadand read it from the render-function child. While the next target mounts, scrolls or animates, Coachmark keeps the previous payload in place and marks the popupdata-pendingandaria-busy; it also keeps the last payload through the close transition. Passpayload={undefined}when closed or when the next step is not ready, instead of a fallback value or unmountingCoachmark. onOpenChangereports only the close part andEscape. Clicking the dimmed page never dismisses a coachmark, so every step needs aCoachmarkClose, which also keeps focus trapped in the popup with the defaultmodal.onStepShownruns each time a step becomes visible, including when the tour returns after stepping aside for another modal. Use it for step analytics or for marking a tour as seen.- Name the popup with
CoachmarkTitle. PutCoachmarkStepLabelinside the title so the progress is part of the dialog's name, and keep the copy inCoachmarkDescription. - Point
initialFocusat the primary action on walkthrough steps. Leave it out on a step the user completes on the target, so the popup takes focus and its copy is read before the user tabs to the target. When focus stays on the same action across steps, Coachmark announces the new copy through a polite live region. CoachmarkPositioneraccepts logical sides only:top,bottom,inline-startandinline-end. The spotlight, the page blocker and the popup are fixed to the viewport, so they follow a target inside a scroll container; when the target scrolls away, the popup stays reachable so the close action remains available.- When another modal covers the coachmark, it steps aside and comes back once its target is reachable again.
Anatomy
CoachmarkSpotlight dims the page around the target. CoachmarkPositioner also renders the layer that blocks the rest of the page, so the page stays blocked without a spotlight.
Examples
Letting the user act on the target
With modal="allow-target", the user completes the step on the target itself. The rest of the page stays blocked for pointer, keyboard and assistive technology, and Tab moves between the popup and the target. Close the coachmark from the target's own change handler.
Customer support bot
DraftOnly workspace members can chat.
Highlighting related elements
highlightSelectors widens the spotlight to cover related elements next to the target. The extra elements stay inert while lit; descendants of the target stay interactive. This example also passes the target as a selector.
Workflow
- StartSucceeded0.01 s
- Knowledge retrievalSucceeded0.42 s
- LLMSucceeded1.87 s
Last edited 2 minutes ago
Keyboard
| Key | Action |
|---|---|
| TaborShift+Tab | Moves focus between the popup's controls. With modal="allow-target", focus moves between popup and target. |
| Escape | Calls onOpenChange with the escape-key reason. The coachmark stays open until the owner closes it. |
API reference
Coachmark
Groups all parts of a guided-tour overlay that spotlights page elements and tracks step payloads across transitions. Doesn't render its own HTML element.
| Prop | Type | Default | Details |
|---|---|---|---|
open required | boolean | No default | |
onOpenChange | ((open: boolean, eventDetails: CoachmarkChangeEventDetails) => void) | No default | |
target required | CoachmarkTarget | No default | |
highlightSelectors | string[] | No default | |
modal | 'allow-target' | true | true | |
payload | Payload | No default | |
onStepShown | ((payload: Payload) => void) | (() => void) | No default | |
children | ((state: { payload: Payload; }) => React.ReactNode) | React.ReactNode | No default | |
Valid prop combinations:
payload: Payload | undefined,onStepShown?: ((payload: Payload) => void),children?: ((state: { payload: Payload; }) => React.ReactNode) | React.ReactNodepayload?: undefined,onStepShown?: (() => void),children?: React.ReactNode
CoachmarkActions
Accepts the props of the element it renders.
CoachmarkArrow
Displays an element positioned against the popover anchor. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverArrowState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverArrowState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverArrowState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-uncentered | Present when the popover arrow is uncentered. |
CoachmarkClose
A button that closes the popover. Renders a <button> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverCloseState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverCloseState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverCloseState) => React.CSSProperties | undefined) | No default | |
nativeButton | boolean | true | |
CoachmarkDescription
A paragraph with additional information about the popover. Renders a <p> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverDescriptionState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverDescriptionState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverDescriptionState) => React.CSSProperties | undefined) | No default | |
CoachmarkPopup
A container for the popover contents. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverPopupState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPopupState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPopupState) => React.CSSProperties | undefined) | No default | |
initialFocus | boolean | React.RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
finalFocus | boolean | React.RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null) | No default | |
| Attribute | Description |
|---|---|
data-pending | Present while the next step waits for its target; the previous step stays in place. |
data-gliding | Present while the coachmark moves from the previous target to a new one. |
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
data-instant | Values: Present if animations should be instant. |
| Variable | Description |
|---|---|
--popup-width | The width of the popup. |
--popup-height | The height of the popup. |
CoachmarkPortal
A portal element that moves the popup to a different part of the DOM. By default, the portal element is appended to <body>. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
keepMounted | boolean | false | |
container | HTMLElement | React.RefObject<HTMLElement | ShadowRoot | null> | ShadowRoot | null | No default | |
className | string | ((state: PopoverPortalState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPortalState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPortalState) => React.CSSProperties | undefined) | No default | |
CoachmarkPositioner
Positions the popover against the trigger. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
sideOffset | number | OffsetFunction | 25 | |
arrowPadding | number | 16 | |
collisionPadding | Padding | 8 | |
collisionAvoidance | CollisionAvoidance | { side: 'flip', align: 'shift', fallbackAxisSide: 'none' } | |
sticky | boolean | true | |
side | 'bottom' | 'inline-end' | 'inline-start' | 'top' | 'bottom' | |
className | string | ((state: PopoverPositionerState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverPositionerState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverPositionerState) => React.CSSProperties | undefined) | No default | |
collisionBoundary | Boundary | 'clipping-ancestors' | |
disableAnchorTracking | boolean | false | |
| Attribute | Description |
|---|---|
data-pending | Present while the next step waits for its target; the previous step stays in place. |
data-gliding | Present while the coachmark moves from the previous target to a new one. |
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-anchor-hidden | Present when the anchor is hidden. |
data-side | Values: Indicates which side the popup is positioned relative to the trigger. |
data-align | Values: Indicates how the popup is aligned relative to specified side. |
| Variable | Description |
|---|---|
--available-width | Values: The available width between the trigger and the edge of the viewport. |
--available-height | Values: The available height between the trigger and the edge of the viewport. |
--anchor-width | Values: The anchor's width. |
--anchor-height | Values: The anchor's height. |
--transform-origin | Values: The coordinates that this element is anchored to. Used for animations and transitions. |
--positioner-width | Values: The width of the popover's positioner. It is important to set |
--positioner-height | Values: The height of the popover's positioner. It is important to set |
CoachmarkSpotlight
An overlay displayed beneath the popover. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverBackdropState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverBackdropState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverBackdropState) => React.CSSProperties | undefined) | No default | |
| Attribute | Description |
|---|---|
data-pending | Present while the next step waits for its target; the previous step stays in place. |
data-gliding | Present while the coachmark moves from the previous target to a new one. |
data-open | Present when the popup is open. |
data-closed | Present when the popup is closed. |
data-starting-style | Present when the popup begins animating in. |
data-ending-style | Present when the popup is animating out. |
CoachmarkStepLabel
Accepts the props of the element it renders.
CoachmarkTitle
A heading that labels the popover. Renders an <h2> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: PopoverTitleState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, PopoverTitleState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: PopoverTitleState) => React.CSSProperties | undefined) | No default | |