@@ -26,8 +26,8 @@ defmodule SurfaceBootstrap.DropDown do
2626 @ doc "ID of dropdown, required to work"
2727 prop id , :string , required: true
2828
29- @ doc "Label of dropdown link/button"
30- prop label , :string , required: true
29+ @ doc "Label of dropdown link/button. Use button_content to provide inner content. "
30+ prop label , :string
3131
3232 @ doc """
3333 If prop `split` is set to `true`, wrapper type is automatically set to `btn_group`.
@@ -51,6 +51,15 @@ defmodule SurfaceBootstrap.DropDown do
5151
5252 prop button_size , :string , values: ~w( small normal large) , default: "normal"
5353
54+ @ doc "Custom class for the dropdown button"
55+ prop button_class , :css_class , default: [ ]
56+
57+ @ doc "Custom class for the wrapper"
58+ prop wrapper_class , :css_class , default: [ ]
59+
60+ @ doc "Custom class for the dropdown menu"
61+ prop menu_class , :css_class , default: [ ]
62+
5463 @ doc """
5564 Show dropdown with a separate arrow to click on (split view)? Defaults false.
5665 If set to true will automatically set `@wrapper = "btn_group"` and `@button = true`.
@@ -63,6 +72,8 @@ defmodule SurfaceBootstrap.DropDown do
6372 @ doc "Show dropdown as active"
6473 prop active , :boolean
6574
75+ slot button_content
76+
6677 slot dropdown_items
6778
6879 slot default
@@ -86,11 +97,11 @@ defmodule SurfaceBootstrap.DropDown do
8697 id={@id}
8798 :hook="DropDown"
8899 class={
89- dropdown: @wrapper == "dropdown" && !@direction,
100+ [ dropdown: @wrapper == "dropdown" && !@direction,
90101 dropup: @direction == "up",
91102 dropend: @direction == "right",
92103 dropstart: @direction == "left",
93- "btn-group": @wrapper == "btn_group" || @split == true
104+ "btn-group": @wrapper == "btn_group" || @split == true] ++ @wrapper_class
94105 }
95106 :attrs={
96107 "data-bsnclass": "show"
@@ -107,12 +118,12 @@ defmodule SurfaceBootstrap.DropDown do
107118 id={@id}
108119 :hook="DropDown"
109120 class={
110- "nav-item",
121+ [ "nav-item",
111122 dropdown: !@direction,
112123 dropup: @direction == "up",
113124 dropend: @direction == "right",
114125 dropstart: @direction == "left",
115- "btn-group": @wrapper == "btn_group" || @split == true
126+ "btn-group": @wrapper == "btn_group" || @split == true] ++ @wrapper_class
116127 }
117128 :attrs={
118129 "data-bsnclass": "show"
@@ -151,17 +162,19 @@ defmodule SurfaceBootstrap.DropDown do
151162 <a
152163 id={@id <> "dropdown"}
153164 class={
154- "dropdown-toggle": !@split,
165+ [ "dropdown-toggle": !@split,
155166 "nav-link": @wrapper == "nav_item",
156167 active: @active,
157168 btn: @button,
158169 "btn-#{@color}": @button && @color,
159170 "btn-lg": @button && @button_size == "large",
160- "btn-sm": @button && @button_size == "small"
171+ "btn-sm": @button && @button_size == "small"] ++ @button_class
161172 }
162173 href={!@split && "#"}
163174 >
164- {@label}
175+ <#slot name="button_content">
176+ {@label}
177+ </#slot>
165178 </a>
166179 """
167180 end
@@ -193,8 +206,8 @@ defmodule SurfaceBootstrap.DropDown do
193206 ~F"""
194207 <div
195208 class={
196- "dropdown-menu",
197- "dropdown-menu-dark": @dark
209+ [ "dropdown-menu",
210+ "dropdown-menu-dark": @dark] ++ @menu_class
198211 }
199212 :attrs={
200213 "data-bsnstyle": true,
@@ -210,18 +223,16 @@ defmodule SurfaceBootstrap.DropDown do
210223 ~F"""
211224 <ul
212225 class={
213- "dropdown-menu",
214- "dropdown-menu-dark": @dark
226+ [ "dropdown-menu",
227+ "dropdown-menu-dark": @dark] ++ @menu_class
215228 }
216229 :attrs={
217230 "data-bsnstyle": true,
218231 "aria-labelledby": @id
219232 }
220233 >
221234 {#for {_item, index} <- Enum.with_index(@dropdown_items)}
222- <li>
223- <#slot name="dropdown_items" index={index} />
224- </li>
235+ <#slot name="dropdown_items" index={index} />
225236 {/for}
226237 </ul>
227238 """
0 commit comments