# ThemeVariant

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/styling/struct-themevariant/

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

```rust
struct ThemeVariant
```

Specifies a UI theme variant that should be used for the control and
application types.

Theme variants are compared by their key.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L21)

## Members

- [`new`](#function-new)
- [`default`](#function-default)
- [`light`](#function-light)
- [`dark`](#function-dark)
- [`actual_theme_variant_property`](#function-actual_theme_variant_property)
- [`requested_theme_variant_property`](#function-requested_theme_variant_property)
- [`key`](#function-key)
- [`inherit_variant`](#function-inherit_variant)
- [`update_actual_theme_variant`](#function-update_actual_theme_variant)
- [`register_theme_variant_root_type`](#function-register_theme_variant_root_type)
- [`to_platform_theme_variant`](#function-to_platform_theme_variant)

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

### new

```rust
fn new(key: impl Into<ResourceKey>, inherit_variant: Option<ThemeVariant>) -> Self
```

Creates a theme variant.

`key` is the key of the custom theme variant. `inherit_variant` is the
variant that this variant inherits from: if set, a resource that is
missing from the theme dictionary of the current variant is looked up
in the dictionary of the inherited one. Inheriting the default variant
is not supported.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L43)

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

### default

```rust
fn default() -> ThemeVariant
```

Use the default theme variant: inherit the variant from the parent,
and at the root use the variant of the platform.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L57)

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

### light

```rust
fn light() -> ThemeVariant
```

Use the Light theme variant.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L62)

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

### dark

```rust
fn dark() -> ThemeVariant
```

Use the Dark theme variant.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L67)

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

### actual_theme_variant_property

```rust
fn actual_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
```

Defines the ActualThemeVariant property: the theme variant in
effect for an element, inherited down the tree. It is `None`
until a root or an element with a requested variant sets it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L71)

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

### requested_theme_variant_property

```rust
fn requested_theme_variant_property() -> &'static StyledProperty<Option<ThemeVariant>>
```

Defines the RequestedThemeVariant property: the theme variant
requested for an element and its descendants.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L83)

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

### key

```rust
fn key(self: &Self) -> &ResourceKey
```

Key of the theme variant by which variants are compared.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L97)

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

### inherit_variant

```rust
fn inherit_variant(self: &Self) -> Option<ThemeVariant>
```

The theme variant that this variant inherits from.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L102)

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

### update_actual_theme_variant

```rust
fn update_actual_theme_variant(target: &FerroObject)
```

Updates the actual theme variant of `target` from its requested
theme variant: a requested variant other than the default becomes the
actual one, otherwise the actual variant is inherited.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L109)

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

### register_theme_variant_root_type

```rust
fn register_theme_variant_root_type(type_: &'static TypeInfo)
```

Declares that the objects of a class that is not a styled element
(the application class) are roots of theme variant resolution.
Styled elements say so through the `is_theme_variant_root` virtual.
(Upstream: the `IThemeVariantRoot` interface.)

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L130)

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

### to_platform_theme_variant

```rust
fn to_platform_theme_variant(theme_variant: Option<&ThemeVariant>) -> Option<PlatformThemeVariant>
```

The platform theme variant of a theme variant (the original's
explicit conversion to a nullable platform theme variant): the light
and the dark variant convert to their counterparts, another variant
converts as the variant it inherits from, and a variant that inherits
from neither, or no variant, converts to nothing.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/styling/theme_variant.rs#L154)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceKeyObject`](/docs/0.5.0/api/ferroui-base/controls/trait-resourcekeyobject/)
- [`PropertyValue`](/docs/0.5.0/api/ferroui-base/trait-propertyvalue/)
- [`AnyValue`](/docs/0.5.0/api/ferroui-base/trait-anyvalue/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `CloneToUninit`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- `Any`
- `ToOwned`
- `ToString`
- `ErasedDestructor`
- `IntoEither`
- `Clone`
- `From<PlatformThemeVariant>`
- `Default`
- `PartialEq`
- `Eq`
- `Hash`
- `Display`
- `Debug`
- `FromStr`
- [`MarkupTyped`](/docs/0.5.0/api/ferroui-base/metadata/trait-markuptyped/)
- [`ValueTypeRegistration`](/docs/0.5.0/api/ferroui-base/data/core/trait-valuetyperegistration/)

## Availability

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