How to change text color and height of <input> in <q-input>?

  • Noob here trying to apply some CSS to the <input> element inside a
    <q-input> element.

    By adding:

    <style lang="stylus" scoped>
      text-align right
      height 32px
      color purple

    to the element containing the <q-input> element, I manage to move the entered input text to the right. But it does not alter neither the color of the input value nor the height of the input field to accommodate for the large font size inherited from the parent component without cropping it.

    What I am doing wrong?

    And also what is this sp unit used in the typography section of the Quasar doc? I don’t find it the w3school CSS reference

  • @damiendeville Partial self-answer here. I almost managed to customize the q-input component styling to my local needs with the following code:

    <style lang="stylus">
      height 2.5em
      text-align right
      color orangeRed
      height 1em
      color purple
      text-align right 

    However, I still do not understand why I needed to add the [type=“number”] to the input selector to access the input element inside the q-input element.

    But this code is not really legible, since neither the q-if-label component nor the input elements encapsulated in the q-input element appear in the vue template that this stylus code is styling. Is there any way to customize the appearance of a quasar component other than selecting in stylus sub-components and sub-elements internal to the component hence in effect breaking its encapsulation and making the code incomprehensible without inspecting the component 's internal DOM with a browser debugger?

    Also, I tried to add an ellipsis to the placeholder and the following code just didn’t have any effect:

      text-overflow ellipsis

    Any suggestion on this one?

  • I’ve found the solution, and this works for every css class with Quasar:
    1- Discover “what class to rewrite”
    2- app.styl:

    // Q-INPUT
    .q-input-target, .q-input-shadow
      color $brown-base

Log in to reply