How install and use Petal Components with Phoenix 1.7?

I’m trying to use Petal Components with Phoenix 1.7. I followed the directions at https://petal.build/components#install_petal_components. After that, if I define a LiveView module like this:

defmodule IknowWeb.PetalTest do
  use IknowWeb, :live_view

  def render(assigns) do
    ~H"""
    <.button label="Button" to="/" />
    """
  end
end

I get the error:

(CompileError) function button/1 imported from both 
PetalComponents.Button and IknowWeb.CoreComponents, call is ambiguous

I can resolve the ambiguity by rewriting my render function like this:

def render(assigns) do
    ~H"""
    <PetalComponents.Button.button label="Button" to="/" />
    """
  end

I’m sure there is a better, less verbose way of doing this.

Any suggestions?

you can rename the button function in core_components.ex to button_core or whatever you like
and the <.button will render the petal component button as you like.

I thought about that. But if I use phx.new.live, I think it will generate code using core_component function components. If that is correct, renaming core component functions probably isn’t ideal.