Skip to content

Instructions for Rails / Vite appear to be wrong #3499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
lpender opened this issue May 21, 2025 · 2 comments
Open

Instructions for Rails / Vite appear to be wrong #3499

lpender opened this issue May 21, 2025 · 2 comments

Comments

@lpender
Copy link

lpender commented May 21, 2025

I'm implementing

I tried following the instructions and added:

import '@primer/view-components'

to my application.js.

At first it couldn't find it. This package doesn't appear to be added by the Rails gem, it needed to be added via npm.

yarn add -D @primer/view-components

It seems the Breadcrumb still had no styles being applied. So I did this:

yarn add -D @primer/css

And then added

@import "@primer/css";

To the top of my application.css.

Now I can see the styles.

However there seem to be steps required to pre-populate CSS vars, e.g.

--borderColor-neutral-emphasis

Will update as I learn more.

@lpender
Copy link
Author

lpender commented May 21, 2025

Okay, I have it working now. It seems the instructions cover the JS side but not the CSS side, which is confusing.

Vite / esbuild / Bun

Use vite_rails if using vite.

Install packages.

npm install -D @primer/css @primer/primitives @primer/view-components

Add CSS:

/* application.css */
@import "@primer/css";
@import "@primer/primitives/dist/css/base/size/size.css";
@import "@primer/primitives/dist/css/base/typography/typography.css";
@import "@primer/primitives/dist/css/functional/size/border.css";
@import "@primer/primitives/dist/css/functional/size/breakpoints.css";
@import "@primer/primitives/dist/css/functional/size/size.css";
@import "@primer/primitives/dist/css/functional/size/viewport.css";
@import "@primer/primitives/dist/css/functional/typography/typography.css";
@import "@primer/primitives/dist/css/functional/themes/light.css";
@import "@primer/primitives/dist/css/functional/themes/dark.css";

Add JS:

// application/js
import '@primer/view-components'

Add HTML:

<body data-color-mode="light" data-light-theme="light" data-dark-theme="dark">

@lesliecdubs
Copy link
Member

Hey @lpender, sorry for the confusion and thanks for documenting how you got things working. What changes would you recommend to the documentation on "Getting Started" to improve this? Happy to take your feedback and look into getting it added to the site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants