Skip to content

Commit 837cf14

Browse files
committed
style: enhance CustomSelect component and add custom styles for select elements
- Updated CustomSelect component styles for improved aesthetics and usability. - Added custom styles for native select elements, including hover and focus states. - Improved accessibility and visual consistency across select options.
1 parent 10ff4c1 commit 837cf14

2 files changed

Lines changed: 65 additions & 7 deletions

File tree

src/components/CustomSelect.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ export default function CustomSelect<T extends string>({
3939
<button
4040
type="button"
4141
onClick={() => setOpen((prev) => !prev)}
42-
className="w-full px-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-800 text-gray-900 dark:text-gray-100 flex items-center justify-between shadow-sm hover:border-primary-500 focus:outline-none focus:ring-2 focus:ring-primary-500"
42+
className="w-full px-4 py-2.5 border border-dark-border rounded-lg bg-dark-card text-white flex items-center justify-between shadow-sm hover:border-primary-500/60 focus:outline-none focus:ring-2 focus:ring-primary-500/50 focus:border-primary-500 transition-colors"
4343
>
4444
<span className="flex items-center gap-2">
4545
{current?.icon && <span className="text-lg">{current.icon}</span>}
46-
<span>{current?.label ?? placeholder}</span>
46+
<span className="text-sm">{current?.label ?? placeholder}</span>
4747
</span>
4848
<svg
49-
className={`w-4 h-4 text-gray-500 dark:text-gray-400 transition-transform ${open ? 'rotate-180' : ''}`}
49+
className={`w-4 h-4 text-gray-400 transition-transform duration-200 ${open ? 'rotate-180' : ''}`}
5050
fill="none"
5151
stroke="currentColor"
5252
viewBox="0 0 24 24"
@@ -57,7 +57,7 @@ export default function CustomSelect<T extends string>({
5757
</button>
5858

5959
{open && (
60-
<div className="absolute z-20 mt-2 w-full bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg max-h-64 overflow-y-auto">
60+
<div className="absolute z-20 mt-2 w-full bg-dark-card border border-dark-border rounded-lg shadow-soft-xl max-h-64 overflow-y-auto animate-slide-down">
6161
{options.map((opt) => {
6262
const isActive = opt.value === value
6363
return (
@@ -68,10 +68,10 @@ export default function CustomSelect<T extends string>({
6868
onChange(opt.value)
6969
setOpen(false)
7070
}}
71-
className={`w-full text-left px-4 py-2 flex items-center gap-2 text-sm ${
71+
className={`w-full text-left px-4 py-2.5 flex items-center gap-2 text-sm transition-colors ${
7272
isActive
73-
? 'bg-primary-50 dark:bg-primary-900/30 text-primary-700 dark:text-primary-200'
74-
: 'text-gray-800 dark:text-gray-100 hover:bg-gray-100 dark:hover:bg-gray-800'
73+
? 'bg-primary-600/20 text-primary-400 border-l-2 border-primary-500'
74+
: 'text-gray-300 hover:bg-dark-100 hover:text-white'
7575
}`}
7676
>
7777
{opt.icon && <span className="text-lg">{opt.icon}</span>}

src/index.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,61 @@ body {
4545
::-webkit-scrollbar-thumb:hover {
4646
background: #3a3b4a;
4747
}
48+
49+
/* Custom styles for native select elements */
50+
select {
51+
appearance: none;
52+
-webkit-appearance: none;
53+
-moz-appearance: none;
54+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
55+
background-repeat: no-repeat;
56+
background-position: right 0.75rem center;
57+
background-size: 1rem;
58+
padding: 0.625rem 2.5rem 0.625rem 1rem;
59+
border: 1px solid #2a2b3a;
60+
border-radius: 0.5rem;
61+
background-color: #1a1b26;
62+
color: #ffffff;
63+
font-size: 0.875rem;
64+
line-height: 1.5;
65+
cursor: pointer;
66+
transition: all 0.2s ease-in-out;
67+
width: 100%;
68+
}
69+
70+
select:hover {
71+
border-color: #38bdf8;
72+
}
73+
74+
select:focus {
75+
outline: none;
76+
border-color: #38bdf8;
77+
box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
78+
}
79+
80+
select:disabled {
81+
opacity: 0.5;
82+
cursor: not-allowed;
83+
background-color: #13131a;
84+
}
85+
86+
/* Firefox specific styles */
87+
@-moz-document url-prefix() {
88+
select {
89+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
90+
padding-right: 2.5rem;
91+
}
92+
}
93+
94+
/* Style select options */
95+
select option {
96+
background-color: #1a1b26;
97+
color: #ffffff;
98+
padding: 0.5rem;
99+
}
100+
101+
select option:hover,
102+
select option:checked {
103+
background-color: #0284c7;
104+
color: #ffffff;
105+
}

0 commit comments

Comments
 (0)