Skip to main content

Props

Props are values passed from a parent component (or the framework bootstrap) into a child component.

Passing props

From parent template

<Card title="Hello" count="42" active="true" />

From spa.config.json

{
"initial_props": { "user": "admin", "debug": false }
}

Receiving props on the server

context(props) receives a plain Python dict:

def context(self, props):
title = props.get("title", "Default Title")
return {"title": title}

Then use it in the template:

<template>
<h1>{{ title }}</h1>
</template>

Declaring props on the client

List expected props with defaults inside client():

def client(self):
return {
"props": {
"title": "Default Title",
"count": 0,
"active": False,
}
}

The framework coerces incoming string attributes to the correct type:

  • int / floatNumber(...)
  • boolBoolean(...)
  • str → stays as-is

Using props in templates

<template>
<p>{{ props.title }}</p>
<p l-if="props.active">Active!</p>
</template>

Props vs State

PropsState
SourceParent / configclient() declaration
MutabilityRead-onlyMutable via actions
ScopeServer + clientClient only
Syntaxprops.xstate.x