Engineering

The props and binding layer

Nov 2026 · 3 min read

A static page is a tree of elements with fixed props. An application is that same tree, except the props change as the user does things. In Codelab, the props and binding layer is what turns one into the other.

A prop is a literal or an expression

Every prop holds one of two things. A literal holds the value directly: "Hello", 42, true. An expression computes the value from the current context when the page renders:

{{stores.user.name}}
{{props.title}}
{{repeat.item}}
{{hooks.rsvpForm.values.email}}
{{session.user.email}}
{{page.search.eventId}}

Mixed text interpolates too: Hello {{stores.user.name}}.

Because an expression is just a prop value, any prop on any element can read live data: the text of a heading, the disabled state of a button, the src of an image, the open state of a dialog. There's no separate "dynamic" version of a component.

State lives in stores

Props are inputs. State lives in stores. A store declares fields and actions, and is scoped to an app, a page or a component:

  • An app store holds what every page needs, such as the signed-in user or a cart.
  • A page store holds that page's state, such as the active tab or a search query.
  • A component store holds state that belongs to that component, such as whether a panel is expanded.

Elements read store fields through expressions like {{stores.cart.count}}. Actions change them: a set-property action writes a field, and every prop that reads the field updates. That's the loop that makes a page stateful. Events trigger actions, actions update stores, and props read stores.

Bindings wire behavior to props

A binding references a target. An event prop such as onClick binds to a function with its parameters. Those parameters can themselves be expressions, so a click can write the event's value into a store:

onClick: { functionId: "set-property", instanceParams: { value: "{{event}}" } }

Component instances work the same way. A component declares its props, each instance supplies its own values, and expressions inside the component read them as {{props.<name>}}. Two cards built from one component can show different titles because each instance binds its own.

Repeat: one subtree, many items

Lists are where state gets interesting. Repeat maps an array onto copies of a subtree. Mark an element as repeatable, point its source at an array, such as {{stores.products.items}}, and Codelab renders one copy per item. Inside each copy, expressions read:

  • {{repeat.item}} for the current item,
  • {{repeat.index}} for its position,
  • {{repeat.key}} for its identity.

So a product card's heading is {{repeat.item.name}}, its price is {{repeat.item.price}}, and its "Add to cart" button's onClick passes {{repeat.item}} to an action. When the array changes, the list changes with it, because the subtree is bound to the data rather than copied from it.

Next to repeat sits render if. renderIf takes an expression, and a falsy result leaves the element and its children out. Together they cover most of what makes a UI feel alive: show the empty state when the list is empty, otherwise repeat a card per item.

One layer, every library

None of this is specific to one component. Expressions, bindings, repeat and render if work on every element from every library, from an HTML div to a COSS Dialog, because they live in the props layer, not in the components. That's what lets Codelab use real UI libraries with their full props and still build stateful applications on top of them.