Skip to content
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

Add 'no-underline' mixin and modifier class for links #2189

Closed
Tracked by #2197
36degrees opened this issue Apr 13, 2021 · 0 comments · Fixed by #2214
Closed
Tracked by #2197

Add 'no-underline' mixin and modifier class for links #2189

36degrees opened this issue Apr 13, 2021 · 0 comments · Fixed by #2214
Assignees
Labels
🕔 hours A well understood issue which we expect to take less than a day to resolve. typography
Milestone

Comments

@36degrees
Copy link
Contributor

36degrees commented Apr 13, 2021

Related component

Add 'no-underline' mixin and modifier class for links.

Context

With the new link styles and hover states being introduced in #2183, there's a little extra complexity where underlines are removed from links.

This is because users will often achieve this by setting text-decoration: none, like this:

.app-link-without-underline:link {
  text-decoration: none;
}

.app-link-without-underline:hover {
  text-decoration: underline;
}

(For example, we've done this ourselves for links in the Design System that do not have underlines)

Because text-decoration is a shorthand property, setting it to none sets all unspecified values back to their initial value. This means that text-decoration-thickness gets set back to auto and as a result when hovered the underline that appears is not thicker like it is on other links – at least for browsers that include text-decoration-thickness in the shorthand property, which I think is every browser that supports text-decoration-thickness except Safari.

Instead, we need to just set the 'longhand' text-decoration-line property – and then also take care of the focus style:

.app-link-without-underline:link {
  text-decoration-line: none;
}

.app-link-without-underline:hover {
  text-decoration-line: underline;
}

.app-link-without-underline:focus {
  text-decoration: none;
}

EDIT: ^ that approach doesn't work in IE11, but instead we can do:

  &:not(:hover):not(:active) {
    text-decoration: none;
  }

Given this is quite nuanced, it would make sense to provide a mixin and a modifier class that handles this for the user. We should also document the new class with an example in the Design System – probably under 'Links without underlines'.

Alternatives

We could rely on users implementing this themselves, but it seems likely for example ensuring the correct underline thickness and ensuring the focus state are correct might be missed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕔 hours A well understood issue which we expect to take less than a day to resolve. typography
Projects
Development

Successfully merging a pull request may close this issue.

1 participant