fateh999 / react-native-paper-dropdown

Dropdown using react native paper TextInput and Menu
MIT License
130 stars 74 forks source link

Styling Menu.Item props #18

Closed zirlman closed 3 years ago

zirlman commented 3 years ago

How can I change the style props of Menu/

image

Code:


export type DropdownItem = {
  label: string;
  value: string;
};
type DropdownProps = {
  label: string;
  items: DropdownItem[];
};
const Dropdown: FC<DropdownProps> = ({label, items}) => {
  const [open, setOpen] = useState(false);
  const [value, setValue] = useState(items?.[0].value ?? '');

  return (
    <Provider>
      <SafeAreaView style={style.containerStyle}>
        <DropDown
          label={label}
          mode={'outlined'}
          value={value}
          setValue={val => setValue(val.toString())}
          list={items}
          showDropDown={() => setOpen(true)}
          onDismiss={() => setOpen(false)}
          visible={open}
          inputProps={{
            right: <TextInput.Icon name={'menu-down'} />,
          }}
          theme={dropdownInputTheme}
          dropDownStyle={style.dropdownStyle}
          dropDownItemStyle={style.dropdownItemStyle}
        />
      </SafeAreaView>
    </Provider>
  );
};

const selectionColor = '#DD622B';
const dropdownInputTheme = {
  ...DefaultTheme,
  roundness: 2,
  dark: false,

  colors: {
    ...DefaultTheme.colors,
    primary: selectionColor,
  },
};
const style = StyleSheet.create({
  containerStyle: {
    marginHorizontal: 20,
  },
  dropdownStyle: {
    backgroundColor: 'red',
    padding: 10,
  },

  dropdownItemStyle: {
    // padding: 20,
    backgroundColor: 'white',
    borderColor: 'blue',

    // marginVertical: -8,
  },
});
fateh999 commented 3 years ago

Will be fixing in next update

fateh999 commented 3 years ago

I have upgraded the library and added new props to handle these cases.