diff --git a/lib/live_select.ex b/lib/live_select.ex index 3ab370e..bf1cc80 100644 --- a/lib/live_select.ex +++ b/lib/live_select.ex @@ -417,6 +417,10 @@ defmodule LiveSelect do doc: "one of `:tailwind`, `:daisyui` or `:none`. See the [Styling section](styling.html) for details" + slot(:caret, doc: "optional slot for rendering a caret when no option has been selected.") do + attr :class, :list + end + slot(:option, doc: "optional slot that renders an option in the dropdown. The option's data is available via `:let`" diff --git a/lib/live_select/component.ex b/lib/live_select/component.ex index 8ff2cc0..92286ad 100644 --- a/lib/live_select/component.ex +++ b/lib/live_select/component.ex @@ -363,6 +363,7 @@ defmodule LiveSelect.Component do :"phx-focus", :option, :tag, + :caret, :clear_button, :hide_dropdown, :value_mapper, diff --git a/lib/live_select/component.html.heex b/lib/live_select/component.html.heex index a4ecd3a..4e519ba 100644 --- a/lib/live_select/component.html.heex +++ b/lib/live_select/component.html.heex @@ -76,6 +76,9 @@ <% end %> <% end %> + <%= if @mode == :single && @caret != [] && @selection == [] do %> +
<%= render_slot(caret) %>
+ <% end %> <%= if @mode == :single do %> <%= hidden_input(@field.form, @field.field,