AdelRedaa97 / react-native-select-dropdown

react-native-select-dropdown is a highly customized dropdown | select | picker | menu for react native that works for andriod and iOS platforms.
MIT License
325 stars 142 forks source link

Button text goes out of boundary when aligning it to the left #10

Closed alessandrocapra closed 2 years ago

alessandrocapra commented 3 years ago

Steps to reproduce

Assign textAlign: "left" to buttonTextStyle.

image

AdelRedaa97 commented 3 years ago

Could you share code

alessandrocapra commented 3 years ago

FYI: I am using Native Base as UI library, that might be useful.

<View
              style={{
                marginTop: 8,
                flexDirection: "row",
                justifyContent: "space-between",
              }}
            >
              <SelectDropdown
                data={["Market order", "Limit order"]}
                onSelect={(selectedItem) => {
                  setOrderType(selectedItem);
                }}
                defaultButtonText={"Order type"}
                buttonTextAfterSelection={(selectedItem) => {
                  return selectedItem;
                }}
                rowTextForSelection={(item, index) => {
                  return item;
                }}
                buttonStyle={styles.selectBtn}
                buttonTextStyle={styles.selectBtnText}
                renderDropdownIcon={() => {
                  return <Icon name="caret-down-outline" />;
                }}
                dropdownIconPosition={"right"}
                rowStyle={{ backgroundColor: "#ccc" }}
              />
              <SelectDropdown
                data={["Day order", "GTC "]}
                onSelect={(selectedItem) => {
                  setOrderDuration(selectedItem);
                }}
                defaultButtonText={"Order duration"}
                buttonTextAfterSelection={(selectedItem) => {
                  return selectedItem;
                }}
                rowTextForSelection={(item, index) => {
                  return item;
                }}
                buttonStyle={styles.selectBtn}
                buttonTextStyle={styles.selectBtnText}
                renderDropdownIcon={() => {
                  return <Icon name="caret-down-outline" />;
                }}
                dropdownIconPosition={"right"}
                rowStyle={{ backgroundColor: "#ccc" }}
              />
            </View> 

and the styles are:

const styles = StyleSheet.create({
  noLeftMargin: {
    marginLeft: 0,
  },
  selectBtn: {
    flexBasis: "48%",
    height: 72,
    borderRadius: 4,
    backgroundColor: "rgba(255,255,255,0.15)",
    borderBottomWidth: 1,
    borderBottomColor: "#fff",
  },
  selectBtnText: { color: "#fff", textAlign: "center", fontSize: 17 },
});
aryalprakash commented 3 years ago

I got it working by setting height in buttonTextStyle.