freedive/lib/liliform/label.ex

19 lines
563 B
Elixir

defmodule Liliform.Label do
use Liliform.Component
@doc """
Renders a label.
"""
attr :for, :string, default: nil, doc: "the for attribute of the label"
attr :class, :string, default: nil, doc: "the optional class of the label"
attr :rest, :global, doc: "the arbitrary HTML attributes to add to the label"
slot :inner_block, required: true, doc: "the inner block that renders the label content"
def label(assigns) do
~H"""
<label for={@for} class={@class} {@rest}>
<%= render_slot(@inner_block) %>
</label>
"""
end
end