Skip to content

Primer ViewComponents

ViewComponents for the Primer Design System

Primer ViewComponents is an implementation of the Primer Design System, using ViewComponent.

This library is under active pre-1.0 development. Breaking changes are likely in patch releases.

Usage

Render Primer ViewComponents from templates:

<%= render(Primer::CounterComponent.new(count: 25)) %>

Installation

In Gemfile, add:

gem "primer_view_components"

In config/application.rb, add after the application definition:

require "view_component/engine"
require "primer/view_components/engine"

Optionally, to add the JavaScript behaviours, in your application.html.erb in the <head> tag add:

<%= javascript_include_tag("primer") %>

Or alternatively, you can install the @primer/view-components npm package and in your JavaScript code add:

import '@primer/view-components'

You can also import only the components you need:

import '@primer/view-components/tab_container'

Dependencies

In addition to the dependencies declared in the gemspec, Primer ViewComponents assumes the presence of Primer CSS.