Skip to main content

Switch

Use the Switch to let users toggle a setting between on and off. The change takes effect immediately without requiring a separate confirmation step.

Import

import { Switch } from '@dynatrace/strato-components/forms';

Demo

Control state

The Switch can also be controlled, meaning that you can handle the state. To do so, you need to use the onChange prop to provide a handler that is called when the internal state of the Switch changes. You also need to assign the value from the state to the Switch by setting the on prop.

Validate

For validation patterns including custom hints and errors, see show custom hints and errors in the FormField documentation.

Still have questions?
Find answers in the Dynatrace Community