PhoenixKitWeb.Components.Core.ThemeController (phoenix_kit v2.7.0)

Copy Markdown View Source

Shared theme controller component for admin and dashboard.

Provides a dropdown to select from available daisyUI themes. Supports filtering to show only specific themes.

Summary

Functions

Renders a theme controller dropdown.

Functions

theme_controller(assigns)

Renders a theme controller dropdown.

Attributes

  • themes - List of theme names to show, or :all for all themes (default: :all)
  • id - Unique ID for the dropdown (default: "theme-dropdown")
  • class - Additional CSS classes

Examples

<%!-- All themes --%>
<.theme_controller />

<%!-- Only specific themes --%>
<.theme_controller themes={["system", "light", "dark", "nord", "dracula"]} />

<%!-- From config --%>
<.theme_controller themes={Application.get_env(:phoenix_kit, :dashboard_themes, :all)} />

Attributes

  • themes (:any) - Defaults to :all.

  • id (:string) - Defaults to "theme-dropdown".

  • class (:string) - Defaults to nil.

  • mode (:atom) - :auto renders a toggle when the theme list is exactly two concrete themes of DIFFERING base (one light, one dark) and a dropdown otherwise; :dropdown and :toggle force the shape. :toggle raises unless the list is such a pair — a toggle over three states would have hidden state, and sun/moon semantics over two themes of the same base are false. (A :cycle mode was considered and rejected: hidden state, no accessibility story, and it makes configuration ORDER behavioural.)

    Defaults to :auto. Must be one of :auto, :dropdown, or :toggle.

  • Global attributes are accepted.