Skip to content

Commit c23accc

Browse files
authored
Merge pull request #4 from erimicel/dark-mode
Dark mode and multiple select UI changes
2 parents bae2495 + dee9a60 commit c23accc

12 files changed

+409
-148
lines changed

dist/select2-tailwindcss-theme-plain.css

+295-74
Large diffs are not rendered by default.

dist/select2-tailwindcss-theme-plain.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select2-tailwindcss-theme.css

+48-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
/* Dropdown */
88
.select2-container--tailwindcss-3.select2-container--open .select2-dropdown {
9-
@apply w-full py-1 mt-1 overflow-auto text-base bg-white border-none rounded-md shadow-lg max-h-60 ring-1 ring-black/5 ring-opacity-5 focus:outline-none sm:text-sm;
9+
@apply w-full py-1 mt-1 overflow-auto text-base bg-white border-none rounded-md shadow-lg max-h-60 ring-1 ring-black/5 ring-opacity-5 focus:outline-none sm:text-sm dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-indigo-600 dark:focus:border-indigo-600;
1010
}
1111

1212
/* Dropdown position */
@@ -20,7 +20,7 @@
2020

2121
/* Search box */
2222
.select2-container--tailwindcss-3 .select2-search--dropdown .select2-search__field {
23-
@apply block w-full px-3 py-1.5 text-sm placeholder-gray-400 border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500;
23+
@apply block w-full px-3 py-1.5 text-base sm:text-sm/6 placeholder-gray-400 border-gray-300 border rounded-md shadow-sm focus:border-indigo-600 focus:outline-none focus:ring-1 focus:ring-indigo-600 dark:bg-gray-700;
2424
}
2525

2626
/* Results container */
@@ -30,22 +30,26 @@
3030

3131
/* Option items */
3232
.select2-container--tailwindcss-3 .select2-results__option {
33-
@apply relative py-2 pl-3 text-gray-900 transition-colors duration-150 ease-in-out cursor-default select-none pr-9;
33+
@apply relative py-2 pl-3 text-gray-900 transition-colors duration-150 ease-in-out cursor-default select-none pr-9 dark:text-white;
3434
}
3535

3636
/* Hover state */
3737
.select2-container--tailwindcss-3 .select2-results__option--highlighted {
3838
@apply text-white bg-indigo-600;
3939
}
4040

41+
.select2-container--tailwindcss-3 .select2-results__option--highlighted::after {
42+
@apply text-white !important;
43+
}
44+
4145
/* Selected state */
4246
.select2-container--tailwindcss-3 .select2-results__option--selected {
43-
@apply font-medium text-blue-900 bg-blue-100;
47+
@apply font-semibold dark:text-white;
4448
}
4549

4650
/* Selected with checkmark */
4751
.select2-container--tailwindcss-3 .select2-results__option--selected::after {
48-
@apply absolute inset-y-0 flex items-center text-blue-600 right-3;
52+
@apply absolute inset-y-0 flex items-center text-indigo-600 right-3;
4953
content: "✓";
5054
}
5155

@@ -75,30 +79,40 @@
7579

7680
/* Loading spinner */
7781
.select2-container--tailwindcss-3 .select2-results__option--loading::after {
78-
@apply w-5 h-5 border-2 border-gray-300 rounded-full animate-spin border-t-blue-600;
82+
@apply w-5 h-5 border-2 border-gray-300 rounded-full animate-spin border-t-indigo-600;
7983
content: "";
8084
}
8185

8286
/* Error states */
8387
.field_with_errors .select2-container--tailwindcss-3 .select2-selection,
8488
select.is-invalid ~ .select2-container--tailwindcss-3 .select2-selection,
8589
select:invalid ~ .select2-container--tailwindcss-3 .select2-selection {
86-
@apply border-red-500 placeholder:text-red-300 text-red-900;
90+
@apply border-red-500 text-red-900;
91+
}
92+
.field_with_errors .select2-container--tailwindcss-3 .select2-container--focus,
93+
select.is-invalid ~ .select2-container--tailwindcss-3 .select2-container--focus,
94+
select:invalid ~ .select2-container--tailwindcss-3 .select2-container--focus {
95+
@apply ring-red-500 border-red-500 !important;
96+
}
97+
.field_with_errors .select2-container--tailwindcss-3 .select2-selection__placeholder,
98+
select.is-invalid ~ .select2-container--tailwindcss-3 .select2-selection__placeholder,
99+
select:invalid ~ .select2-container--tailwindcss-3 .select2-selection__placeholder {
100+
@apply text-red-300;
87101
}
88102

89103
/* Single Selection */
90104
.select2-container--tailwindcss-3 .select2-selection--single {
91-
@apply relative w-full h-9 py-1.5 pl-3 pr-8 text-left transition-colors duration-200 ease-in-out bg-white border border-gray-300 rounded-md cursor-default focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500 sm:text-sm;
105+
@apply relative w-full h-auto min-h-[2.25rem] py-1.5 pl-3 pr-8 text-left text-base sm:text-sm/6 transition-colors duration-200 ease-in-out bg-white border border-gray-300 rounded-md cursor-default dark:bg-white/5 dark:text-white dark:border-white/10;
92106
}
93107

94108
/* Rendered text */
95109
.select2-container--tailwindcss-3 .select2-selection--single .select2-selection__rendered {
96-
@apply block pl-0 pr-0 text-gray-900 truncate;
110+
@apply block pl-0 pr-0 text-gray-900 truncate dark:text-white;
97111
}
98112

99113
/* Placeholder */
100114
.select2-container--tailwindcss-3 .select2-selection--single .select2-selection__placeholder {
101-
@apply text-gray-400;
115+
@apply text-gray-400 dark:text-gray-500;
102116
}
103117

104118
/* Arrow container */
@@ -108,26 +122,27 @@ select:invalid ~ .select2-container--tailwindcss-3 .select2-selection {
108122

109123
/* Arrow */
110124
.select2-container--tailwindcss-3 .select2-selection--single .select2-selection__arrow b {
111-
@apply w-5 h-5 text-gray-400;
125+
@apply w-5 h-5 text-gray-400 bg-center bg-no-repeat bg-contain;
112126
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
113-
background-position: center;
114-
background-repeat: no-repeat;
115-
background-size: contain;
116127
}
117128

118129
/* Disabled state */
119130
.select2-container--tailwindcss-3.select2-container--disabled .select2-selection--single {
120-
@apply text-gray-500 cursor-not-allowed bg-gray-50;
131+
@apply text-gray-500 cursor-not-allowed bg-gray-50 border-gray-200 dark:bg-white/20 dark:border-white/5;
132+
}
133+
134+
.select2-container--tailwindcss-3.select2-container--disabled.select2-container--focus .select2-selection--single {
135+
@apply ring-0 border-gray-200 dark:border-white/5;
121136
}
122137

123138
/* Clear button */
124139
.select2-container--tailwindcss-3 .select2-selection--single .select2-selection__clear {
125-
@apply float-right pr-0 mr-0 font-bold text-gray-400 cursor-pointer hover:text-gray-600;
140+
@apply font-bold absolute inset-y-0 right-0 flex items-center pr-[2rem] text-base sm:text-sm/6 text-gray-400 cursor-pointer hover:text-gray-700;
126141
}
127142

128143
/* Focus styles for keyboard navigation */
129144
.select2-container--tailwindcss-3.select2-container--focus .select2-selection--single {
130-
@apply border-blue-500 ring-1 ring-blue-500;
145+
@apply ring-1 ring-indigo-600 border-indigo-600 outline-none;
131146
}
132147

133148
/* RTL Support */
@@ -137,32 +152,40 @@ select:invalid ~ .select2-container--tailwindcss-3 .select2-selection {
137152

138153
/* Multiple selection */
139154
.select2-container--tailwindcss-3 .select2-selection--multiple {
140-
@apply min-h-[2.25rem] rounded-md border border-gray-300 bg-white py-1 px-2 focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500;
155+
@apply min-h-[2.25rem] h-auto rounded-md text-base sm:text-sm/6 bg-white py-1.5 px-3 border border-gray-300 cursor-default dark:bg-white/5 dark:text-white dark:border-white/10;
141156
}
142157

143158
/* Multiple selection list */
144159
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-selection__rendered {
145-
@apply inline float-left;
160+
@apply flex flex-row flex-wrap gap-2 m-0 p-0 list-none;
146161
}
147162

148163
/* Multiple selection choices */
149164
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-selection__choice {
150-
@apply m-1 inline-flex items-center rounded-md bg-blue-100 px-2.5 py-0.5 text-sm font-medium text-blue-800;
165+
@apply inline-flex items-center rounded-md bg-indigo-100 px-2.5 py-0.5 text-base sm:text-sm/6 font-medium text-indigo-800;
151166
}
152167

153168
/* Remove button */
154169
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-selection__choice__remove {
155-
@apply -ml-1 mr-1.5 h-4 w-4 items-center flex justify-center rounded-full text-blue-600 hover:bg-blue-200 hover:text-blue-900;
170+
@apply -ml-1 mr-1.5 h-4 w-4 pb-[0.10rem] items-center flex justify-center rounded-full text-indigo-600 hover:bg-blue-200 hover:text-indigo-900;
156171
}
157172

158173
/* Search field in multiple selection */
174+
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-search--inline {
175+
@apply block;
176+
}
177+
159178
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-search--inline .select2-search__field {
160-
@apply h-8 p-0 text-sm placeholder-gray-400 bg-transparent border-0 focus:outline-none focus:ring-0;
179+
@apply h-[1.5rem] p-0 m-0 text-base sm:text-sm/6 bg-transparent border-0 focus:outline-none focus:ring-0 dark:placeholder:text-gray-500 placeholder:text-gray-400;
161180
}
162181

163182
/* Disabled state */
164183
.select2-container--tailwindcss-3.select2-container--disabled .select2-selection--multiple {
165-
@apply text-gray-500 cursor-not-allowed bg-gray-50;
184+
@apply text-gray-500 cursor-not-allowed bg-gray-50 border-gray-200 dark:bg-white/20 dark:border-white/5;
185+
}
186+
187+
.select2-container--tailwindcss-3.select2-container--disabled.select2-container--focus .select2-selection--multiple {
188+
@apply ring-0 border-gray-200 dark:border-white/5;
166189
}
167190

168191
/* Clearable state */
@@ -172,10 +195,10 @@ select:invalid ~ .select2-container--tailwindcss-3 .select2-selection {
172195

173196
/* Clear button */
174197
.select2-container--tailwindcss-3 .select2-selection--multiple .select2-selection__clear {
175-
@apply absolute top-0 right-0 mt-2 mr-4 font-bold text-gray-400 cursor-pointer hover:text-gray-600;
198+
@apply font-bold absolute inset-y-0 right-0 flex items-center pr-4 text-base sm:text-sm/6 text-gray-400 cursor-pointer hover:text-gray-700;
176199
}
177200

178201
/* Focus styles for keyboard navigation */
179202
.select2-container--tailwindcss-3.select2-container--focus .select2-selection--multiple {
180-
@apply border-blue-500 ring-1 ring-blue-500;
203+
@apply ring-1 ring-indigo-600 border-indigo-600 outline-none;
181204
}

0 commit comments

Comments
 (0)