Repacking of GOV.UK Frontend and GOV.UK form components for use in Katalyst projects.
Add this line to your application's Gemfile:
gem "katalyst-govuk-formbuilder"
And then execute:
$ bundle
Or install it yourself as:
$ gem install katalyst-govuk-formbuilder
Add the stylesheet to your default layout:
<%= stylesheet_link_tag "katalyst/govuk/formbuilder" %>
You can also add it to your SASS build:
@use "katalyst/govuk/formbuilder";
Some GOVUK components require javascript enhancements (see GOVUK docs).
You can use the provided helper to load the formbuilder esm from importmaps and enhance your form:
<%= form_with ... %>
<%= govuk_formbuilder_init %>
You'll need to include the helper to make this method available, which you can add to your ApplicationController
:
helper Katalyst::GOVUK::Formbuilder::Frontend
We include some optional extensions for integrating with gems that we (Katalyst) commonly use.
These require additional steps to use.
Hotwire Combobox is a promising option for adding asynchronous multi-select inputs to Rails forms. We're assuming importmaps and Turbo if this option is used.
There's no explicit dependency so if you want to use this input you'll need to add:
gem "hotwire_combobox"
JS is added by the gem automatically (via importmaps), but you'll need to explicitly add CSS:
@use "katalyst/govuk/formbuilder";
@use "katalyst/govuk/components/combobox";
Bug reports and pull requests are welcome on GitHub at https://github.com/katalyst/govuk-formbuilder.
Tag the release version and push to CI.
The gem is available as open source under the terms of the MIT License.