# ToggleSwitch

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-controls/struct-toggleswitch/

**struct** · [`ferroui-controls`](/docs/0.5.0/api/ferroui-controls/) · v0.5.0

```rust
struct ToggleSwitch
```

A toggle switch control.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L24)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`off_content_property`](#function-off_content_property)
- [`off_content_template_property`](#function-off_content_template_property)
- [`on_content_property`](#function-on_content_property)
- [`on_content_template_property`](#function-on_content_template_property)
- [`knob_transitions_property`](#function-knob_transitions_property)
- [`construct`](#function-construct)
- [`new`](#function-new)
- [`on_content`](#function-on_content)
- [`set_on_content`](#function-set_on_content)
- [`off_content`](#function-off_content)
- [`set_off_content`](#function-set_off_content)
- [`off_content_presenter`](#function-off_content_presenter)
- [`on_content_presenter`](#function-on_content_presenter)
- [`off_content_template`](#function-off_content_template)
- [`set_off_content_template`](#function-set_off_content_template)
- [`on_content_template`](#function-on_content_template)
- [`set_on_content_template`](#function-set_on_content_template)
- [`knob_transitions`](#function-knob_transitions)
- [`set_knob_transitions`](#function-set_knob_transitions)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L36)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<ToggleSwitch>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L36)

<a id="function-off_content_property"></a>

### off_content_property

```rust
fn off_content_property() -> &'static StyledProperty<Option<BoxedValue>>
```

Defines the `OffContent` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L125)

<a id="function-off_content_template_property"></a>

### off_content_template_property

```rust
fn off_content_template_property() -> &'static StyledProperty<Option<Rc<dyn IDataTemplate>>>
```

Defines the `OffContentTemplate` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L125)

<a id="function-on_content_property"></a>

### on_content_property

```rust
fn on_content_property() -> &'static StyledProperty<Option<BoxedValue>>
```

Defines the `OnContent` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L125)

<a id="function-on_content_template_property"></a>

### on_content_template_property

```rust
fn on_content_template_property() -> &'static StyledProperty<Option<Rc<dyn IDataTemplate>>>
```

Defines the `OnContentTemplate` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L125)

<a id="function-knob_transitions_property"></a>

### knob_transitions_property

```rust
fn knob_transitions_property() -> &'static StyledProperty<Option<Transitions>>
```

Defines the `KnobTransitions` property.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L125)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `ferroui_base::FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L177)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L191)

<a id="function-on_content"></a>

### on_content

```rust
fn on_content(self: &Self) -> Option<BoxedValue>
```

The content that is displayed when in the on state.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L196)

<a id="function-set_on_content"></a>

### set_on_content

```rust
fn set_on_content(self: &Self, value: Option<BoxedValue>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L200)

<a id="function-off_content"></a>

### off_content

```rust
fn off_content(self: &Self) -> Option<BoxedValue>
```

The content that is displayed when in the off state.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L205)

<a id="function-set_off_content"></a>

### set_off_content

```rust
fn set_off_content(self: &Self, value: Option<BoxedValue>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L209)

<a id="function-off_content_presenter"></a>

### off_content_presenter

```rust
fn off_content_presenter(self: &Self) -> Option<Ref<ContentPresenter>>
```

The presenter of the off content from the control's template.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L214)

<a id="function-on_content_presenter"></a>

### on_content_presenter

```rust
fn on_content_presenter(self: &Self) -> Option<Ref<ContentPresenter>>
```

The presenter of the on content from the control's template.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L219)

<a id="function-off_content_template"></a>

### off_content_template

```rust
fn off_content_template(self: &Self) -> Option<Rc<dyn IDataTemplate>>
```

The data template used to display the off content.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L224)

<a id="function-set_off_content_template"></a>

### set_off_content_template

```rust
fn set_off_content_template(self: &Self, value: Option<Rc<dyn IDataTemplate>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L228)

<a id="function-on_content_template"></a>

### on_content_template

```rust
fn on_content_template(self: &Self) -> Option<Rc<dyn IDataTemplate>>
```

The data template used to display the on content.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L233)

<a id="function-set_on_content_template"></a>

### set_on_content_template

```rust
fn set_on_content_template(self: &Self, value: Option<Rc<dyn IDataTemplate>>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L237)

<a id="function-knob_transitions"></a>

### knob_transitions

```rust
fn knob_transitions(self: &Self) -> Option<Transitions>
```

The transitions of the switching knob.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L242)

<a id="function-set_knob_transitions"></a>

### set_knob_transitions

```rust
fn set_knob_transitions(self: &Self, value: Option<Transitions>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Controls/toggle_switch.rs#L246)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`TemplatedControlImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimplext/)
- [`ToggleButtonImplExt`](/docs/0.5.0/api/ferroui-controls/primitives/trait-togglebuttonimplext/)
- [`ContentControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimplext/)
- [`ControlImplExt`](/docs/0.5.0/api/ferroui-controls/trait-controlimplext/)
- [`ButtonImplExt`](/docs/0.5.0/api/ferroui-controls/trait-buttonimplext/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- [`InputElementImplExt`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimplext/)
- [`InteractiveImplExt`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimplext/)
- [`LayoutableImplExt`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`StyledElementImplExt`](/docs/0.5.0/api/ferroui-base/trait-styledelementimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- [`VisualImplExt`](/docs/0.5.0/api/ferroui-base/trait-visualimplext/)
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ToggleSwitch>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`StyledElementImpl`](/docs/0.5.0/api/ferroui-base/trait-styledelementimpl/)
- [`VisualImpl`](/docs/0.5.0/api/ferroui-base/trait-visualimpl/)
- [`LayoutableImpl`](/docs/0.5.0/api/ferroui-base/layout/trait-layoutableimpl/)
- [`InteractiveImpl`](/docs/0.5.0/api/ferroui-base/interactivity/trait-interactiveimpl/)
- [`InputElementImpl`](/docs/0.5.0/api/ferroui-base/input/trait-inputelementimpl/)
- [`ButtonImpl`](/docs/0.5.0/api/ferroui-controls/trait-buttonimpl/)
- [`ToggleButtonImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-togglebuttonimpl/)
- [`ControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-controlimpl/)
- [`TemplatedControlImpl`](/docs/0.5.0/api/ferroui-controls/primitives/trait-templatedcontrolimpl/)
- [`ContentControlImpl`](/docs/0.5.0/api/ferroui-controls/trait-contentcontrolimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
