> For the complete documentation index, see [llms.txt](https://docs.sacruda.nl/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sacruda.nl/developers/windows/window-states.md).

# Window states

A Sacruda window has several different *states*, these are modes the window can apply to represent it in different ways. These states are available:

* Minimized — Is this window hidden (minimized)?
* Maximized — Is this window maximized?
* Resizable  — Can the user resize the window?
* Headless — Does the window have no titlebar?
* Fullscreen — Is the window fullscreen?

If you recall, these states are also documented [here](https://docs.sacruda.nl/developers/getting-started/creating-your-project.md#scaffold-arcos-app) (point 6) because you're asked about window states in the CLI's app creation wizard. The states have default values that you can set by modifying properties of the `state` object in your `_app.tpa` file.

### Alright, how do I change them programmatically?

You can't change the Resizable and Headless states dynamically, these will have to be decided upon before your app starts. Other than that, the methods for changing states are part of the App Renderer, so you'll have to manually invoke them from there. The snippets below are from inside your app's main process, here they are:

#### Toggle the maximized state

```typescript
stack.renderer?.toggleMaximize(this.pid);
```

#### Toggle the minimized state

```typescript
stack.renderer?.toggleMinimize(this.pid);
```

#### Toggle the fullscreen state

```typescript
stack.renderer?.toggleFullscreen(this.pid);
```

### Window snapping

An Sacruda window can also be *snapped* to different corners or sides of the screen: `top`, `bottom`, `left`, `right`, `top-left`, `top-right`, `bottom-left`, `bottom-right`. These can be set programmatically too by calling `AppRenderer.snapWindow`:

```javascript
stack.renderer?.snapWindow(this.pid, "top-left");
```

The first argument is the PID, and the second is the *variant*, which is one of the 8 options I listed earlier.
