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 option for separate link colours #1583

Closed
3 tasks done
Andre601 opened this issue Apr 10, 2020 · 10 comments
Closed
3 tasks done

Add option for separate link colours #1583

Andre601 opened this issue Apr 10, 2020 · 10 comments
Labels
change request Issue requests a new feature or improvement

Comments

@Andre601
Copy link
Contributor

Andre601 commented Apr 10, 2020

I checked that...

  • ... the documentation does not mention anything about my idea
  • ... to my best knowledge, my idea wouldn't break something for other users
  • ... there are no open or closed issues that are related to my idea

Description

It would be a nice addition to have two options to set a different colour for links and when hovering over them.
The available colours could just be the one already provided and it could default to either the primary or accent colour depending on what option is missing or invalid.

The reason is simple: Readability.
Depending on what colour theme (background colour) and primary/accent colours you have set are links barely readable.
This is especially the case when using links in inline code, as - depending on your modifications - the text becomes barely distinguishable from the code background.

I f.e. want to use indigo as primary colour, but due to me using css for having a dark theme is the link colour barely readable on inline code, forcing me to either customize the CSS (Which I'm not good at) or switch to a different, much brighter colour which I wouldn't like to do.

Use Cases

The aforementioned cases would apply here and I'm sure people would love to have a colour for links, different to the primary and accent colour set.

Screenshots / Mockups

Colour indigo while using a dark theme:
image

Colour yellow without any custom CSS:
image

@squidfunk squidfunk added the change request Issue requests a new feature or improvement label Apr 10, 2020
@squidfunk
Copy link
Owner

This topic can (and will) be revisited when implementing dark mode, as some more variables/branches could be necessary.

@squidfunk
Copy link
Owner

Added in 1fc6af1#diff-84f37ad4f75d6bdb8cc32a1b513f5e65R65 as part of the dark mode branch.

@squidfunk squidfunk added the resolved Issue is resolved, yet unreleased if open label May 16, 2020
@squidfunk
Copy link
Owner

Released as part of 5.2.0! You can now set the link color with --md-text-link-color.

@Andre601
Copy link
Contributor Author

Would this be set within custom css?

@facelessuser
Copy link
Contributor

Yes, it is a CSS variable.

@squidfunk squidfunk removed the resolved Issue is resolved, yet unreleased if open label May 18, 2020
@Andre601
Copy link
Contributor Author

Andre601 commented May 18, 2020

I'm not quite sure how I would now implement this (I honestly assumed this to become an option in the mkdocs.yml)

Like what css would I have to add/alter in order to display the link as a bright blue (cyan?) and make it brighter when hovering over it?

@squidfunk
Copy link
Owner

we might add a tutorial on this in the future, but I currently don’t have the time to write one. There might also be some guidance on the tutorials branch, see open PRs. The issue itself is fixed, as the variable is now defined.

@Andre601
Copy link
Contributor Author

I tried to add it now, but still are lost

What I tried:

body {
  --md-text-link-color: #3498db;
}

The above doesn't work. I did add it as extra_css and there's no other css files that would alter colors on any way.
I use css and not scss, so it might by a syntax issue?
From my basic css knowledge should it accept hexadecimal values, right?

@squidfunk
Copy link
Owner

You need to understand CSS Specificity

@denreyrey
Copy link

In your extra.css file, you'll need to add (for the color of the links)
:root>* {
--md-typeset-a-color: #3498db;
}

And then in mkdocs.yml (for color on hover)
theme:
name: material
custom_dir: overrides
palette:
# try other colors https://squidfunk.github.io/mkdocs-material/getting-started/#primary-colors
primary: white
accent: purple

extra_css:

Hope it works :) I did it like this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change request Issue requests a new feature or improvement
Projects
None yet
Development

No branches or pull requests

4 participants