HTML component base for Phlex.
Use this module to create HTML components:
defmodule MyComponent do
use Phlex.HTML
def view_template(assigns, state) do
div(state, [class: "container"], fn state ->
h1(state, [class: "title"], "Hello, World!")
end)
end
endStandard HTML Elements
All standard HTML elements are available as functions that accept state explicitly. This follows Elixir's functional programming style and ensures clear data flow.
Examples
def view_template(assigns, state) do
div(state, [class: "card"], fn state ->
h1(state, [class: "title"], "Hello")
end)
end
Summary
Functions
Renders a standard HTML element.
Renders a void HTML element (self-closing).
Renders a dynamic HTML tag.