---
description: ╱🚧 under construction
---

# state value

[SwiftUI](../..) ⟩ [view](..) ⟩ [state]() ⟩ value

{% hint style="success" %}
The [state](../../../master/term/state) of a [view](..), use [@State](value/state) to <mark style="color:yellow;">declare</mark> and <mark style="color:yellow;">initialize</mark> a <mark style="color:purple;">state value</mark> of a [view](..). Also called a <mark style="color:purple;">state property</mark>.
{% endhint %}

```swift
struct ContentView: View {

    // ⭐️ declare & initialize a state value
    @State var isOn = true
    
    // UI
    var body: some View { ... }
    
}
```

* [SwiftUI](../..) <mark style="color:yellow;">updates</mark> your views' appearances <mark style="color:yellow;">automatically</mark> whenever your app's <mark style="color:yellow;">state changes</mark>.&#x20;
* One common way to <mark style="color:yellow;">change view states</mark> is through [user interaction](../../../master/term/user-interaction), such as when a person taps a [Button](../../control/button).

{% tabs %}
{% tab title="👥 相關" %}
- [state](value/state "mention")：<mark style="color:yellow;">declare</mark> and <mark style="color:yellow;">initialize</mark> a <mark style="color:purple;">state value</mark>&#x20;
- [object](object "mention")
{% endtab %}
{% endtabs %}
