如何使用ReactJS + Chakra UI修改滚动条?

huangapple go评论71阅读模式
英文:

How can I modify the scrollbar with ReactJS + Chakra UI?

问题

I'm trying to modify the style of my scrollbar but I can't get it.

I have tried with the parameters: css, __css, and sx.

Example:

             __css={{
                '&::-webkit-scrollbar': {
                    width: '2px',
                },
                '&::-webkit-scrollbar-track': {
                    boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
                    webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
                    width: '2px',
                },
                '&::-webkit-scrollbar-thumb': {
                    backgroundColor: 'rgba(0,0,0,.1)',
                    outline: '1px solid slategrey',
                    borderRadius: '24px',
                },
            }}

As seen on:
https://stackoverflow.com/questions/65042380/how-to-add-webkit-scrollbar-pseudo-element-in-chakra-ui-element-react

英文:

I'm trying to modify the style of my scrollbar but I can't get it.

I have tried with the parameters: css, __css and sx.

Example:

             __css={{
                '&::-webkit-scrollbar': {
                    width: '2px',
                },
                '&::-webkit-scrollbar-track': {
                    boxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
                    webkitBoxShadow: 'inset 0 0 6px rgba(0,0,0,0.00)',
                    width: '2px',
                },
                '&::-webkit-scrollbar-thumb': {
                    backgroundColor: 'rgba(0,0,0,.1)',
                    outline: '1px solid slategrey',
                    borderRadius: '24px',
                },
            }}

As see on:
https://stackoverflow.com/questions/65042380/how-to-add-webkit-scrollbar-pseudo-element-in-chakra-ui-element-react

答案1

得分: 0

以下是您要翻译的代码部分:

* {
  scrollbar-width: thin;
  scrollbar-color: transparent var(--primary);
}

*::-webkit-scrollbar {
  width: 5px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: 0;
  border: none;
}

您可以在https://css-tricks.com/almanac/properties/s/scrollbar/上查看更多选项。

英文:

Best way I use for basic customization, put the following code inside a .css or .scss or .sass file:

* {
  scrollbar-width: thin;
  scrollbar-color: transparent var(--primary);
}

*::-webkit-scrollbar {
  width: 5px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--primary);
  border-radius: 0;
  border: none;
}

You can check for more options at https://css-tricks.com/almanac/properties/s/scrollbar/

huangapple
  • 本文由 发表于 2023年2月9日 03:01:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390536.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定