Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to remove padding-top in menu drop-down react-select?

how to remove padding-top in menu drop-down react-select?

const customStyles = {

    indicatorSeparator: styles => ({ ...styles, display: "none" }),
    option: (provided, state) => ({
      ...provided,
      fontSize: 16,

        height:"40px",
      paddingLeft: "11px",
      ":firstChild": {
        margin: "10px",
        padding: "10px",
        borderRadius: "10px 10px 10px 10px"

    }),



 <Select
    styles={customStyles}
    defaultValue={[colourOptions[2], colourOptions[3]]}
    isMulti
    name="colors"
    options={colourOptions}
    className="basic-multi-select"
    classNamePrefix="select"
  />

enter image description here https://codesandbox.io/s/react-codesandboxer-example-90zz6

like image 698
recile Avatar asked Jun 08 '26 08:06

recile


2 Answers

The default margin-top between the menu list and the select box can be removed easily with the props styles like this:

const styles = {
  menu: base => ({
    ...base,
    marginTop: 0
  })
}

Live example here.

like image 132
Laura Avatar answered Jun 10 '26 19:06

Laura


You should set the styles for the menuList style key according to react-select docs.

menuList: (provided, state) => ({
   ...provided,
   paddingTop: 0,
   paddingBottom: 0,
}),
like image 24
Armin Bu Avatar answered Jun 10 '26 19:06

Armin Bu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!