# UI State

* ***UI State*** is useful for keeping track of the current view and state of your application.
* To set/update a UI state variable, use the ***set()*** predicate:

```
// SYNTAX
set(var_id, var_value)

// EXAMPLE
prompt :-
  show [
    button('Create Guestbook', [ set(tab, create) ]),
    button('View Guestbook', [ set(tab, view) ]),
    button('Open Guestbook', [ set(tab, open) ])
  ].
```

{% hint style="warning" %}
`var_id` must be in *snake\_case* **OR** *camelCase*.
{% endhint %}

* To get the current value of a UI state variable, use the ***get()*** predicate:

```
// SYNTAX
get(var_id, var_value)

// EXAMPLE
prompt :- get(tab, create), show[text('Create Prompt')].
prompt :- get(tab, view), show[text('View Prompt')].
prompt :- get(tab, open), show[text('Open Prompt')].
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hyperdapp.gitbook.io/code-editor/guides/ui-state.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
