score:4

in this little snippet: ${props => props.width ? width : 'auto'}, you forget that width is on the props-object. to fix it:

${props => props.width ? props.width : 'auto'}

you can see my working example below:

const uiinput = styled.input`
  padding: 5px;
  width: ${props => props.width ? props.width : 'auto'}
`

reactdom.render(
  <div>
    <div>
      <p>300px</p>
      <uiinput width="300px" />
    </div>
    <div>
      <p>80%</p>
      <uiinput width="80%"/>
    </div>
  </div>,
  document.getelementbyid('root'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/styled-components/dist/styled-components.min.js"></script>

<div id="root"></div>


Related Query

More Query from same tag