简体   繁体   中英

Changing the height of a react-select component

I have a relatively straight forward question. When I try to modify the height of a react-select it messes up the position of the internal text. It doesn't appear their styles api lets me dig any deeper into control so I'm not sure how to fix this.

Edit: I'd like to keep the padding.

CodeSandbox: example of my question

在此处输入图片说明

import React from "react";
import Select from "react-select";

const customStyles = {
  control: provided => {
    return {
      ...provided,
      width: "100%",
      padding: "10px 12px",
      height: "20px"
    };
  }
};

export default () => <Select styles={customStyles} />;

所以你只需要移除填充物,它应该被修复。

This should work for you:

import React from "react";
import Select from "react-select";

const customStyles = {
  control: provided => {
    return {
      ...provided,
      width: "100%",
      padding: "0px 12px",
      height: "20px"
    };
  }
};

export default () => <Select styles={customStyles} />;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM