38

This results in an underlined link:

<li><router-link to="/hello">Hello</router-link></li>

My understanding is that the router-link element generates an a tag.

I've tried these things in the CSS:

router-link{
    text-decoration: none;
}

router-link a{
    text-decoration: none;
}

router-link a{
    text-decoration: none !important;
}

..but unfortunately none of these work.

rpivovar
  • 3,150
  • 13
  • 41
  • 79

10 Answers10

44

If anyone using Vuetify comes across this question, note that the styling below do not work due to Vuetify's in built styles. You must instead use inline CSS styling:

<router-link
 style="text-decoration: none; color: inherit;"
 to="/hello">
Winters
  • 980
  • 3
  • 11
  • 16
29

It is Converted into <a ...
So to remove the underline try this

a { text-decoration: none; }
live2
  • 3,771
  • 2
  • 37
  • 46
JPilson
  • 1,075
  • 11
  • 10
23

You can try targeting the list item link like this:

li a {
    text-decoration: none;
}
Derek Pollard
  • 6,953
  • 6
  • 39
  • 59
Emma Earl Kent
  • 498
  • 5
  • 12
15

Vue component tags don't generate HTML tags.
Look in the DOM inspector to see what HTML tags actually exist.

You need to use regular classnames.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 6
    Ah, I see what you're talking about. The `router-link` turns into an `a`. `li a { }` in CSS seems to work. Thanks. – rpivovar Jun 28 '17 at 16:57
14

You can use the tag prop of router link to use the li css class like this:

<li><router-link tag="li" to="/hello">Hello</router-link></li>

The link will now use li css propertys but still work as like a normal router link.

alexcodes
  • 404
  • 3
  • 11
9

Add a class to router-link tag:

<router-link class="routerLink" to="/hello">Hello</router-link>

Then give css to the class:

.routerLink{
     text-decoration: none;
 }

This should work :)

Nobin Jacob
  • 91
  • 2
  • 3
2

SCSS

div /deep/ .v-list a {
    text-decoration: none;
}

CSS

div >>> .v-list a{
    text-decoration: none;
}
2

Even in React-Router. The Link tag makes the text underlined. Because any text (h1, h3, p) inside tag are converted to anchor tags so:

a{text-decoration: none;}
amit.exe
  • 81
  • 1
  • 2
0

Although this answer seems quite obvious. I think my colleagues above forgot to mention that if you are using vuetify with the Laravel framework this problem can be solved as follows. Access:

resources\sass\app.scss file

And comment out the line:

@import '~bootstrap/scss/bootstrap';

This usually resolves this type of problem, which is actually a library conflict.

0

If you are using Boostrap 5 you can use the class text-decoration-none

<router-link href="yourlink" class="text-decoration-none" >

</router-link>

see bootsrap documentation for reference. Just an additional information I am using Vue3 in my application

Dharman
  • 30,962
  • 25
  • 85
  • 135