Skip to content

Style menu based on menuPlacement when it is set to auto #5811

Answered by manjushsh
erdbom asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @erdbom, yes we can detect it using combination of menuPlacement or state.selectProps.menuPlacement and placement props. as shown in image below.

👉🏼 Code Sandbox link

Example code:

menu: (provided, state) => ({
    ...provided,
    ...(state.selectProps.menuPlacement === "auto"
      ? state?.placement === "top"
        ? { outline: "2px solid red" }
        : { outline: "2px solid green" }
      : {})
  }),

Replies: 1 comment 1 reply

Comment options

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

Answer selected by erdbom
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