alphagov / govuk-design-system

One place for service teams to find styles, components and patterns for designing government services.
https://www.gov.uk/design-system
MIT License
510 stars 232 forks source link

Add guidance on changing the font and colours #1019

Open joelanman opened 5 years ago

joelanman commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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;
}
joelanman commented 5 years ago

@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 commented 5 years ago

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 commented 4 years ago

adding to triage as it came up in a support request

DevRCRun commented 4 years ago

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 commented 4 years ago

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";
joelanman commented 3 years ago

had another support request that was resolved by this

hannalaakso commented 2 years ago

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

EoinShaughnessy commented 2 years ago

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 commented 2 years ago

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

DevRCRun commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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 commented 10 months ago

+ 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!