Interpolation
Bind reactive state directly to your HTML using the powerful @{} syntax.
Text Interpolation
The most basic form of data binding is text interpolation. Use the @{} tag to embed any JavaScript expression that resolves to a string or number.
const MyComponent = () => {
const name = $state('World');
useInsert({ name });
return html`<h1>Hello, @{name.value}!</h1>`;
};
Attribute Binding
Interpolation isn't just for text content; it works seamlessly with HTML attributes. This is commonly used for dynamic classes, IDs, or ARIA labels.
<div class="badge @{isActive.value ? 'bg-green-500' : 'bg-gray-500'}">
Status: @{isActive.value ? 'Active' : 'Inactive'}
</div>
You can also bind to any other standard attribute:
<button id="@{componentId}" disabled="@{isLoading.value}">
Submit
</button>
Expressions & Logic
Inside the @{} tags, you have the full power of JavaScript. You can perform calculations, call functions, or use ternary operators.
<p>The total is: @{items.value.reduce((acc, i) => acc + i.price, 0)}</p>
<p>User level: @{calculateLevel(user.points)}</p>
Unlike Virtual DOM frameworks, PawaJS interpolation is fine-grained.
When count.value changes, the runtime updates only the exact text node or
attribute dependent on that value. The rest of the component and DOM tree remain untouched.
Page Not Found
We couldn't find the page you're looking for. It might have been moved or deleted.
Go back home