Ion-icon not visible on ion-fab-button

I am building a simple map app with Vue, Leaflet and Ionic. I want to have a fixed button with an icon on it. I am using ion-fab in combination with ion-icon. But whatever I try, the icon is not visible on the button. Hope someone can tell me what I am doing wrong.

The vue component (Menubar.vue):

<template >
  <!-- fab placed to the top end -->
  <ion-fab vertical="top" slot="fixed">
    <ion-fab-button>
      <ion-icon name="add"></ion-icon>
    </ion-fab-button>  
  </ion-fab>
</template>

<script>
import { IonFab, IonFabButton, IonIcon } from "@ionic/vue";
import { eventHub } from "../main";
import { add } from "ionicons/icons";


export default {
  components: {
    IonFab,
    IonFabButton,
    IonIcon,
  },

  methods: {
    reCenter() {
      console.log("Emitted reCenter");
      eventHub.emit("reCenter");
    },

    startAdd() {
      console.log("Emitted startAdd");
      eventHub.emit("startAdd");
    },
  },

  setup() {
    return {
      add,
    };
  },
};
</script>

My App.vue:

<template>
  <ion-app>
    <ion-content>
    
    <!-- <ion-router-outlet /> -->
    <front-page :bankjes="bankjes" v-if="dataReceived"></front-page>

    <menu-bar />
    </ion-content>
  </ion-app>
</template>

<script >
// import { IonApp, IonRouterOutlet } from '@ionic/vue';
import { IonApp,IonContent } from "@ionic/vue";
import { defineComponent } from "vue";
import FrontPage from "./components/FrontPage";
import MenuBar from "./components/MenuBar.vue";


const axios = require("axios");

export default defineComponent({
  name: "App",
  components: {
    IonApp,
    // IonRouterOutlet,
    FrontPage,
    MenuBar,
    IonContent
  },
  
  data() {
    return {
      bankjes: null,
      dataReceived: false,
    };
  },

  mounted() {
    this.refreshDataFromServer();
  },

  methods: {
    refreshDataFromServer() {
      axios.get("http://localhost:3000/bankjes").then((response) => {
        this.bankjes = response.data;
        this.dataReceived = true;
      });
    },
  },
});
</script>

Meanwhile I found the solution.

Instead of using

<ion-icon name="add">

I have to use

<ion-icon :icon="add">

Even though the Ionic documentation for IonFab says to do the first!

<ion-icon :icon="add"> is the correct usage. This is documented in the quickstart guide (Ionic Vue Quickstart - Ionic Documentation), but looks like we did not update the ion-fab example to document the correct ion-icon usage. I will put up a PR to fix this. Thanks!

edit: PR is up: docs(fab): document correct ion-icon usage for vue by liamdebeasi · Pull Request #23352 · ionic-team/ionic-framework · GitHub

Hi,
It’s August 22, and the vue docs are still incorrect:

Come on guys

Andy

Hi @andrewpnlp3,

The documentation inaccuracy has been fixed: ion-button: Design and Style Buttons with Custom CSS Properties

If you find any other any other typos in the docs, definitely feel free to open issues or PRs on GitHub - ionic-team/ionic-docs.

1 Like