Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
G

govuk-components

> 前端框架
Open source

Lightweight Ruby on Rails components for developing with the GOV.UK Design System.

190 stars0 likes1 views
WebsiteGitHub

About

Lightweight Ruby on Rails components for developing with the GOV.UK Design System.

GOV.UK Components for Ruby on Rails

This gem provides a suite of reusable components for the GOV.UK Design System. It is intended to provide a lightweight alternative to the GOV.UK Publishing Components library and is built with GitHub’s ViewComponent framework.

It aims to implement the functionality from the original Nunjucks macros in a way that will feel more familiar to Rails developers. Blocks are preferred over strings of HTML, beneath the surface each component is just a Ruby object, everything is inheritable and overrideable.

Documentation

The gem comes with a full guide that covers most aspects of day-to-day use, along with code and output examples. The examples in the guide (and the guide itself) are built using the components, so it will always be up to date.

What’s included?

All of the non-form components from the GOV.UK Design System are implemented by this library as ViewComponents. Form components are implemented by the GOV.UK Form Builder.

The provided components are:

  • Accordion
  • Back link
  • Breadcrumbs
  • Cookie banner
  • Details
  • Exit this page
  • Feedback
  • Generic header
  • GOV.UK footer
  • GOV.UK header
  • Inset text
  • Language navigation
  • Notification banner
  • Panel
  • Pagination
  • Phase banner
  • Section break
  • Service navigation
  • Start button
  • Summary list
  • Tabs
  • Tables
  • Tags
  • Task list
  • Warning text

This library also provides helpers for creating links, buttons, skip links and back to top links.

Alternative syntax

All of the components can be rendered in two ways:

  • directly using Rails’ #render method:

    erb
      
        A serious warning
      
  • via the helper wrapper:

    erb
      
        A serious warning
      

    The naming convention for helpers is govuk_ followed by the component’s name in snake case. You can see the full list in GovukComponentsHelper.

Example use

This library allows components to be rendered with Rails’ render method or via the provided helpers. Here we’ll use the govuk_tabs to render three tabbed sections:

erb

  
    
Monday’s child is fair of face

  

  
    
Tuesday’s child is full of grace

  

  
    
Wednesday’s child is full of woe

  

Here are the rendered tabs:

For examples on usage see the guide page.

Setup

Add this line to your config/application.rb:

ruby
require "govuk/components"

Services using this library

  • Apply for teacher training
  • Find postgraduate teacher training
  • Get help with technology
  • Publish teacher training courses
  • Register trainee teachers
  • Teaching Vacancies

Forks

  • Betagouv Système de Design de l'État view components

Installation

Add this line to your application’s Gemfile:

ruby
gem 'govuk-components'

And then execute:

bash
bundle

Or install it yourself as:

bash
gem install govuk-components

Contributing

Bug reports and feature requests are most welcome, please raise an issue or submit a pull request.

Currently we're using GOVUK Lint to ensure code meets the GOV.UK guidelines. Please ensure that any PRs also adhere to this standard.

To help keep the logs clean and tidy, please configure git to use your full name:

bash
git config --global user.name "Julius Hibbert"

Licence

The gem is available as open source under the terms of the MIT License.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rubycomponentsgovukgovuk-componentsgovuk-frontend

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架