_grid_layout.scss
_conditionals.scss
_colours.scss
_css3.scss
_typography.scss
design-patterns/_buttons.scss
design-patterns/_alpha-beta.scss
design-patterns/_breadcrumbs.scss
Grid helpers to enable easy cross browser grids. The grids use absolute widths in older versions of IE or percentage based widths in modern browsers.
%site-width-container
creates a 960px wide elastic container for you site content block%grid-row
container for a row of columns@mixin grid-column($width, $full-width: tablet)
a mixin to create grid columns of fraction width
These three grid helpers are designed to be used together and aren't guaranteed to work or behave in a predictable way if used in isolation.
There is also an %outdent-to-full-width
selector which can be extended to
outdent and element and cause it to take up the edge gutters and butt up to the
edge of smaller screens.
#page-container {
@extend %site-width-container;
}
.grid-row {
@extend %grid-row;
.column-third {
@include grid-column( 1/3 );
}
.column-two-thirds {
@include grid-column( 2/3 );
}
}
.hero-image {
@extend %outdent-to-full-width;
}
<div id="page-container">
<div class="grid-row">
<div class="column-two-thirds">
Main content
</div>
<div class="column-third">
Sidebar
</div>
</div>
<div class="hero-image">
<img ...>
</div>
</div>
Media query and IE helpers. These make producing responsive layouts and attaching IE specific styles to elements really easy.
To use the IE conditionals you will need to add extra stylesheets for each IE, there's an example of how to do this in the GOV.UK template.
<!--[if gt IE 8]><!--><link href="<%= asset_path "govuk-template.css" %>" media="screen" rel="stylesheet" type="text/css" /><!--<![endif]-->
<!--[if IE 6]><link href="<%= asset_path "govuk-template-ie6.css" %>" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE 7]><link href="<%= asset_path "govuk-template-ie7.css" %>" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
<!--[if IE 8]><link href="<%= asset_path "govuk-template-ie8.css" %>" media="screen" rel="stylesheet" type="text/css" /><![endif]-->
The conditional logic ensures that only one stylesheet is downloaded.
<!--[if gt IE 8]><!--> // [1]
<link href="<%= asset_path "govuk-template.css" %>" media="screen" rel="stylesheet" type="text/css" />
<!--<![endif]--> // [1]
[1] Note the comment syntax to hide this stylesheet from IE 6-8.
At the top of each stylesheet, you will need:
$is-ie: true;
$ie-version: 6; // [1]
@import "application.scss"; // [2]
[1] This example is for ie6.css, use 6, 7 or 8 as required here
[2] Here application.scss
is the name of your main stylesheet
There are examples for an IE 6 stylesheet, an IE 7 stylesheet and an IE 8 stylesheet.
@mixin media($size: false, $max-width: false, $min-width: false)
note: the parameters are mutually exclusive and the first one found will be used.
$size
size
can be one of desktop
, tablet
, mobile
. desktop
and tablet
should be used to add styles to a mobile first stylesheet. mobile
should be
used to add styles to a desktop first stylesheet.
It is recommended that you primarily use desktop
for new stylesheets to
enhance mobile first when serving to mobile devices.
$min-width
$max-width
These should be set to an absolute pixel value. They will get added directly to their respective @media queries.
$ignore-for-ie
Styles that would normally be wrapped in @media queries by this mixin will be instead
added to the main block if the $is-ie
variable is true.
Setting $ignore-for-ie
to true
means those styles will not be added.
div.columns {
border: 1px solid;
@include media(desktop){
width: 30%;
float: left;
}
@include media($min-width: 500px){
width: 25%;
}
@include media($max-width: 400px){
width: 25%;
}
}
Conditially send CSS to IE browsers less than or equal to the named version.
@include ie-lte($version)
$version
version
is an integer value. Possible values are 6
, 7
, 8
.
div.columns {
border: 1px solid;
@include ie-lte(7){
border: 0;
}
}
Send CSS to a named IE version.
@include ie($version)
$version
version
is an integer value. Possible values are 6
, 7
, 8
.
div.columns {
border: 1px solid;
@include ie(6){
border: 0;
}
}
A collection of colour variables.
$treasury
$cabinet-office
$department-for-education
$department-for-transport
$home-office
$department-of-health
$ministry-of-justice
$ministry-of-defence
$foreign-and-commonwealth-office
$department-for-communities-and-local-government
$department-for-energy-and-climate-change
$department-for-culture-media-and-sport
$department-for-environment-food-and-rural-affairs
$department-for-work-and-pensions
$department-for-business-innovation-and-skills
$department-for-international-development
$government-equalities-office
$attorney-generals-office
$scotland-office
$wales-office
$purple
$purple-50
$purple-25
$mauve
$mauve-50
$mauve-25
$fuschia
$fuschia-50
$fuschia-25
$pink
$pink-50
$pink-25
$baby-pink
$baby-pink-50
$baby-pink-25
$red
$red-50
$red-25
$mellow-red
$mellow-red-50
$mellow-red-25
$orange
$orange-50
$orange-25
$brown
$brown-50
$brown-25
$yellow
$yellow-50
$yellow-25
$grass-green
$grass-green-50
$grass-green-25
$green
$green-50
$green-25
$turquoise
$turquoise-50
$turquoise-25
$light-blue
$light-blue-50
$light-blue-25
$black
$grey-1
$grey-2
$grey-3
$grey-4
$white
$link-colour
$link-active-colour
$link-hover-colour
$link-visited-colour
$text-colour: $black
$secondary-text-colour
$border-colour
$panel-colour
$canvas-colour
$highlight-colour
$page-colour
.column {
background: $green;
}
A collection of font-mixins. There are two different types of font mixins.
- Heading and Copy styles which are the font with added paddings to ensure a consistent baseline vertical grid.
- Core styles which are base font styles with no extra padding.
Typography mixins use a “New Transport” font stack by default.
If you are using the toolkit on projects that aren’t GOVUK branded you can
override the font using two variables: $toolkit-font-stack
and
$toolkit-font-stack-tabular
. These must be declared before they are used, eg by
the core typography mixins.
The following heading and copy styles exist:
heading-80
heading-48
heading-36
heading-27
heading-24
copy-19
copy-16
copy-14
h2 {
@include heading-27;
}
The following core styles exist:
core-80
core-48
core-36
core-27
core-24
core-19
core-16
core-14
@include core-[size]($line-height, $line-height-640)
$line-height
and $line-height-640
are both optional. When used it is
recomended to pass a fraction in for readability.
h1 {
@include core-48;
}
h2 {
@include core-24($line-height: (50/24), $line-height-640: (18/16));
}
Tabular numbers have numerals of a standard fixed width. As all numbers have the same width, sets of numbers may be more easily compared. We recommend using them where different numbers are likely to be compared, or where different numbers should line up with each other, eg in tables.
$tabular-numbers
is an optional variable that may be passed to the heading, copy and core styles to use (or explicitly not use) tabular numbers. When no variable is passed, the default is non-tabular.
h1 {
@include core-48;
}
h2 {
@include core-24($tabular-numbers: true);
}
See an example of tabular numbers in a table
CSS3 helpers to abstract vendor prefixes.
@mixin border-radius($radius)
$radius
a pixel value.
.column {
@include border-radius(5px);
}
@mixin box-shadow($shadow)
$shadow
a value set to pass into box-shadow
.
.column {
@include box-shadow(0 0 5px black);
}
@mixin translate($x, $y)
$x
and $y
are css values.
.column {
@include translate(2px, 3px);
}
This can currently only handle linear top to bottom gradients.
@mixin gradient($from, $to)
$from
and $to
are colour values.
.column {
@include gradient(#000, #fff);
}
@mixin transition($property, $duration, $function, $delay:0s)
Match up with the respective properties from transition
.
.column {
@include transition(left, 3s, ease);
}
@mixin box-sizing($type)
$type
is one of border-box
, content-box
and padding-box
.
.column {
@include box-sizing(border-box);
}
@mixin calc($property, $calc)
$property
the property to apply the calc to.
$calc
the calculation to.
.column {
@include calc(width, "300% - 20px");
}
A mixin for creating buttons in the GOV.UK style.
@mixin button($colour)
$colour
the background colour of the button (default is $green
).
.button{
@include button;
}
.button-secondary{
@include button($grey-3);
}
.button-warning{
@include button($red);
}
The button text colour is set by the mixin to either light or dark, depending on the button background colour.
If you're applying these styles to non form elements, adding a class of 'disabled' to the element will emulate the disabled button style.
A mixin to create a GOV.UK Phase banner, with alpha/beta tag inside.
@mixin phase-banner()
.phase-banner {
@include phase-banner();
}
<div class="phase-banner">
<p>
<strong class="phase-tag">ALPHA</strong>
<span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
</p>
</div>
.phase-banner {
@include phase-banner();
}
<div class="phase-banner">
<p>
<strong class="phase-tag">BETA</strong>
<span>This is a new service – your <a href="#">feedback</a> will help us to improve it.</span>
</p>
</div>
A mixin to create an alpha/beta tag.
@mixin phase-tag()
.alpha-tag{
@include phase-tag();
}
<h2>
Apply using the new service <span class="alpha-tag">ALPHA</span>
</h2>
.beta-tag{
@include phase-tag();
}
<h2>
Apply using the new service <span class="beta-tag">BETA</span>
</h2>
A mixin for creating breadcrumb navigation, showing page hierarchy in the GOV.UK style.
@mixin breadcrumbs
.breadcrumbs {
@include breadcrumbs;
}
<div class="breadcrumbs">
<ol role="breadcrumbs">
<li>
<a href="/">Home</a>
</li>
<li>
<a href="/section-name">Section name</a>
</li>
<li>
Page name
</li>
</ol>
</div>