Surface.Component behaviour (surface v0.7.0) View Source

Defines a stateless component.

Example

defmodule Button do
  use Surface.Component

  prop click, :event

  def render(assigns) do
    ~F"""
    <button class="button" :on-click={@click}>
      <#slot/>
    </button>
    """
  end
end

Note: Stateless components cannot handle Phoenix LiveView events. If you need to handle them, please use a Surface.LiveComponent instead.

Link to this section Summary

Link to this section Callbacks

Specs

render(assigns :: Socket.assigns()) :: Phoenix.LiveView.Rendered.t()