File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,10 @@ const Cursor: React.FC<CursorProps> = ({
3737 return customDefaultColor || fallbackColor ;
3838 } , [ customDefaultColor ] ) ;
3939
40+ const defaultTextColor = useMemo ( ( ) => {
41+ return window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches ? 'hsl(240 10% 3.9%)' : 'hsl(0 0% 98%)' ;
42+ } , [ ] ) ;
43+
4044 const defaultVariants : Record < CursorType , CursorVariant > = {
4145 default : {
4246 style : {
@@ -206,7 +210,7 @@ const Cursor: React.FC<CursorProps> = ({
206210 ref = { contentRef }
207211 className = { `react-dot-cursor-content ${ currentVariantData . content . className || '' } ` }
208212 style = { {
209- color : 'white' ,
213+ color : `var(--cursor-text-color, ${ defaultTextColor } )` ,
210214 fontSize : '16px' ,
211215 ...currentVariantData . content . style ,
212216 } }
Original file line number Diff line number Diff line change 4848 --chart-5 : 27 87% 67% ;
4949 --radius : 0.5rem ;
5050 --cursor-color : hsl (349 , 80% , 59% );
51+ --cursor-text-color : white;
5152 }
5253 .dark {
5354 --background : 240 10% 3.9% ;
7576 --chart-4 : 280 65% 60% ;
7677 --chart-5 : 340 75% 55% ;
7778 --cursor-color : hsl (349 , 80% , 59% );
79+ --cursor-text-color : white;
7880 }
7981}
8082
Original file line number Diff line number Diff line change 44
55### <a name = " using-css-variables" ></a >Using CSS Variables
66
7- You can style the cursor by setting the ` --cursor-color ` CSS variable using any ** valid CSS color format** .
7+ You can style the cursor by setting the ` --cursor-color ` and ` --cursor-text-color ` CSS variable using any ** valid CSS color format** .
88
99``` css
1010:root {
11- --cursor-color : hsl (349 80% 59% ); /* HSL */
12- --cursor-color : #ff4081 ; /* Hex */
13- --cursor-color : rgb (255 64 129 ); /* RGB */
14- --cursor-color : oklch(0.7 0.15 330 ); /* OKLCH */
15- --cursor-color : hotpink ; /* Named color */
11+ --cursor-color : hsl (349 80% 59% );
12+ --cursor-text-color : white ;
1613}
1714```
1815
@@ -24,12 +21,14 @@ The cursor automatically detects system dark mode preferences and adjusts its co
2421/* Light mode */
2522:root {
2623 --cursor-color : hsl (240 10% 3.9% );
24+ --cursor-text-color : hsl (0 0% 98% );
2725}
2826
2927/* Dark mode */
3028@media (prefers-color-scheme: dark) {
3129 :root {
3230 --cursor-color : hsl (0 0% 98% );
31+ --cursor-text-color : hsl (240 10% 3.9% );
3332 }
3433}
3534```
You can’t perform that action at this time.
0 commit comments