> 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/applis/components/inputs/switch.md).

# Interrupteur

Ajoutez des interrupteurs à bascule aux applis PowerShell Universal pour activer ou désactiver des paramètres, avec des gestionnaires d'événements de changement et la récupération de valeur via Get-UD

Les interrupteurs activent ou désactivent l'état d'un seul paramètre.

Les interrupteurs sont la façon préférée d'ajuster les paramètres sur mobile. L'option que l'interrupteur contrôle, ainsi que l'état dans lequel il se trouve, devraient être clairement indiqués par l'étiquette en ligne correspondante.

## Interrupteur

Créez un interrupteur de base.

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

## Événement OnChange

Réagissez au changement de la valeur d'un interrupteur. La variable `$EventData` indiquera si l'interrupteur 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 de l'interrupteur dans un autre composant en utilisant `Get-UDElement`. Utilisez la propriété Checked pour déterminer si l'interrupteur 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](/powershell-universal/fr/commandes-powershell/new-udswitch.md)

### Voir aussi

* [Devolutions Academy – Adding user unlock feature](https://academy.devolutions.net/student/activity/3546024-part-4-adding-user-unlock-feature)


---

# 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
