Skip to main content
useMindWidget().widget, or the object returned from createMindWidget, implements the MindWidget interface. These are the imperative methods you call to drive the widget. The playground wires them to buttons:
const {widget} = useMindWidget();

widget.transitionTo('engage');      // open the engage panel
widget.transitionTo('idle');        // close it
widget.toggle();                    // toggle DOM visibility
widget.updateContext({pageType});   // update the learning context
widget.showNudge(nudge);            // surface a nudge
widget.dismissNudge();              // dismiss the current nudge

Methods

MethodDescription
mount(container)Mount the UI into an element or selector. MindWidgetHost calls this for you.
unmount()Detach from the DOM without clearing state.
destroy()Unmount, reset state and context, and remove all listeners.
getState()Current WidgetState.
transitionTo(state, context?)Move to a new state. Throws on invalid transitions.
updateContext(partial)Merge into the learning context. The first call requires a pageType.
getContext()Current LearningContext or undefined.
triggerAction(action)Run a quick action (async). Transitions to engage from idle or nudge.
showNudge(nudge)Set and display a nudge. Transitions to nudge.
dismissNudge()Dismiss the active nudge. Transitions back to idle.
show() / hide() / toggle()Control DOM visibility. Only effective once mounted.
on(event, handler)Subscribe to an event.
off(event, handler)Unsubscribe.
emit(event, ...args)Emit a custom event.
show, hide, and toggle only take effect while the widget is mounted to a container. mount() throws an InitializationError if the widget is already mounted or the target selector cannot be found.