.astral files are HEEx-first static templates. They can be used as pages, layouts, and local components.
Components
Place local components under the configured component directory, components/ by default:
<!-- components/pill.astral -->
<span class="pill">
{render_slot(@inner_block)}
</span>Use local components with HEEx syntax:
<.pill>Elixir</.pill>Pages
.astral pages live in pages/:
---
assigns = assign(assigns, :title, "Home")
---
<h1>{@title}</h1>
<.pill>Static HTML</.pill>The setup block is Elixir. It receives assigns and should return updated assigns when adding values.
Layouts
.astral layouts receive the same assigns as EEx layouts:
<!doctype html>
<html lang="en">
<body>
<main data-route={@route}>{@content}</main>
</body>
</html>HEEx syntax
Use Phoenix HEEx conventions:
<h1>{@title}</h1>
<ul>
<li :for={item <- @items}>{item}</li>
</ul>
<p :if={@draft}>Draft</p>Slots use HEEx slot rendering:
<div class="card">
{render_slot(@inner_block)}
</div>Browser assets
<style> and <script> blocks are extracted into Volt's asset graph:
<style>
.hero { padding: 4rem; }
</style>
<script lang="ts">
document.querySelector(".hero")?.classList.add("ready");
</script>Astral removes those blocks from the server-rendered HTML template. Volt builds and serves them as first-class browser modules.