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

    Use hex value to set Toggle color?

    Help
    components toggle
    4
    6
    1080
    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.
    • A
      argonaut76 last edited by

      Is it possible to use a hex value to set the color of a Toggle? For example:

      <q-toggle
         color="#575757"
         keep-color
         ...
      >
      

      The docs suggest you can only use names from the Quasar color palette, but this seems like it should be possible. Thanks for any and all help!

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Yes, you can, if you define the color in the CSS: https://codepen.io/smolinari/pen/abOObbq

        Scott

        1 Reply Last reply Reply Quote 2
        • A
          argonaut76 last edited by

          Oh, that’s awesome and super simple. Thanks Scott!

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            Don’t forget, if you are going to use the color across your app, you can also define it in your global custom css (i.e. in the app.sass, app.scss or app.styl files in the /css folder). And, you can define your own Q css variables in the quasar.variables.sass, quasar.variables.scss or quasar.variables.style file too.

            Scott

            1 Reply Last reply Reply Quote 0
            • D
              Dapeng last edited by

              In my case, the colors (hex value) are calculated so it is difficult to use the method recommended by @s-molinari. Is there any way to set the color that is hex value calculated? It would be good to have property color recognize hex value directly or have new property for hex color.

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

                @Dapeng try to look into color utils https://quasar.dev/quasar-utils/color-utils

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