Updating Corex
View SourceHow to pull a newer Corex release into your app and refresh design assets.
Usual update
In mix.exs:
{:corex, "~> 0.2.0"}~> 0.2.0 keeps you on 0.2.x. Then:
mix deps.update corex corex_design corex_mcp
mix deps.get
mix compile
When release notes mention CSS or tokens:
mix corex.design.build
Or run a full asset build with mix assets.build.
For day-to-day patch notes, see CHANGELOG.md. The rest of this guide is the 0.1.x → 0.2.0 migration.
Upgrading to 0.2.0
Requirements
- Elixir
~> 1.17
Packages
Design and MCP are separate Hex packages (they no longer ship inside corex).
Design (tokens, themes, component CSS):
{:corex_design, "~> 0.2", runtime: false, only: :dev}Add :corex_design to your project's compilers when you want design assets to rebuild on mix compile (see Manual installation).
MCP (AI discovery; never enable in :prod):
{:corex_mcp, "~> 0.2", only: [:dev, :test]}Keep plug Corex.MCP on the endpoint. Move any config :corex, mcp_* / MCP debug settings to config :corex_mcp (mcp_root, mcp_verbose_errors, debug). See MCP.
Design pipeline
- Add
config :corex_designtoconfig/config.exs(see Manual installation and Design). - Add
"corex.design.build"toassets.buildandassets.deploy. - Prefer a single CSS import (generated under
assets/corex/):
@import "../corex/corex.css";
@source "../corex";- Remove old copied design CSS that is not generated by
mix corex.design.build. - Run
mix deps.get && mix corex.design.build.
Also:
- Remove
config :corex_design, variants:if present. Bundle filtering usescomponents:andsemantics:only. mix corex.designand--designexare retired; usemix corex.design.build.mix corex.codeis nowmix corex.design.code(Makeup syntax CSS for<.code>).- Optional
--a11yonmix corex.newscaffolds accessibility preference wiring. See Accessibility.
Ignore generated CSS in git (new apps with design get this from mix corex.new):
/assets/corex/If assets/corex/ is already tracked:
echo '/assets/corex/' >> .gitignore
git rm -r --cached assets/corex
git commit -m "Stop tracking generated Corex Design CSS"
Then run mix corex.design.build on every clone / CI before Tailwind or asset builds.
Modifier classes
Per-component BEM palette/size modifiers are gone. Use shared ui-* classes on the host:
| 0.1.x | 0.2.0 |
|---|---|
button button--accent | button ui-accent |
accordion accordion--lg | accordion ui-size-lg |
timer timer--rounded-xl | timer ui-rounded-xl |
button button--accent button--solid | button ui-accent ui-solid |
button button--ghost / button--outline | button ui-ghost (outline removed; drop --outline / ui-outline) |
Stack freely: class="accordion ui-accent ui-size-lg ui-rounded-xl".
Axes: semantic (ui-accent, ui-brand, ui-alert, ui-info, ui-success), variant (ui-solid, ui-ghost; subtle is default), size (ui-size-sm … ui-size-xl), radius (ui-rounded-*). Full reference: modifier guide.
No variant axis on switch, checkbox, radio-group, native-input, number-input, password-input, pin-input, tags-input, or selection hosts such as toggle and toggle-group. Drop ui-solid / ui-ghost / ui-outline from those hosts. Binary controls always paint the checked state with the semantic fill. Input fields keep the shared ui-input surface; semantic classes only tint focus and accent ink. ui-outline is removed entirely.
Token and config renames
| 0.1.x / early naming | 0.2.0 |
|---|---|
{role}-ink (on filled surfaces) | {role}-contrast |
ink-{role} (text on neutral surfaces) | {role}-text |
--theme-color-* aliases | removed; use --color-* |
--theme-* non-color tokens | removed; use public names (--radius-*, --spacing-*, --font-*, --duration-*, …) |
layer / --color-layer / bg-layer | surface / --color-surface / bg-surface |
scales: [semantic: …] | semantics: […] |
theme profile / radius_curve / elevation / … | removed (use numeric Dimensions scales) |
.ui-chrome-* | removed; use host class + part selectors |
selected-* token aliases | removed |
ThemeDefinition | removed; use config :corex_design only |
Forms
- Form components require an explicit
idwhen you do not passfield. Preferfield={@form[:name]}with Ecto +to_form/1so ids stay stable across LiveView patches. - Non-form hook hosts may still omit
:id(derived from:nameor a random prefix). Pass a stable:idwhen usingcontrolledor serveron_*handlers. field={@form[:name]}no longer setsinvalidby default. Passauto_invalidfor alert borders from visible errors, or setinvalid={true}/invalid={false}explicitly (explicit wins).
<.select field={@form[:country]} auto_invalid class="select" …>- Do not set
form_fieldorfield_usedon components; usefield={@form[:…]}only. - Controlled mode on form fields applies only to select, radio, switch, checkbox (not every input).
JSON list datasets
Multi-select values (select, combobox, listbox, tags, pin, date-picker ranges, accordion, toggle-group, tree-view) encode as JSON in the DOM, for example data-default-value='["fra","bel"]'. Do not rely on comma-separated data-* strings in custom JS.
API renames
| Before | After |
|---|---|
toast-create / toast-update / toast-remove / toast-dismiss | toast_create / toast_update / toast_remove / toast_dismiss |
toast payload / detail groupId | group_id |
toggle-group_set_value | toggle_group_set_value |
marquee push %{marquee_id: …} | %{id: …} |
pagination <:prev> / <:next> | <:prev_trigger> / <:next_trigger> |
color_picker label="…" | <:label>…</:label> |
file_upload_live field={:name} | upload_name={:name} |
combobox / color_picker positioning as :map | Corex.Positioning |
color_picker Corex.Json.encode!(presets) | Corex.Dataset.encode_json(presets) |
mix corex.code | mix corex.design.code |
Zag-faithful attrs (checked / pressed / on_checked_change, and data_table selected) stay as-is. Prefer value / on_value_change for selection components.
Checklist
- Bump deps and add
corex_design/corex_mcpif you use them. - Move MCP config to
config :corex_mcp. - Wire
config :corex_design, compilers, andmix corex.design.build. - Grep templates for
--accent,--ghost,--outline, and per-component size/radius BEM classes; rewrite toui-*. Remove any remainingui-outline. - Grep for API renames (
toast-create,groupId,<:prev>, color_pickerlabel=,file_upload_livefield=). - Fix form controls missing
id/field, and opt intoauto_invalidwhere you want alert borders. - Run
mix test,mix assets.build, and spot-check forms, overlays, and tables.
For a full manual install path (first-time setup), see Manual installation.