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

    Replace material icon with my own custom icon

    Help
    css custom icon icons scss
    3
    5
    947
    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
      acros last edited by

      Im using the table component:
      https://quasar.dev/vue-components/table

      but want to replace the icon with my own custom icons. In chrome inspector it says for example:

      <i aria-hidden="true" role="img" class="material-icons q-icon notranslate">chevron_left</i>
      

      How can I replace this “chevron_left” with “mycustomimg.png”

      This works but seems like a bit of a hack more than a proper solution:

      framework: {
            iconSet: 'fontawesome-v5',
      

      leaving this result:

      <i aria-hidden="true" role="img" class="fas fa-chevron-left q-icon notranslate"> </i>
      

      and then change the css

      .fa-chevron-left:before{
          background-image:url("../assets/icon_back.png");
          background-size: 10px 10px;
          display: inline-block;
          width: 10px; 
          height: 10px;
          content:"";
      }
      

      How is the proper way of doing this?

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

        @acros Read up on it here: https://quasar.dev/vue-components/icon#Custom-mapping

        A 1 Reply Last reply Reply Quote 0
        • A
          acros last edited by

          Thanks. Yes I saw that page but as far as I understand I cannot reach and modify the class that calls the icon that easy since it is inside the component. Im pretty new to quasar after using vue but its not obvious to me how to reach the classes inside the component. In my case I obviously want to replace this:

          <i aria-hidden="true" role="img" class="material-icons q-icon notranslate">chevron_left</i>
          

          with something like this:

          <i aria-hidden="true" role="img" class="my-custom-icon"> </i>
          
          .my-custom-icon {
              background-image:url("../assets/icon_back.png");
              background-size: 10px 10px;
              display: inline-block;
              width: 10px; 
              height: 10px;
          }
          

          but cannot really see how this will be done except for the solution I already tried. It seems like a bit of a hack though to me … or is maybe something like this fine where Im simply overriding the css with my own using fontawsome-v5

          <i aria-hidden="true" role="img" class="fas fa-chevron-left q-icon notranslate"> </i>
          

          and

          .fa-chevron-right {
              background-image:url("../assets/quasar-logo-full.svg");
              background-size: 10px 10px;
              display: inline-block;
              width: 10px; 
              height: 10px;
          }
          

          This do work but again seems like a hacky solution?

          1 Reply Last reply Reply Quote 0
          • A
            acros @Hawkeye64 last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • T
              tozuo last edited by tozuo

              @acros, as @Hawkeye64 mentioned - in my case it’s [ in App.vue ]

                created () {
                  this.$q.iconMapFn = (iconName) => {
                    if (iconName.startsWith('chevron_left') === true) {
                      return { cls: 'fal fa-chevron-left' }
                    }
                    if (iconName.startsWith('chevron_right') === true) {
                      return { cls: 'fal fa-chevron-right' }
                    }
                  }
                },
              
              1 Reply Last reply Reply Quote 1
              • First post
                Last post