百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
G

govuk-components

> 前端框架
开源

用于使用 GOV.UK 设计系统开发的轻量级 Ruby on Rails 组件。

190 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

用于使用 GOV.UK 设计系统开发的轻量级 Ruby on Rails 组件。

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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rubycomponentsgovukgovuk-componentsgovuk-frontend

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类前端框架
定价开源

> 相关工具

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