3

I'm working with Chakra UI and i needed to customize the scrollbar style using the css pseudo element ::-webkit-scrollbar, but Chakra UI doesn't seen to have this pseudo element and a I don't know where I can style this specific component without creating a global css class.

Here is a sample of my code:

<Box
  overflowX="auto"
  maxW="100vw"
  h="100%"
  whiteSpace="nowrap"
  pb="17px"
  color="white"
  px="32px"
  // the ::-webkit-scrollbar property should goes here
>
  <!-- content -->
</Box>

2 Answers2

6

Try css prop:

<Box
  overflowY="auto"
  css={{
    '&::-webkit-scrollbar': {
      width: '4px',
    },
    '&::-webkit-scrollbar-track': {
      width: '6px',
    },
    '&::-webkit-scrollbar-thumb': {
      background: scrollbarColor,
      borderRadius: '24px',
    },
  }}
>
nbsp
  • 118
  • 6
  • Do you know how to add `::-webkit-scrollbar-thumb:horizontal`, cannot figure out what rules chakra is using internally for pseudo css. – Yunhai Mar 09 '21 at 05:05
-1

I'm not sure if this will work but I've customize a Link like this.

import {
 
  Link,
  
} from "@chakra-ui/core";

 <Link key={link} 
       style={{ textDecoration: 'none' }} 
       mr={6} 
       href={link} 
       size="16px">
       {title}
 </Link>

user1256378
  • 663
  • 2
  • 12
  • 29