Learn how to use Phoenix's auto-generated core components for building reusable UI elements
Learn how to use Phoenix’s auto-generated core components for building reusable UI elements.
core_components.ex
file.component_name
(dot syntax)ShopWeb.CoreComponents.button
) or, thanks to Phoenix’s auto-import system, just use the dot syntax in HEEx and it will work<.button>
component expects an inner_block
(slot/child)ShopWeb.CoreComponents
is imported in the Phoenix HTML macro<.button>Click me</.button>
for buttons<.back navigate={~p"/products"}>Back to product listing</.back>
for a back-to-listing button (where ~p
uses the verified route sigil)Phoenix makes it easy to use and compose reusable UI components (like buttons, icons, “back” links) throughout your app with zero boilerplate, and all the best examples are in the auto-generated core_components.ex
file.