question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to override input style

See original GitHub issue

Describe the bug
Unable to override the style of the element inside the container view.

To Reproduce
Steps to reproduce the behavior:

  1. Load the picker component in a blank app.
  2. Fill all required attributes for the component with the once similar to the main example.
  3. Add a style attribute and add the following value to it:
const style = {
   inputAndroid: {
      padding: 0,
      paddingTop: 0,
      paddingBottom: 0,
      paddingLeft: 0,
      paddingRight: 0,
      paddingVertical: 0,
      paddingHorizontal: 0,
   },
   inputIOS: {
      padding: 0,
      paddingTop: 0,
      paddingBottom: 0,
      paddingLeft: 0,
      paddingRight: 0,
      paddingVertical: 0,
      paddingHorizontal: 0,
   },

};
  1. The padding is still visible.

Expected behavior
The padding is removed, styles are applied.

Screenshots
Result, nothing changed: basically a standard select

Additional details

  • Device: Pixel 2
  • OS: 10.0 (Q) - API 29
  • react-native-picker-select version: 7.0.0
  • react-native version: 37.0.1
  • react version: 16.9

Code sample

import React from 'react';
import RNPickerSelect from 'react-native-picker-select';

export default class App extends React.Component {
  render() {
    return (
      <RNPickerSelect
        style={style}
        onValueChange={(value) => console.log(value)}
        items={[
          { label: 'Football', value: 'football' },
          { label: 'Baseball', value: 'baseball' },
          { label: 'Hockey', value: 'hockey' },
        ]} />
      );
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Fleuvcommented, May 26, 2020

For android it seems to be possible to get it some kind of working with the attribute useNativeAndroidPickerStyle set to false. Then you can set the the style under the inputAndroid attribute.

However this removes the arrow icon on the right.

1reaction
lfkwtzcommented, Jun 30, 2020

looks like this was solved. unless you set useNativeAndroidPickerStyle={false} or use the android headless mode, you’re dealing with the native android picker and styling is limited

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't override defined styles on input elements in CSS
I want to make a input element of a specific width in px. Unfortunately, there's a file that I can't edit which sets...
Read more >
You can't override !important user agent CSS declarations
You can override user agent stylesheet declarations with your author styles. And indeed, you do that every day when you write your CSS....
Read more >
autofill
The :auto-fill pseudo-class in CSS allows us to style <input> elements ... overriding those styles is something we are unable to do in...
Read more >
Specificity - CSS: Cascading Style Sheets - MDN Web Docs
Create a separate, short style sheet containing only important declarations specifically overriding any important declarations you were unable ...
Read more >
How to Override CSS Styles
It means that if you have an element with a class and ID selector with different styles, it is the ID style that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found