Convert Figma logo to code with AI

alphagov logogovuk-frontend

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.

1,159
319
1,159
299

Top Related Projects

6,776

The U.S. Web Design System helps the federal government build fast, accessible, mobile-friendly websites.

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

49,128

Modern CSS framework based on Flexbox

A utility-first CSS framework for rapid UI development.

Semantic is a UI component framework based around useful principles from natural language.

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

Quick Overview

GOV.UK Frontend is the official frontend framework for building accessible, responsive, and consistent web interfaces for UK government services. It provides reusable design patterns, components, and styles that adhere to the GOV.UK Design System, ensuring a unified user experience across government websites.

Pros

  • Ensures consistency and accessibility across government digital services
  • Regularly updated and maintained by the Government Digital Service (GDS)
  • Includes pre-built, tested components that speed up development
  • Offers extensive documentation and guidance for implementation

Cons

  • Primarily designed for UK government services, which may limit its applicability for other projects
  • Requires adherence to specific design patterns, potentially limiting creative freedom
  • Learning curve for developers unfamiliar with the GOV.UK Design System
  • May require additional customization for non-standard use cases

Code Examples

  1. Including GOV.UK Frontend in your project:
<link rel="stylesheet" href="path/to/govuk-frontend.min.css">
<script src="path/to/govuk-frontend.min.js"></script>
  1. Initializing GOV.UK Frontend JavaScript:
window.GOVUKFrontend.initAll()
  1. Using a GOV.UK Frontend component (Button):
{% from "govuk/components/button/macro.njk" import govukButton %}

{{ govukButton({
  text: "Save and continue",
  classes: "govuk-button--start"
}) }}
  1. Customizing GOV.UK Frontend colors:
$govuk-brand-colour: #0b0c0c;
$govuk-link-colour: #1d70b8;

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

Getting Started

To use GOV.UK Frontend in your project:

  1. Install the package:

    npm install govuk-frontend
    
  2. Include the CSS and JavaScript in your HTML:

    <link rel="stylesheet" href="node_modules/govuk-frontend/govuk/all.css">
    <script src="node_modules/govuk-frontend/govuk/all.js"></script>
    
  3. Initialize the JavaScript:

    <script>
      window.GOVUKFrontend.initAll()
    </script>
    
  4. Start using GOV.UK Frontend components in your templates or JavaScript.

For more detailed instructions and best practices, refer to the official GOV.UK Frontend documentation.

Competitor Comparisons

6,776

The U.S. Web Design System helps the federal government build fast, accessible, mobile-friendly websites.

Pros of USWDS

  • More comprehensive component library with a wider range of UI elements
  • Better documentation and guidelines for accessibility compliance
  • Stronger focus on mobile-first design principles

Cons of USWDS

  • Steeper learning curve due to its extensive feature set
  • Less frequent updates and releases compared to GOV.UK Frontend

Code Comparison

USWDS (SCSS):

@use "uswds-core" with (
  $theme-show-notifications: false,
  $theme-font-path: "../fonts",
  $theme-image-path: "../img"
);

@use "uswds";

GOV.UK Frontend (Sass):

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

.app-width-container {
  @include govuk-width-container;
}

Both frameworks offer modular importing of components and utilities, but USWDS uses the newer @use syntax while GOV.UK Frontend still relies on @import. USWDS provides more configuration options out of the box, allowing for easier customization of paths and theme settings.

169,947

The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web.

Pros of Bootstrap

  • Larger community and ecosystem, with extensive third-party themes and plugins
  • More comprehensive component library, covering a wider range of UI elements
  • Flexible grid system that adapts well to various screen sizes and devices

Cons of Bootstrap

  • Less focused on accessibility compared to GOV.UK Frontend
  • May require more customization to achieve a unique design, as it's widely used
  • Larger file size, which can impact page load times if not optimized

Code Comparison

GOV.UK Frontend (Sass):

.govuk-button {
  @include govuk-font($size: 19);
  @include govuk-link-common;
  @include govuk-link-style-default;
  @include govuk-link-print-friendly;
}

Bootstrap (Sass):

.btn {
  display: inline-block;
  font-weight: $btn-font-weight;
  color: $body-color;
  text-align: center;
  vertical-align: middle;
}

Both frameworks use Sass for styling, but GOV.UK Frontend relies more heavily on mixins for consistent styling across components. Bootstrap's approach is more direct, with fewer abstraction layers. GOV.UK Frontend's code is specifically tailored for government websites, while Bootstrap aims for broader applicability.

49,128

Modern CSS framework based on Flexbox

Pros of Bulma

  • Lightweight and modular CSS framework, allowing for easy customization
  • Extensive documentation and active community support
  • Flexbox-based grid system for responsive layouts

Cons of Bulma

  • Less specific focus on accessibility compared to GOV.UK Frontend
  • Fewer pre-built components tailored for government services
  • May require more customization to achieve a specific design language

Code Comparison

Bulma (SASS):

@import "bulma/sass/utilities/_all"
@import "bulma/sass/base/_all"
@import "bulma/sass/elements/button"
@import "bulma/sass/components/navbar"

GOV.UK Frontend (SCSS):

@import "govuk/all";
@import "govuk/core/all";
@import "govuk/objects/all";
@import "govuk/components/button/button";
@import "govuk/components/header/header";

Both frameworks offer modular importing, allowing developers to include only the necessary components. GOV.UK Frontend provides a more opinionated structure tailored for government services, while Bulma offers a more general-purpose approach with greater flexibility for customization.

Bulma's lightweight nature and extensive documentation make it appealing for a wide range of projects. However, GOV.UK Frontend's focus on accessibility and pre-built components for government services gives it an edge for specific use cases in the public sector.

A utility-first CSS framework for rapid UI development.

Pros of Tailwind CSS

  • Highly customizable and flexible utility-first CSS framework
  • Rapid development with pre-built classes for common design patterns
  • Smaller file sizes due to purging unused styles in production

Cons of Tailwind CSS

  • Steeper learning curve for developers new to utility-first CSS
  • Can lead to cluttered HTML with many class names
  • Less opinionated design system, requiring more decision-making

Code Comparison

GOV.UK Frontend:

<button class="govuk-button" data-module="govuk-button">
  Save and continue
</button>

Tailwind CSS:

<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
  Save and continue
</button>

Summary

Tailwind CSS offers greater flexibility and customization options, while GOV.UK Frontend provides a more structured and opinionated design system specifically tailored for UK government services. Tailwind CSS is ideal for projects requiring unique designs, whereas GOV.UK Frontend ensures consistency across government websites. The choice between the two depends on project requirements, team expertise, and design goals.

Semantic is a UI component framework based around useful principles from natural language.

Pros of Semantic-UI

  • More comprehensive UI component library with a wider range of pre-built elements
  • Highly customizable with theming support and LESS variables
  • Active community and extensive documentation

Cons of Semantic-UI

  • Larger file size and potential performance impact
  • Steeper learning curve due to its extensive features
  • Less focused on accessibility compared to GOV.UK Frontend

Code Comparison

Semantic-UI button:

<button class="ui primary button">
  Save
</button>

GOV.UK Frontend button:

<button class="govuk-button" data-module="govuk-button">
  Save
</button>

Both frameworks provide easy-to-use button components, but Semantic-UI offers more built-in styling options, while GOV.UK Frontend focuses on simplicity and adherence to government design standards.

Semantic-UI is a versatile framework suitable for various projects, offering a rich set of components and customization options. However, it may be overkill for simpler websites and can impact performance due to its size.

GOV.UK Frontend is specifically designed for UK government websites, emphasizing accessibility and compliance with government design standards. It's lighter and easier to implement but has a more limited scope of components and styling options.

Choose Semantic-UI for complex, highly customizable projects, and GOV.UK Frontend for government-related websites or when prioritizing accessibility and simplicity.

The most advanced responsive front-end framework in the world. Quickly create prototypes and production code for sites that work on any kind of device.

Pros of Foundation

  • More comprehensive and feature-rich, offering a wider range of UI components and utilities
  • Highly customizable with Sass variables and mixins
  • Larger community and ecosystem, with more third-party extensions and resources

Cons of Foundation

  • Steeper learning curve due to its extensive feature set
  • Larger file size, which may impact page load times
  • Less focused on accessibility compared to GOV.UK Frontend

Code Comparison

GOV.UK Frontend (button component):

.govuk-button {
  @include govuk-font($size: 19);
  @include govuk-focusable;
  @include govuk-link-common;
  @include govuk-link-style-default;
  @include govuk-link-print-friendly;
}

Foundation (button component):

.button {
  @include button-base;
  @include button-size;
  @include button-style;
  @include button-expand;
  @include button-hollow;
  @include button-disabled;
}

Both frameworks use Sass mixins for component styling, but Foundation's approach is more modular, allowing for easier customization of individual button properties. GOV.UK Frontend's approach is more opinionated and focused on maintaining consistency with government design standards.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

GOV.UK Frontend · Build Status JavaScript Style Guide

GOV.UK Frontend contains the code you need to start building a user interface for government platforms and services.

See live examples of GOV.UK Frontend components, and guidance on when to use them in your service, in the GOV.UK Design System.

Contact the team

GOV.UK Frontend is maintained by a team at Government Digital Service. If you want to know more about GOV.UK Frontend, please email the Design System team or get in touch with them on Slack.

Quick start

There are 2 ways to start using GOV.UK Frontend in your app:

Once installed, you will be able to use the code from the examples in the GOV.UK Design System in your service.

You should also have a plan to stay up to date with changes.

Browser and assistive technology support

To help manage the ever-growing number of browser versions, we group browsers into 4 grades:

  • grade A - Most recent stable versions of Chrome, Firefox, Edge, Samsung Internet and Safari
  • grade B - All stable versions of Chrome, Firefox and Edge released in the last 6 months and the last 4 major stable releases of Safari which are not supported in Grade A
  • grade C - All browsers that support <script type="module"> (Chrome 61+, Edge 16-18, Edge 79+, Firefox 60+, Safari 11+)
  • grade X - All other browsers (including IE11 and older)

Note: Only browsers in grades A, B and C will run our JavaScript enhancements. We will not support our JavaScript enhancements for older browsers in grade X.

For more information see our Browser Support documentation.

GOV.UK Frontend also supports:

Accessibility

The GOV.UK Design System team works hard to ensure that GOV.UK Frontend is accessible.

Using Frontend will help your service meet level AA of WCAG 2.2. But you must still check that your service meets accessibility requirements, especially if you extend or modify components.

You should also use the JavaScript from GOV.UK Frontend and read the accessibility statement for the GOV.UK Design System.

Known issues flagged by validators or automated testing tools

Check our list of known issues that may be reported by HTML Validators or automated testing tools.

Security

GDS is an advocate of responsible vulnerability disclosure. If you’ve found a vulnerability, we would like to know so we can fix it.

For full details on how to tell us about vulnerabilities, see our security policy.

Licence

Unless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation. The documentation is © Crown copyright and available under the terms of the Open Government 3.0 licence.

Contributing

To learn how to help us build GOV.UK Frontend, see our contribution guidelines.

The govuk-frontend repository is public and we welcome contributions from anyone.

Contributors to alphagov repositories are expected to follow the Contributor Covenant Code of Conduct. Contributors working within government are also expected to follow the Civil Service code.

We're unable to monitor activity on this repository outside of our office hours (10am to 4pm, UK time). To get a faster response at other times, you can report abuse or spam to GitHub.

NPM DownloadsLast 30 Days