Skip to content

Commit 32e7d55

Browse files
authoredJan 23, 2025··
fix ::selection styles, use hsla instead of hsl because it can overlap text with ::selection background when background-clip: text is set (#4011)
fix
1 parent fc78033 commit 32e7d55

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed
 

‎.changeset/honest-parrots-rest.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nextra": patch
3+
---
4+
5+
fix `::selection` styles, use `hsla` instead of `hsl` because it can overlap text with `::selection` background when `background-clip: text` is set

‎packages/nextra/src/client/components/head.tsx

+1-11
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,7 @@ export const Head: FC<HeadProps> = ({ children, ...props }) => {
9696
--nextra-bg: ${backgroundColor.dark};
9797
}
9898
::selection {
99-
background: ${makePrimaryColor('+ 41%')};
100-
}
101-
.dark ::selection {
102-
background: ${makePrimaryColor('- 11%')};
99+
background: hsla(var(--nextra-primary-hue),var(--nextra-primary-saturation),var(--nextra-primary-lightness),.3);
103100
}
104101
html {
105102
background: rgb(var(--nextra-bg));
@@ -130,10 +127,3 @@ html {
130127
</head>
131128
)
132129
}
133-
134-
function makePrimaryColor(val: string): string {
135-
const h = 'var(--nextra-primary-hue)'
136-
const s = 'var(--nextra-primary-saturation)'
137-
const l = `calc(var(--nextra-primary-lightness) ${val})`
138-
return `hsl(${h + s + l})`
139-
}

0 commit comments

Comments
 (0)
Please sign in to comment.