> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/fr/apps/components/inputs/switch.md).

# Interrupteur

Les switchs basculent l'état d'un paramètre unique entre activé et désactivé.

Les switchs sont la méthode privilégiée pour ajuster les paramètres sur mobile. L'option que le switch contrôle, ainsi que l'état dans lequel il se trouve, doivent être clairement indiqués par l'étiquette en ligne correspondante.

## Switch

Créez un switch de base.

![](/files/Y4d9YkQZLf96xJyiYsTI)

```powershell
New-UDSwitch -Checked $true 
New-UDSwitch -Checked $true -Disabled
```

## Événement OnChange

Répondez au changement de valeur d'un switch. La variable `$EventData` indiquera si le switch a été coché ou décoché.

```powershell
New-UDSwitch -OnChange { Show-UDToast -Message $EventData }
```

## Prise en charge de Get-UDElement

Vous pouvez récupérer la valeur du switch depuis un autre composant en utilisant `Get-UDElement`. Utilisez la propriété Checked pour déterminer si le switch est coché ou non.

```powershell
New-UDSwitch -Id 'switch' 
New-UDButton -Text 'Click' -OnClick {
    Show-UDToast -Message (Get-UDElement -Id 'switch').checked
}
```

## API

* [New-UDSwitch](https://github.com/ironmansoftware/universal-docs/blob/v5/cmdlets/New-UDSwitch.txt)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/fr/apps/components/inputs/switch.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
