Picocss::Gem
picocss-gem is a Ruby gem that integrates PicoCSS into Ruby applications.
It works with Rails, Bridgetown, and Sinatra, providing:
- Automatic inclusion of PicoCSS assets
- Rails generators (base + theme + login template)
- Multi-framework support for Ruby apps
Documentation also available in Portuguese: PortuguΓͺs
π Features
- β Rails, Sinatra, and Bridgetown support
- β PicoCSS included and ready for production
- β Easy setup and integration
- β
Generators for Rails (
bin/rails generate picocss:install) - β
Theme generators (
bin/rails generate picocss:install_<theme>) - β
Login template generator (
bin/rails generate picocss:template_login)
πΎ Installation
Add to your Gemfile:
gem "picocss-gem", "~> 0.1.0"Then run:
bundle installOr install directly:
gem install picocss-gemπ οΈ Usage
Rails
Default PicoCSS
- Add PicoCSS to your layout:
<%= stylesheet_link_tag "pico.min", media: "all" %>- Copy the CSS to your project:
bin/rails generate picocss:install- Restart your server:
rails serverπ¨ Install a Theme
bin/rails generate picocss:install_<color>| Theme | Color |
|---|---|
| red | |
| pink | |
| fuchsia | |
| purple | |
| violet | |
| indigo | |
| blue | |
| cyan | |
| jade | |
| green | |
| lime | |
| yellow | |
| pumpkin | |
| orange | |
| sand | |
| grey | |
| zinc | |
| slate |
Example:
bin/rails generate picocss:install_blueπ€ Login Template Generator
bin/rails generate picocss:template_loginThis will copy the login template to:
app/views/sessions/new.html.erb
Template highlights:
- Centered form with vertical alignment
- Fields: Email, Password, "Remember me" checkbox
- Dark background with contrasting buttons
- Fully responsive container
<main class="container" style="background-color:#111; height:100vh; display:flex; justify-content:center; align-items:center;">
<form method="post" action="/login" style="width:300px;">
<h1 style="color:white;">Login</h1>
<label>Email</label>
<input type="email" required>
<label>Password</label>
<input type="password" required>
<div>
<input type="checkbox">
<label>Remember me</label>
</div>
<button type="submit">Login</button>
</form>
</main>Sinatra
require "sinatra"
require "picocss"
register Picocss::Sinatra<link rel="stylesheet" href="/assets/stylesheets/pico.min.css" />ruby app.rbBridgetown
gem "picocss-gem", "~> 0.1.0"CSS Copy automatically to:
output/assets/css/pico.min.css
Include in layout:
<link rel="stylesheet" href="/assets/css/pico.min.css" />Build and serve:
bridgetown build
bridgetown serveβ‘ Generators Summary
| Command | Description |
|---|---|
bin/rails generate picocss:install |
Copy pico.min.css
|
bin/rails generate picocss:install_<theme> |
Copy a themed CSS (e.g. pico.blue.min.css) |
bin/rails generate picocss:template_login |
Copy login template |
π§ͺ Development
bin/setup
rake spec
bin/console
bundle exec rake install
bundle exec rake releaseπ License
MIT License. See LICENSE