Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent input from changing line height and content width #63

Closed
Radivarig opened this issue Jul 30, 2016 · 1 comment
Closed

Prevent input from changing line height and content width #63

Radivarig opened this issue Jul 30, 2016 · 1 comment

Comments

@Radivarig
Copy link

I'd like to create an input that is visually equivalent to a span with different background color, meaning it does not change the line height or is wider than the span with exactly the same text.

This is my attempt, works for the above but is not ideal.

    const style = {
      fontFamily: 'inherit',
      fontSize: 'inherit',
      height: '1em',
      lineHeight: '1em',
      border: '1px',
      borderColor: '#DDF',
      borderStyle: 'solid solid solid none',
      margin: '0px 0px 0px 0px',
      padding: '0px 0px 0.15em 0px',
      minWidth: 30 > width ? 30 : width,
      width: inputText != '' ? inputWidth : width,
      backgroundColor: '#EEF',
      display: 'inline-block',
      whiteSpace: 'nowrap',
    }
...
        <div
          contentEditable
          style={style}
          value={inputText}
          onChange={this.handleOnChange}
          onKeyPress={(e) => {if(e.which == 13) e.preventDefault()}}
        />

Any way to achieve the same with react-input-autosize?

@JedWatson
Copy link
Owner

Theoretically yes, you could, with the right styles attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants