UI: Use native scroll bar for codeblocks and some elements for better performance

This commit is contained in:
Fuma Nama
2025-05-15 19:05:51 +08:00
parent ac0ab12294
commit 8e862e534d
4 changed files with 26 additions and 8 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-ui': patch
---
Use native scroll bar for codeblocks and some elements for better performance
+16
View File
@@ -227,6 +227,22 @@
}
}
@utility fd-scroll-container {
&::-webkit-scrollbar {
width: 5px;
height: 5px;
}
&::-webkit-scrollbar-thumb {
border-radius: 5px;
background: var(--color-fd-border);
}
&::-webkit-scrollbar-track {
background: transparent;
}
}
@utility fd-steps {
counter-reset: step;
position: relative;
+3 -6
View File
@@ -4,8 +4,9 @@
}
code .line {
min-height: 1em;
@apply relative inline-block w-full;
line-height: 1.45em;
min-height: 1.45em;
@apply relative;
}
&[data-line-numbers] code .twoslash-meta-line {
@@ -48,10 +49,6 @@
@apply text-fd-diff-add-symbol;
}
code .diff {
@apply relative;
}
.highlighted {
@apply bg-fd-primary/10;
}
+2 -2
View File
@@ -51,7 +51,7 @@ export const Pre = forwardRef<HTMLPreElement, HTMLAttributes<HTMLPreElement>>(
return (
<pre
ref={ref}
className={cn('size-full *:block *:w-full', className)}
className={cn('min-w-full w-max *:flex *:flex-col', className)}
{...props}
>
{props.children}
@@ -134,7 +134,7 @@ export const CodeBlock = forwardRef<HTMLElement, CodeBlockProps>(
ref={areaRef}
{...viewportProps}
className={cn(
'text-[13px] py-3.5 overflow-auto [&_.line]:px-4 max-h-[600px] [scrollbar-width:thin]',
'text-[13px] py-3.5 overflow-auto [&_.line]:px-4 max-h-[600px] fd-scroll-container',
props['data-line-numbers'] && '[&_.line]:pl-3',
viewportProps?.className,
)}