No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Q-Avatar add custom icon color from a variable (Solved)

    Help
    2
    7
    1094
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mboeni
      mboeni last edited by mboeni

      hey there

      Quick question. I would like to bind a variable to the text-color attribute of Q-Avatar like so:

      <q-avatar :text-color="{accent}" icon="home" size="48px" />
      

      But that does not do anything. How do I make this work?

      Cheers,
      M.

      1 Reply Last reply Reply Quote 0
      • metalsadman
        metalsadman last edited by

        Remove the braces

        mboeni 1 Reply Last reply Reply Quote 0
        • mboeni
          mboeni @metalsadman last edited by

          @metalsadman I tried that, the color of the icon is still not affected. I have the impression that does not work at all and the framework falls back to a ‘default’ color or something.

          1 Reply Last reply Reply Quote 0
          • metalsadman
            metalsadman last edited by metalsadman

            when you say ‘variable’ did you mean a css variable or a reactive data? because it’s working fine here https://codepen.io/metalsadman/pen/rNNbYYg. anyway if you want a custom color, you can just use css class / style with color: <somecolor>.

            mboeni 1 Reply Last reply Reply Quote 0
            • mboeni
              mboeni @metalsadman last edited by mboeni

              @metalsadman I’m doing this:

              Vue.prototype.$textColor1 = '#6A7C89'
              

              and would, in the final solution, use it like this:

              <q-avatar :text-color="$textColor1" icon="home" size="48px" />
              

              is this a correct approach?

              I was using ‘accent’ to test if it works with the built-in brand colors.

              1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman last edited by metalsadman

                @mboeni it works with brand colors and quasar colors from https://quasar.dev/style/color-palette#Color-List. since you are using a hex, better use style binding. ie :style="{ color: $textColor1 }". https://codepen.io/metalsadman/pen/rNNbYYg

                mboeni 1 Reply Last reply Reply Quote 0
                • mboeni
                  mboeni @metalsadman last edited by

                  @metalsadman yep, that solved it. It works now as expected! Thanks :)`

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post