Best way to customise the formatting of the link text?

סיכום מבוסס בינה מלאכותית

The discussion revolves around customizing the formatting of link text in the Custom Header Links plugin. alexs asks how to style the link text (e.g., bold, color) without losing changes during updates. dax suggests creating a custom theme component instead of editing CSS directly. alexs confirms this works. manuel explains that since the plugin now uses CSS variables, direct SCSS assignments like $header_primary don’t work, but using var(--header_primary) in custom CSS does. pmusaraj confirms this is due to the switch to CSS variables and recommends updating the component for the fix. Daniel_R notes the solution didn’t work for him, possibly due to not updating the component.

What’s the best way to customise the formatting of the link text? It looks like editing the CSS isn’t the best approach because the changes will be lost when the plugin’s updated.

I’d like to make it bold & change the text colour to match the site’s theme which will help it blend in.

At the moment the link looks like this -

& I’d like it to look like this -

It’d be useful to be able to customise the text depending on the theme too. I have a dark theme & a light theme with different colour fonts for each. I’d like to set the colour of the text to match the theme.

You need to create a new theme component with your changes and then add it in the same main themes where is the Custom Header Links

Thanks! I’ve done that now & it worked like a charm.

Out of interest, how does the site choose which CSS to use? If the standard theme component contains CSS that will set the font colour to $header_primary -

.headerLink {
  list-style: none;
  a {
    padding: 6px 10px;
    color: $header_primary;
    font-size: $font-up-1;
  }
}

then how does it know to use the CSS from my new component instead?

.headerLink {
  list-style: none;
  a {
    color: #7A7A7A;
  }
}

Hi @Johani - is this still the case? My instance seems reluctant to adopt the $header_primary colour, and curiously even when I set $primary to the colour I want (white), it remains stubbornly black :upside_down_face: !

Screenshot 2021-02-06 at 14.16.12

It’s probably related to the switch from SCSS to CSS variables for color declarations. Assigning $header_primary in custom css doesn’t work, but if you use

.custom-header-links .headerLink a {
    color: var(--header_primary);
}

the color gets picked up correctly.

I didn’t get this solution to work for me. Are you adding this to the theme’s custom CSS?

Yes, it was indeed. The component now uses the CSS custom property, it should fix the issue for you @Daniel_R, you just need to update the component.