Skip to content

Commit abf11c5

Browse files
author
Ibrahim Haizel
committed
add props for suggestion item styling
1 parent 9a8379b commit abf11c5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/lib/components/ui/MultiSelectSearchAutocomplete.svelte

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@
5959
minLength = 0,
6060
tTooShort = (n: number) => `Enter ${n} or more characters for suggestions`,
6161
62-
...attributes
62+
// Custom styling props
63+
choicesItemBackgroundColor = "#f3f2f1",
64+
choicesItemBorderColor = "#b1b4b6",
65+
choicesItemTextColor = "black",
66+
...attributes
67+
6368
}: {
6469
id: string;
6570
name: string;
@@ -89,6 +94,9 @@
8994
sourceSelector?: (query: string, options: any[]) => "api" | "options";
9095
minLength?: number;
9196
tTooShort?: (n: number) => string;
97+
choicesItemBackgroundColor?: string;
98+
choicesItemBorderColor?: string;
99+
choicesItemTextColor?: string;
92100
} & Omit<
93101
import("svelte/elements").HTMLSelectAttributes,
94102
| "id"
@@ -951,7 +959,7 @@
951959

952960
<div
953961
class="gem-c-select-with-search"
954-
style={`--cross-icon-url: url("${crossIconUrl}")`}
962+
style={`--cross-icon-url: url("${crossIconUrl}"); --choices-item-bg-color: ${choicesItemBackgroundColor}; --choices-item-border-color: ${choicesItemBorderColor}; --choices-item-text-color: ${choicesItemTextColor};`}
955963
>
956964
{#snippet rightIcon()}
957965
<button
@@ -1723,9 +1731,9 @@
17231731
.choices__list[aria-expanded]
17241732
.choices__item--selectable.is-highlighted
17251733
) {
1726-
background-color: #1d70b8;
1727-
border-color: #1d70b8;
1728-
color: #fff;
1734+
background-color: var(--choices-item-bg-color, #1d70b8);
1735+
border-color: var(--choices-item-border-color, #1d70b8);
1736+
color: var(--choices-item-text-color, #fff);
17291737
outline: none;
17301738
}
17311739
:global(.gem-c-select-with-search .choices__heading) {

0 commit comments

Comments
 (0)