## Set the view on the embedded form

`checkoutForm.setView(viewIndex: number)`

Programmatically sets the active view on the embedded form. This method is only available when `options[layout]` is `'compact'`.
The compact layout is in private preview. [Request access](https://docs.stripe.com/checkout/form/quickstart.md#request-access-to-the-compact-layout).

The `viewIndex` parameter is a positive integer that corresponds to an index from the `views` array provided on the embedded form's [change event](https://docs.stripe.com/js/custom_checkout/element_events/on_change.md?type=checkoutForm). You can only set a view where `enabled` is `true`.

- `viewIndex`
  A positive integer index corresponding to an entry in the `views` array provided on the embedded form's [change event](https://docs.stripe.com/js/custom_checkout/element_events/on_change.md?type=checkoutForm). The view at the specified index must have `enabled: true`.

### Example

```title
Set the view on the embedded form
```
