Aurora. Uix. Templates. ThemeHelper
(Aurora UIX v0.1.4-rc.6)
Copy Markdown
Provides helper functions for embedding theme-based styles within HEEx templates.
Offers a convenient way to include compiled or dynamic themeable stylesheets. Leverages the configured theme module to apply consistent styling and manage CSS rule generation.
The stylesheet is split across three files:
auix-variables.css—:rootvariable declarations and palette colors.auix-rules.css—.auix-*component rules.auix-baseline.css— tag-selector reset for hosts without a CSS preflight. Tailwind hosts should ignore this file; non-Tailwind hosts@importit beforeauix-variables.css.
Summary
Functions
Generates the baseline tag-selector stylesheet for non-Tailwind hosts.
Generates the rules half of the stylesheet.
Generates a complete stylesheet from all rules in the theme module.
Generates the variables half of the stylesheet.
Extracts the rule contents and replace and create a new rule using the target_name.
Registers and retrieves all available themes.
Returns the configured theme module.
Returns the name of the configured theme.
Functions
@spec generate_baseline_stylesheet() :: binary()
Generates the baseline tag-selector stylesheet for non-Tailwind hosts.
Hosts on Tailwind v4 (or any other CSS reset) should NOT import this — it
patches html, body, and a selectors that Tailwind's preflight
already normalises. Hosts without a reset import auix-baseline.css
BEFORE auix-variables.css so the @layer auix.baseline placement is
honoured.
Returns
binary() - The combined baseline CSS rules.
@spec generate_rules_stylesheet() :: binary()
Generates the rules half of the stylesheet.
Emits every theme rule except :root and :root_colors, which are
handled by generate_variables_stylesheet/0.
Returns
binary() - The component CSS rules.
@spec generate_stylesheet() :: binary()
Generates a complete stylesheet from all rules in the theme module.
Returns
binary() - All the :root_colors from all the registered themes plus the CSS rules from the configured theme module.
Examples
iex> generate_stylesheet(MyApp.Theme)
["<style>.button { color: blue; }</style>", "<style>.card { ... }</style>"]
@spec generate_variables_stylesheet() :: binary()
Generates the variables half of the stylesheet.
Emits the :root declarations from the configured theme (sizes, typography,
shadows) followed by every registered palette's :root_colors, then the
shared :root_color_aliases block. Host applications can @import this
file, override individual --auix-* vars, and then @import the rules file.
Returns
binary() - The combined CSS variable declarations.
Extracts the rule contents and replace and create a new rule using the target_name.
Parameters
rule_source(atom()) - rule name to import from.target_name(binary()|atom()) - rule to create.
Returns
binary()- The new css rule.
@spec registered_themes() :: map()
Registers and retrieves all available themes.
@spec theme_module() :: module()
Returns the configured theme module.
Returns
module() | nil - The theme module configured at compile time, nil if the configured module name
is not registered. This might provoke an error in calling modules.
Examples
iex> theme_module()
Aurora.Uix.Templates.Basic.Themes.WhiteCharcoal
@spec theme_name() :: atom()
Returns the name of the configured theme.
Returns
atom() - The name of the configured theme.
Examples
iex> theme_name()
:white_charcoal