Skip to content

Commit 6778d43

Browse files
committed
feature: SelectBox has custom scrollbar
1 parent 557b2fd commit 6778d43

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

packages/design-system/src/css/style.css

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
--code-text-color: rgba(0, 122, 255, 1);
3737
--code-bg-color: rgba(96, 165, 250, 0.2);
3838
--code-block-bg-color: rgba(60, 60, 60, 0.12);
39+
40+
/* Scrollbar tokens (colors reuse existing palette) */
41+
--scrollbar-size: 10px; /* width/height for webkit scrollbars */
42+
--scrollbar-track: var(--color-white);
43+
--scrollbar-thumb: var(--color-gray-400);
44+
--scrollbar-thumb-hover: var(--color-gray-400);
3945
}
4046

4147
@media (prefers-color-scheme: dark) {
@@ -46,9 +52,27 @@
4652
--content-fg: #fff;
4753
--content-hover-bg: #222;
4854
--content-hover-fg: #fff;
55+
--scrollbar-track: var(--color-charcoal-600);
56+
/* Dark overrides for scrollbar */
57+
--scrollbar-thumb: var(--color-charcoal-100);
58+
--scrollbar-thumb-hover: var(--color-gray-800);
4959
}
5060
}
5161

62+
/* Dark theme variable overrides for class-based theming */
63+
.dark-theme {
64+
/* ensure tokens match dark scheme even without prefers-color-scheme */
65+
--scrollbar-track: var(--color-charcoal-600);
66+
--scrollbar-thumb: var(--color-charcoal-100);
67+
--scrollbar-thumb-hover: var(--color-gray-800);
68+
/* let UA widgets (including scrollbars) render in dark mode where supported */
69+
color-scheme: dark;
70+
}
71+
/* Ensure scrollable containers participate in dark color-scheme */
72+
.dark-theme .custom-scrollbar {
73+
color-scheme: dark;
74+
}
75+
5276
@theme {
5377
--text-xxs: 0.625rem;
5478
--text-xxs--line-height: calc(1 / 0.625);
@@ -152,6 +176,56 @@
152176
}
153177
}
154178

179+
/* ===================== Custom Scrollbar (cross-browser) =====================
180+
Usage: Add `custom-scrollbar` class to any scrollable container.
181+
Notes:
182+
- Firefox uses `scrollbar-width` and `scrollbar-color`.
183+
- WebKit/Blink (Chrome/Edge/Safari) use `::-webkit-scrollbar` pseudo elements.
184+
- macOS/iOS show overlay scrollbars; thick tracks may appear slimmer there.
185+
- Uses existing CSS variables (tokens) for colors and size.
186+
============================================================================ */
187+
@layer components {
188+
/* Base (light) theme */
189+
.custom-scrollbar {
190+
/* Firefox */
191+
scrollbar-width: thin; /* auto | thin | none */
192+
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); /* thumb track */
193+
/* Layout stability where supported */
194+
scrollbar-gutter: stable both-edges; /* ignored if unsupported */
195+
}
196+
.custom-scrollbar::-webkit-scrollbar {
197+
width: var(--scrollbar-size);
198+
height: var(--scrollbar-size);
199+
}
200+
.custom-scrollbar::-webkit-scrollbar-track {
201+
background: var(--scrollbar-track);
202+
}
203+
.custom-scrollbar::-webkit-scrollbar-thumb {
204+
background: var(--scrollbar-thumb);
205+
border-radius: 999px;
206+
border: 2px solid var(--scrollbar-track); /* visual separation from track */
207+
}
208+
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
209+
background: var(--scrollbar-thumb-hover); /* hover color */
210+
}
211+
212+
/* Dark theme overrides (scoped to your `.dark-theme` root) */
213+
.dark-theme .custom-scrollbar {
214+
scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); /* thumb track */
215+
}
216+
.dark-theme .custom-scrollbar::-webkit-scrollbar-track {
217+
background: var(--scrollbar-track);
218+
}
219+
.dark-theme .custom-scrollbar::-webkit-scrollbar-thumb {
220+
background: var(--scrollbar-thumb);
221+
border: 2px solid var(--scrollbar-track);
222+
}
223+
.dark-theme .custom-scrollbar::-webkit-scrollbar-thumb:hover {
224+
background: var(--scrollbar-thumb-hover); /* hover color */
225+
}
226+
}
227+
/* =================== End Custom Scrollbar (cross-browser) =================== */
228+
155229
/* Everthing below here to be cleaned up over time. */
156230

157231
body {

src/components/input/MultiSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ const pt = computed(() => ({
242242
},
243243
listContainer: () => ({
244244
style: { maxHeight: listMaxHeight },
245-
class: 'overflow-y-auto scrollbar-hide'
245+
class: 'overflow-y-auto custom-scrollbar'
246246
}),
247247
list: {
248248
class: 'flex flex-col gap-0 p-0 m-0 list-none border-none text-sm'

src/components/input/SingleSelect.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const pt = computed(() => ({
159159
},
160160
listContainer: () => ({
161161
style: `max-height: ${listMaxHeight}`,
162-
class: 'overflow-y-auto scrollbar-hide'
162+
class: 'overflow-y-auto custom-scrollbar'
163163
}),
164164
list: {
165165
class:

0 commit comments

Comments
 (0)