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 guidance on changing the font and colours #1019

Open
joelanman opened this issue Aug 8, 2019 · 16 comments
Open

Add guidance on changing the font and colours #1019

joelanman opened this issue Aug 8, 2019 · 16 comments
Labels
customisation documentation User requests new documentation or improvements to existing documentation guidance

Comments

@joelanman
Copy link
Contributor

Suggested content:

Setting your own font and colours

Set the font and colour variables in your Sass, before importing GOV.UK Frontend.

For example:

$govuk-font-family: "Source Sans Pro";

$govuk-brand-colour: #FF0000;

You can find the colour variable names on the colour page.

@joelanman
Copy link
Contributor Author

We could add the page to Styles, and link to from Get Started.

We could add a block/comments to the Prototype Kit to help people put their overrides in the right place.

This guidance doesn't allow for changing font-weight. This can be achieved through override classes, but this seems a little inconsistent: font-family can be overridden through variables but the font-weight cannot. If we want to support it through white-labelling we could add a variable:

$govuk-heading-font-weight

However in the service I'm working on the font-weight changes for different heading levels. H1 is 100, h2 is 600, and so on. So we could add per size weighting variables:

$govuk-heading-xl-font-weight

$govuk-heading-l-font-weight

@dashouse
Copy link

dashouse commented Aug 9, 2019

Thanks Joe, there's a lot of things like this and is part of the ongoing consideration of content that's currently only in the Sass docs.

Font weight can be overridden using variables globally if you did something like $govuk-font-weight-bold: $govuk-font-weight-regular however I believe this will not affect the headings.

As you're dealing with very specific weights for those headings it would probably be worth creating ccs- prefixed modifiers using the govuk-font mixin? I think something like this should work?:

.ccs-heading-xl {
    @include govuk-font($weight: 100);
}

If you didn't need to change anything but weight maybe just a normal override with CSS?:

.ccs-heading-xl {
   font-weight: 100;
}

@dashouse dashouse added the awaiting triage Needs triaging by team label Aug 9, 2019
@joelanman
Copy link
Contributor Author

@dashouse thanks yeh you could use overrride classes, but I think its just a little inconsistent that you can change the font-family in a variable (what I call the white-labelling approach) but not the font-weight. It's not a huge deal and I know this isn't your focus right now :)

@joelanman
Copy link
Contributor Author

Hi just wondering whether just the text I wrote could be added to the Design System, in which case I don't think this would take weeks? Or do you think more needs to be done?

@joelanman
Copy link
Contributor Author

adding to triage as it came up in a support request

@36degrees 36degrees added Effort: days and removed Effort: weeks awaiting triage Needs triaging by team labels Mar 2, 2020
@timpaul timpaul added the awaiting triage Needs triaging by team label Apr 9, 2020
@kellylee-gds kellylee-gds added guidance documentation User requests new documentation or improvements to existing documentation and removed guidance awaiting triage Needs triaging by team labels Apr 15, 2020
@hannalaakso hannalaakso added the awaiting triage Needs triaging by team label May 14, 2020
@kellylee-gds kellylee-gds removed awaiting triage Needs triaging by team documentation User requests new documentation or improvements to existing documentation labels May 14, 2020
@DevRCRun
Copy link

Potentially obvious question to someone more familiar with scss than I, but is it possible to set the font src to our own file? Using $govuk-font-family: "Arial"; in application.scss works fine, but unsure whether using our own woff files is even possible

@36degrees
Copy link
Contributor

Hi,

It should work fine, but you'll need to include the font-face declaration in the Sass yourself.

You should then be able to set $govuk-font-family to reference the same font-family you use in the font-face declaration.

For example:

@font-face {
  font-family: "Open Sans";
  src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
       url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
}

$govuk-font-family: "Open Sans", "Arial";

@import "node_modules/govuk-frontend/govuk/all";

@m-green m-green added the documentation User requests new documentation or improvements to existing documentation label Sep 24, 2020
@joelanman
Copy link
Contributor Author

had another support request that was resolved by this

@hannalaakso
Copy link
Member

hannalaakso commented Dec 15, 2021

Just had a question on support about how to override the font, I directed the person asking here.

@EoinShaughnessy
Copy link
Contributor

EoinShaughnessy commented Jan 6, 2022

Suggested content:

Setting your own font and colours

Set the font and colour variables in your Sass, before importing GOV.UK Frontend.

For example:

$govuk-font-family: "Source Sans Pro";

$govuk-brand-colour: #FF0000;

You can find the colour variable names on the colour page.

We could add the page to Styles, and link to from Get Started.

The Styles section on the Design System site has 2 separate sections titled 'Colour' and 'Font'.

Is there a case for splitting up the suggested content accordingly? So, somewhere in the 'Font' section, we'd have "Set the font variable in your Sass..." and so on.

Or does it make more sense to keep this content together (if users would be setting both variables at roughly the same time)?

@lfdebrux
Copy link
Member

lfdebrux commented Mar 1, 2022

Is there still a user need for this? I a little curious to know who's doing this...

@DevRCRun
Copy link

DevRCRun commented Mar 1, 2022

We did it as a local authority who (as I understood it at the time - scream at me if I'm wrong) aren't permitted to use the transport font on something.localauthority.gov.uk

At the time the use case of stripping out this and any crown images when using the NPM module wasn't really covered in the frontend "get-started" docs (perhaps fairly enough) in a way we could comprehend (we were new to Sass at the time and aren't exactly experts with the API now).

Fwiw, for our admittedly non-core use case, I'd imagine it makes sense to have them together (corporate branding and all that).

@abbott567
Copy link

Just wondering if there is a recommended fallback or alternative for Transport?

Obviously for services not on GOVUK, Transport is not an option. But I usually see the fall backs noted as Arial, Helvetica or Open Sans, but they all have the same issue with the uppercase i and lowercase L looking identical. It can make words like illness look particularly weird whereas transport handles them quite nicely with the spurs on the L.

Comparison of 3 fonts. GDS Transport, Arial and Open Sans. Each font is showing a lowercase and uppercase I, and a lowercase and uppercase L. With the exception of Transport, the uppercase I and lowercase L look identical.

I feel like from a legibility / accessibility point of view, there should probably be a consistent nominated fallback recommended which handles it as elegantly as Transport, given that the whole reason Transport exists is to be as legible as possible. Something like Source Sans Pro or PT Sans handle the L and the i well, but the capital G is quite a bit different. But there probably are closer alternatives if we look hard enough.

A comparison of Transport, Source Sans Pro and PT Sans. Each shows the word GOV.UK along with the upper and lowercase alphabet.

@joelanman
Copy link
Contributor Author

@lfdebrux anyone who'd like to use Frontend but can't use the GOV.UK brand and colours - local gov, internal systems, and so on, needs to do this

@36degrees
Copy link
Contributor

Just wondering if there is a recommended fallback or alternative for Transport?

@abbott567 would you mind raising this comment as a new issue? I can see why you've posted it here – it's definitely related – but feels like a distinct thing to me.

@oshawa-connection
Copy link

oshawa-connection commented Jan 11, 2024

+ 1 for @EoinShaughnessy 's suggestion, potentially it could be something to add to/ link to from
this page.

Luckily I stumbled upon this issue from my google search or else I would have been in trouble. Please please please add it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customisation documentation User requests new documentation or improvements to existing documentation guidance
Projects
None yet
Development

No branches or pull requests