← how-to

nested component

zsx / basic

program
fun header() -> </> {
  return <h1>hello</h1>;
}

fun main() {
  imu page ::= <div><header /></div>;

  #render page;
}

A component is a function that returns </>. Here header builds an <h1>. The parent markup pulls it in by name: <header /> sits in the page like any tag, and the compiler splices the function’s markup in its place.

The tag name is the function name, fun header becomes <header />. With no children to pass, the tag closes itself.

The splice happens while the program builds, so the page holds the component’s nodes. No wrapper element, no runtime lookup.

A component takes props through its parameters, the same way a function takes arguments. Pass them as attributes on the tag.

reachout

echo -n 'dGhlQGNvbXBpbG9yZHMuaG91c2U=' | base64 --decode

For humans: faq.

For Ai agents: llms.txt (curated index) and llms-full.txt (full docs).

Privacy: No cookies, no ads, no tracking. It's like you were never here.