> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/ios/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/ios/swiftui/view/state/value.md).

# state value

[SwiftUI](/ios/swiftui.md) ⟩ [view](/ios/swiftui/view.md) ⟩ [state](/ios/swiftui/view/state.md) ⟩ value

{% hint style="success" %}
The [state](/ios/master/term/state.md) of a [view](/ios/swiftui/view.md), use [@State](/ios/swiftui/view/state/value/state.md) 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](/ios/swiftui/view.md). 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](/ios/swiftui.md) <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](/ios/master/term/user-interaction.md), such as when a person taps a [Button](/ios/swiftui/control/button.md).

{% tabs %}
{% tab title="👥 相關" %}

* [＠State](/ios/swiftui/view/state/value/state.md)：<mark style="color:yellow;">declare</mark> and <mark style="color:yellow;">initialize</mark> a <mark style="color:purple;">state value</mark>&#x20;
* [state object](/ios/swiftui/view/state/object.md)
  {% endtab %}
  {% endtabs %}
