Configuration

View Source

Introduction

Corex uses a small set of application environment keys. Most apps only need Phoenix Gettext configuration for translated component labels.

Config map

Theme CSS, the theme picker, and generator layout flags are three different knobs. Do not put picker allowlists under config :corex.

ConfigRoleDetails
config :corexGenerators and debugdebug, generators (including layout: [theme: true, mode: true]) for mix corex.gen.* only. See below.
config :corex_designBuild-time CSSWhich theme CSS, components, semantics, and optional accessibility preference CSS mix corex.design.build emits (themes, default_theme, default_mode, accessibility, …). See Design and Accessibility. List allowed keys with mix corex.design.options.
config :my_app, :themesRuntime picker allowlistWhich theme names plugs / Tableau Config / JS may switch among (default = first entry). See Theming. Keep this a subset of what :corex_design emits.
config :corex_mcpMCP endpointSeparate Hex package; see MCP.

Corex Design colors come from [data-theme][data-mode] on <html>. Build which theme CSS exists with :corex_design. Decide which names the UI may switch among with :my_app :themes. Persist with cookies / phx:* (Phoenix) or data-* localStorage (Tableau).

Before you start

RequirementNotes
Phoenix appconfig/config.exs loaded at runtime

Translations (Gettext)

Corex reads the same backend as Phoenix templates:

config :phoenix,
  gettext_backend: MyAppWeb.Gettext

Components with a translation assign (Select, Editable, Dialog, and others) use this backend for default labels when no struct is passed. See Localize.

config :corex

KeyTypeDefaultPurpose
:debugbooleanfalseWhen true, verbose logging in Corex (also enables MCP debug if corex_mcp is present)
:generatorskeyword[]Options for mix corex.gen.live and mix corex.gen.html (see below)

Generator keys:

KeyValuesPurpose
:gettexttrue, :sigils, or omitWhen true, generated copy uses gettext/1. When :sigils, uses ~t (needs gettext_sigils in html_helpers).
:gettext_sigilsbooleanAlias for gettext: :sigils
:layoutkeywordmode: true, theme: true, locale: true wire Layouts.app assigns in generated LiveViews / HTML

mix corex.new --lang writes gettext: :sigils and layout: [locale: true] (plus mode / theme when those flags are set). Generators also auto-detect GettextSigils in lib/my_app_web.ex when config is omitted.

Example:

config :corex,
  debug: false,
  generators: [
    gettext: :sigils,
    layout: [locale: true, mode: true, theme: true]
  ]

Phoenix uses a similar pattern on the web app, for example config :my_app, :generators, context_app: :my_app. Corex reads config :corex, :generators for layout and translation behavior in mix corex.gen.*.

MCP

MCP lives in the separate Hex package corex_mcp. Mount plug Corex.MCP on the endpoint and configure config :corex_mcp (see MCP). Enable only in :dev (or :test in generated apps); never in :prod.

  • Design: config :corex_design and bundle filtering
  • Theming: runtime data-theme picker
  • Dark mode: runtime data-mode toggle
  • Accessibility: optional preference axes (data-text, data-contrast, …). Scaffold with mix corex.new --a11y / mix corex.tableau.new --a11y (default off).
  • Localize: locales and Gettext setup
  • MCP: development tooling endpoint (corex_mcp)
  • Installation: first-time setup