• Onsen UI

    An input element. The type attribute can be used to change the input type. All text input types as well as checkbox and radio are supported. The component will automatically render as a Material Design input on Android devices. Most attributes that can be used for a normal <input> element can also be used on this element.

    Click here to see the original article

  • How can I change the width of Input text?

  • Onsen UI

    @Liu-Xiao Apply the style you want. style={{width: '90%'}}

  • Onsen UI

    @Liu-Xiao you can just target your element with regular CSS. What’s the problem you’re having specifically?

  • How can I enable multi-line text input?

  • Onsen UI

    @Nguyen-Truc-Minh There is some CSS for textarea element.

  • @Fran Diox: Thank you, but that textarea css is not consitent with meterial style so I created new component my self at

  • Most attributes that can be used for a normal <input> element can also be used on the <ons-input> element…

    This means I can set id and name attributes for <Input>, right?

  • @samphan Yes.

  • document.getElementById('id') doesn’t work when the inputId is set. (The inputId works indeed.)
    Could anyone tell me why and how to solve this… thx

    Here is my code:

    export default class InputDemo extends Component {
      componentDidMount() {
        console.log(document.getElementById(('input1')));// null
      render() {
              <Input inputId="input1" />

    The interesting thing is that i can get this work by typing document.getElementById(('input1') in the browser console.
    So i guess the id is set after componentDidMount…? So strange…

  • @songkeys:
    Additionally, the reason why i try to target the inner <input> element is that i wanna set the font-size in the input box.
    You can try to specify the fontSize css on the <Input> element. The wrapper changes its size but the inner text doesn’t…

  • Onsen UI

    @Songkeys not sure why but it seems like the DOM is not ready in your componentDidMount hook, can you try doing the same log on click of a button? I will have a look later at why that is happening, in principle I think it should work like you did

  • Onsen UI

    It’s probably better if you just apply it as a CSS class: .myClass input { font-size: ... } or #input1 { ... }.

Log in to reply