Skip to main content

NEW Please give feedback

London Borough of Croydon Bootstrap 4 theme

Templates, design patterns and usage

Introduction

Why use Bootstrap 4?

Bootstrap 4 is a open source HTML and CSS framework. By customising Bootstrap's components we can create our own front end theme, documenting our markup practices and creating working web patterns along the way.

Cross platform compatability

All components in this theme have been configured using HTML5, Bootstrap CSS and pure Javascript. They do not require a JQuery Library or any Bootstrap JQuery to function.

Why pure CSS and 'vanilla' Javascript?

Global theme components that usually require JQuery to function have had their Bootstrap JQuery classes removed, and their functions replaced with a custom 'vanilla' Javascript equivalent:

  • Main navigation mobile menu toggle
  • Main navigation dropdown menu
  • Expandable content
  • Accordion menu
  • Cookie alert bar and cookie creation

By using this 'vanilla' approach the global components will not be affected should Bootstrap JQuery , AngularJS or other coding languages be integrated into the theme.

Fonts and Fallbacks

The Croydon Council brand font Fiendstar Bold is used for display headlines and a handful of other elements, creating a unique identity:

Fiendstar Bold

  • Site logo
  • Headings (H1 - H6)
  • Headings (H1 - H6)
  • Main navigation links
  • Button text
  • Form labels

Embedded using @font-face

Source Sans Pro

  • Copy
  • As a fallback for Fiendstar
  • Choose from weights: 400, 600, 700, 900
  • Headings and form labels
  • Button text

Embedded using Google Web Fonts

Defining fallbacks

Fiendstar Bold and fallbacks

font-family: "Fiendstar W01 Bold", 'Source Sans Pro', Arial, Helvetica, sans-serif;
font-weight: bold; /* For fallbacks only */

Source Sans Pro and fallbacks

font-family: 'Source Sans Pro', Arial, Helvetica, sans-serif;
font-weight: 300; /* 400, 700, or 900* /

Page master headlines

The page title (required) and descriptive paragraph (optional) should be placed inside a <header> tag and use the .key-under class:

Page title <h1>

Describe what the user can do or find on this page <p>

Use only once per page inside <main> > <header>

Page content sections

Where pages require multiple sections, content should be grouped in <section> tags. Sections have custom styles applied in the theme to visually break up the layout, as well as carrying their HTML5 semantic meaning.

Each content section typically starts with a <h2> heading and can contain nested sections to group sub content:

First level section heading <h2>

Paragraph in the first level section

Second level section heading <h3>

Paragraph in the second level sub section

Headings

Sizing and usage for <h1> to <h6> heading tags:

Page title <h1>

Use only once per page in the <main> > <header>

Section heading <h2>

Use for clearly defined sections inside <main> and for headings in the sidebar

Sub section heading <h3>

Use for sub sections of <h2>

Sub section heading <h4>

Use for sub sections of<h3>

Sub section heading <h5>

Use for sub sections of <h4>

Sub section heading <h6>

Use for sub sections of <h5>

List types

Use the standard HTML <ul> and <ol> tags to create lists. Custom icon lists require some additional styling acheived by adding the class . iconlist to your ul .

Unordered lists

  • Bullet list item
  • Bullet list item
  • Bullet list item

Ordered lists

  1. Numbered list item
  2. Numbered list item
  3. Numbered list item

Custom icon lists

  • Checklist required or included
  • Checklist required or included
  • This longer list item with a word count of 20 has been included to demonstrate icon alignment with multiline text

Form input heights

Use Bootstrap 4 'form control' classes in your HTML to choose an input height:

Standard size input using .form-control class:

Height = 50px

Large size input using .form-control and .form-control-lg classes:

Height = 60px

Small size input using .form-control and .form-control-sm classes:

Height = 40px

Inputs and buttons share the same sizing variables. Read more about input sizing with Bootstrap 4 form control.

Form input widths

Use Bootstrap 4 'column classes' in your HTML to choose an input width:

Input using .form-control and .col-sm-12 classes:

100% width input, then 12 of 12 columns above the sm breakpoint (576px+)

Input using .form-control and .col-sm-6 classes:

100% width input, then 6 of 12 columns above the sm breakpoint (576px+)

Input using .form-control and .col-sm-2 classes:

100% width input, then 2 of 12 columns above the sm breakpoint (576px+)

Input using .form-control and .col-4 classes:

4 of 12 columns at all screen sizes

The above classes may be combined with form input heights. Read more about using the Bootstrap 4 layout grid.

Form best practice

Example form elements:

Your details <legend>

Custom radios and checkboxes follow the w3schools.com method

Conditional questions

Output a conditional question based on the user's selection, note how the purple border lines up with the select options and the conditional appears below all options:

Form validation

Meeting field requirements:

Create a password for your account
Strong!
Passwords do not match

The default Bootstrap 4 field validation icons have been replaced with Open Iconinc svg background images.

Alerts

Alert the user to information, a warning or an action they need to take:

This is a information alert with the class .alert-info
This is a soft information alert with the class .alert-primary
This is a success alert with the class .alert-success
This is a warning alert with the class .alert-danger
This is a failure alert with the class .alert-danger

Icons are defined in the alert markup using content icons.

Button colours

Use Bootstrap 4 'button classes' in your HTML to choose a colour theme.

Button using .btn and .btn-primary classes:

Use by default

Button using .btn and .btn-carbon classes:

Create contrast with main button or overlay on purple

Make a button inactive by adding a disabled attribute to the <button> input:

Uses 60% opacity

Make use of our custom SASS colour variables by adding them to the button class. In this example replacing .btn-primary with .btn-indigo :

Only use colours from the theme that have been colour contrast tested with white text

Use the .btn and .btn-link classes to create inline, link style buttons:

Read more about button theming with Bootstrap 4 buttons.

Buttons height and font size

Use Bootstrap 4 'button classes' in your HTML to choose a button height and font size.

Standard size button using .btn and .btn-primary classes:

Use by default (height = 50px)

Large size button using .btn , .btn-primary and .btn-lg classes:

Draw attention to key functionality (height = 60px)

Small size button using .btn , .btn-primary and .btn-sm classes:

Use where space is limited or when another button requires priority focus (height = 40px)

Inputs and buttons share the same sizing. Read more about input sizing with Bootstrap 4 form control.

Button widths

Buttons will expand to accomodate their content, but in order to align buttons to other elements we must use Bootstrap 4 button or column classes.

Button with no width defined:

Expands to accomodate text

Button using the .col-12 class:

100% with of container at all breakpoints

Button using .col-sm-8 class:

100% width button, then 8 of 12 columns above the sm breakpoint (576px+)

Button using .col-sm-5 class:

100% width button, then 5 of 12 columns above the sm breakpoint (576px+)

Button using .col-6 and .col-md-4 classes:

50% width button, then 33.3% above the md breakpoint

Read more about using the Bootstrap 4 layout grid.

Inline text styles

For extra text syling make use of these HTML5 elements:

Use the <mark> tag to highlight text in your pages - It's used throught these guidlines to highlight tags and classes .

Use the <small> tag to add footnotes:
Caption or footnote wrapped in a small tag with a hyperlink

Use the <em> tag to emphasise text:
Example sentence with emphasised text

Read more about text styling with Bootstrap 4 inline elements.

Colours

All theme colours have been tested for colour contrast WCAG level AA. Both as coloured text on a white background and as a background with the default 'Carbon' or white text overlayed.

Default theme colours

Primary
#880088
Secondary
#121212
Success
#338800
Information
#121212
Warning
#ff5500
Danger
#ae1100
Light
#ededed
Dark
#444444

Custom colours mapped to 'theme colours'

Purple
#880088
Green
#77bb55
Indigo
#540055
Purple tint
#f8eef8
Green tint
#eaf5e5
Indigo tint
#eee5ee
Carbon
#121212
Graphite
#282828
Stonewash
#a0a0a0
Gray
#dbdfe3
Gray dark
#444444
White
#FFFFFF
Gray tint
#ededed
Visited
#ad52ad
Blue
#0059a4
Pink
#ad52ad
Red
#ae1100
Orange
#ff5500
Yellow
#ffbb00
Teal
#008877
Cyan
#17a2b8

Icons

Open Iconinc Icons have been chosen for their simple flat style, bold weight, and availability of desired icons.

Icon examples

account-login
ban
caret-right
check
chevron-bottom
circle-x
cog
external-link
eye
map
person
x

Example icon markup

<span class="oi oi-check" title="Checklist"></span>

Using icons with text and links

Icons may accompany inline hyperlinks informing the user of an action they are about to take, in the example below the external-link icon is used with an additional .purple class:

You can find out more about council tax rates before you apply.

Icons may be used aesthetically to organise information, in this example calendar :

15th March 2019

Provide a title attribute on the icon if the meaning is not conveyed in the link text, in this case 'Date: '

Icons may be used to accompany actions, in this example viewing a map :

View this on a map

Avoid screen reader repeats by omitting the title attribute on the icon if the meaning is already conveyed in the link text

Brand icons

As brand icons are not featured in Open Iconinc a custom font has been generated using Fontello creating a lightweight @font-face embed, just for brand icons.

Brand icons examples

icon-twitter-squared
icon-facebook-squared
icon-linkedin-squared
icon-flickr
icon-youtube-squared

Horizontal rules and key lines

Key line underneath

Add a key line to the bottom edge of an element using the .key-under class:

For example each <section> on this page uses the .key-under class.

Expandable content - Vanilla Javascript

Provide additional information or functionality inside an expandable comtainer.

You must ensure the <section> that wraps both the expandable and the trigger uses a class of .expandable-container

Expandable form triggered by a link:

Start application

Expandable helper triggered by a link:

Find out more information on this topic

Helper text with a hyperlink

Form expandable triggered by a button:

Accordion menu - Vanilla Javascript

For multi category navigation consider an accordion style menu in the sidebar.

You must ensure the <div> that wraps the navigation uses a class of .sidebar

Simple menu

For multi category navigation consider the simple menu in the sidebar.

You must ensure the <div> that wraps the navigation uses a class of .sidebar

Callout boxes

Focus attention on key information by using a callout box. Typically used a maximum of once per page.

The callout box background colour can be defined using custom SASS colour variables, in the example below .bg-teal :

Your next green recycling collection is Tuesday 18th July 2019

Put out your green bin (plastic, metal and glass) and your food waste

In this example .bg-primary :

Your next green recycling collection is Tuesday 18th July 2019

Put out your green bin (plastic, metal and glass) and your food waste

Spacing - padding and margin

Use the Bootstrap 4 spacing classes in your HTML code to add styling to your elements.

The example below has the padding class .p3 resulting in a tight padding of 1rem on all sides:

Padding example

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt.

The example below has the padding class .px-5 and .py-4 resulting in a looser padding of 3rem on the horizontal axis and 1.5rem on the vertical axis:

Padding example

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt.

The example below has the margin class .mt-4 and .mb-5 resulting in a margin of 1.5rem on the top edge and 3rem on the bottom edge:

Margin example

Neque porro quisquam est qui dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt.

This text demonstrates the margin underneath the callout box

Pixel to REM unit conversion table

The conversion table is useful for converting pixel units to REMs. In Bootstrap 4 font sizes and element spacing are measured in REM units, while design files typically use pixel units.

Pixel REM
1px 0.0625rem
2px 0.125rem
3px 0.1875rem
4px 0.25rem
5px 0.3125rem
6px 0.4375rem
7px 0.375rem
8px 0.5rem
9px 0.5625rem
10px 0.625rem
12px 0.75rem
14px 0.875rem
15px 0.9375rem
16px 1rem (base)
17px 1.063rem
18px 1.125rem
19px 1.188rem
20px 1.25rem
22px 1.375rem
24px 1.5rem
26px 1.625rem
28px 1.75rem
30px 1.875rem
32px 2rem
34px 2.125rem
36px 2.25rem
38px 2.375rem
40px 2.5rem
42px 2.625rem
44px 2.75rem
46px 2.875rem