Packages
corex
0.1.1
0.1.2
0.1.1
0.1.0
0.1.0-rc.1
0.1.0-rc.0
0.1.0-beta.5
0.1.0-beta.4
0.1.0-beta.3
0.1.0-beta.2
0.1.0-beta.1
0.1.0-alpha.33
0.1.0-alpha.32
0.1.0-alpha.31
0.1.0-alpha.30
0.1.0-alpha.29
0.1.0-alpha.28
0.1.0-alpha.27
0.1.0-alpha.26
0.1.0-alpha.25
0.1.0-alpha.24
0.1.0-alpha.23
0.1.0-alpha.22
0.1.0-alpha.21
0.1.0-alpha.20
0.1.0-alpha.19
0.1.0-alpha.18
0.1.0-alpha.17
0.1.0-alpha.16
0.1.0-alpha.15
0.1.0-alpha.14
0.1.0-alpha.13
0.1.0-alpha.12
0.1.0-alpha.11
0.1.0-alpha.10
0.1.0-alpha.9
0.1.0-alpha.8
0.1.0-alpha.7
0.1.0-alpha.6
0.1.0-alpha.5
0.1.0-alpha.4
0.1.0-alpha.3
0.1.0-alpha.2
0.1.0-alpha.1
Accessible and unstyled UI components library written in Elixir and TypeScript that integrates Zag.js state machines into the Phoenix Framework.
Current section
Files
Jump to
Current section
Files
usage-rules/api.md
# Corex component API
Imperative **push** API — socket helpers and JS commands. For **subscriptions** (`on_*_change`), see `corex:events`.
Search: `mix usage_rules.search_docs "set_value" -p corex --query-by title`
## Stable id
Required on every API-driven component:
```heex
<.accordion id="faq" class="accordion" items={…} />
```
## Client — `<.action>` and JS commands
Prefer `<.action>` over raw buttons for Corex Design:
```heex
<.action class="button" phx-click={Corex.Accordion.set_value("faq", ["first"])}>
Open first panel
</.action>
```
Pattern: `Corex.<Name>.<action>("<id>", …args)`
## Server — socket helpers
```elixir
def handle_event("open_first", _params, socket) do
{:noreply, Corex.Accordion.set_value(socket, "faq", ["first"])}
end
```
Pattern: `Corex.<Name>.<action>(socket, "<id>", …args)` — socket first.
## Controlled mode
Server owns state. Pair with `on_value_change` — see `corex:events`:
```heex
<.accordion id="faq" controlled value={@open} on_value_change="faq_value_change" class="accordion" items={…} />
```
```elixir
def handle_event("faq_value_change", %{"value" => value}, socket) do
{:noreply, assign(socket, :open, value)}
end
```
## Async loading
```heex
<.async_result :let={data} assign={@accordion}>
<:loading><.accordion_skeleton count={3} class="accordion" /></:loading>
<.accordion id="async" class="accordion" items={data.items} value={data.value} />
</.async_result>
```
Use `assign_async/3` in `mount/3`.
## Toast layout
```heex
<.toast_group id="layout-toast" class="toast" flash={@flash}>
<:loading><.heroicon name="hero-arrow-path" /></:loading>
<:close><.heroicon name="hero-x-mark" /></:close>
</.toast_group>
```
Programmatic: `Corex.Toast.create/5`, `update/3`, `remove/2`, `dismiss/2`.
## Discovery
1. MCP `get_component { id: "<name>" }`
2. Hexdocs `Corex.<Name>` API section
3. `mix usage_rules.search_docs "<name> set_value" -p corex`
Never invent helper names.
## References
- https://hexdocs.pm/corex/manual_installation.html