> ## Documentation Index
> Fetch the complete documentation index at: https://developer.watson-orchestrate.ibm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# view:change

Triggered after the view state changes. This event enables post-change logic such as analytics, UI updates, or side effects.

## Event properties

**type** `string` *required*

Always `'view:change'`.

**reason** `string` *required*

The reason for the view change.

**oldViewState** `object` *required*

The previous view state.

**oldViewState.launcher** `boolean`

Whether the launcher was visible.

**oldViewState.mainWindow** `boolean`

Whether the main window was visible.

**newViewState** `object` *required*

The new view state.

**newViewState.launcher** `boolean`

Whether the launcher is now visible.

**newViewState.mainWindow** `boolean`

Whether the main window is now visible.

## Example

```javascript theme={null}
instance.on('view:change', (event, instance) => {
    console.log('View changed:', {
        reason: event.reason,
        from: event.oldViewState,
        to: event.newViewState
    });
    
    // Remove transition CSS class
    document.body.classList.remove('chat-view-changing');
    
    // Track analytics
    if (event.newViewState.mainWindow && !event.oldViewState.mainWindow) {
        analytics.track('chat_opened', { reason: event.reason });
    }
    
    // Adjust page layout
    if (event.newViewState.mainWindow) {
        adjustPageLayout('chat-open');
    } else {
        adjustPageLayout('chat-closed');
    }
});
```

> [card] [Do you need practical examples?](https://www.ibm.com/docs/SSAVQO/deploy/web_chat_agent/tutorials/tutorials_lp.html)
>
> Learn how to apply the features available for embedded chat into your implementation with guidance and examples.
