Skip to content

How to replicate group sticky header? #343

Answered by csandman
tsuharesu asked this question in Q&A
Discussion options

You must be logged in to vote

Yeah this is pretty straightforward to add with the chakraStyles prop! That was the main reason it was removed, it's very simple to add as an end-user, and it's not really replicating something from React Select or Chakra.

Here's an example of how you can add it with just a few custom styles:

const App = () => (
  <Select
    chakraStyles={{
      groupHeading: (base) => ({
        ...base,
        borderBottomWidth: 1,
        position: 'sticky',
        top: -2,
        bg: 'white', // Make this match whatever the background color of your modal is
        zIndex: 1,
      }),
    }}
  />
)

Here's a complete example: https://stackblitz.com/edit/vitejs-vite-ngfuyh?file=src%2Fapp.tsx

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tsuharesu
Comment options

Answer selected by tsuharesu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants