Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Add support for vue-router #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mghmay opened this issue Mar 11, 2024 · 2 comments
Closed

Add support for vue-router #285

mghmay opened this issue Mar 11, 2024 · 2 comments

Comments

@mghmay
Copy link

mghmay commented Mar 11, 2024

I'd like to clarify the status of vue-router and coreui.

According to this thread it hasn't been implemented: #177

But according to the documentation we can turn a link into a router link by passing the to prop: https://coreui.io/vue/docs/3.2/components/link.html#router-link-props

I'm currently trying to get coreui to work with vue-router and as far as I can tell this currently isn't working. It would be very useful to pass a route using a to prop, it would make the code a lot neater too.

Failing that could the documentation be updated? Perhaps with detailed instructions about how to use router-link with coreui.

@alienforhumans
Copy link

Hi, as I see in CoreUI v4 code it is still impossible. You can use something like:

<template>
  <CSidebar unfoldable>
    <CSidebarNav>
      <CNavItem>
        <router-link
          class="nav-link"
          to="/"
        >
          <CIcon  customClassName="nav-icon" :icon="cilSpeedometer"/> Dashboard
        </router-link>
      </CNavItem>
    </CSidebarNav>
  </CSidebar>
</template>

It is important not to pass the "href" attribute for the navigation element.

@mrholek
Copy link
Member

mrholek commented May 4, 2024

@mghmay @alienforhumans you can also try something like this

<CSidebar>
  <CSidebarNav>
    <router-link v-slot="{ href, navigate, isActive }" to="./compose" custom>
      <CNavItem :active="isActive" :href="href" @click="navigate">
        <CIcon custom-class-name="nav-icon" icon="cil-pencil" />
        Compose
      </CNavItem>
    </router-link>
    <router-link v-slot="{ href, navigate, isActive }" to="./inbox" custom>
      <CNavItem :active="isActive" :href="href" @click="navigate">
        <CIcon custom-class-name="nav-icon" icon="cil-inbox" />
        Inbox
        <CBadge class="ms-auto" color="danger">4</CBadge>
      </CNavItem>
    </router-link>
</CSidebar>

@coreui coreui locked and limited conversation to collaborators May 17, 2024
@mrholek mrholek converted this issue into discussion #288 May 17, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants