Skip to Content
APIWidget State

Widget State

This page explains which interaction states runtime continuity preserves and why that matters.

If you have not read the internals pages yet, start with:

What continuity preserves today

Runtime continuity currently preserves these RuntimeWidgetState variants:

  • input cursor
  • list selection
  • table selection
  • tabs selection
  • scroll positions

This is what keeps subtree replacement and full rerendering from resetting interaction state back to defaults.

Input

Input continuity preserves the cursor position, not the input string itself.

RuntimeWidgetState::InputCursor(cursor)

The string is still your app state or local signal. Continuity exists so the cursor does not jump back to the beginning after rerender.

ListState

List preserves the selected item:

ListState::default().with_selected(Some(2))

When the user moves selection and a rerender happens, runtime reconnects that interaction state.

TableState

Table has a richer shape than List:

  • selected row
  • optional selected cell
  • visible window state

That is why continuity matters more here: a table can lose both selection and viewport position if the state shape is not preserved.

Tabs

Tabs preserves the runtime-managed selected tab.

If you pass selected(...), that is controlled state. If you do not, runtime keeps the user’s current tab stable across rerenders.

ScrollView / Scrollbar

Scrolling widgets preserve position:

  • ScrollView: offset
  • Scrollbar: position

That is what lets shared scroll state, redraw, and continuity work together.

What this means for new widgets

When you design a new interactive widget, ask:

  1. Does it have local interaction state the user expects to survive rerender?
  2. Should that state survive subtree replacement?

If the answer is yes, it probably belongs in the continuity contract instead of living only in transient node state.

What does not belong here

These usually should not become RuntimeWidgetState:

  • business data
  • network state
  • persistent storage state
  • pure visual styling

Put differently:

  • app state owns “what the data is”
  • continuity owns “where the user currently is”
Last updated on