Usage
Work without package manager or dependencies 🙂!
There are 3 ways to get started with pico.css:
Install manually
Download Pico and link /css/pico.min.css
in the <head>
of your website.
<link rel="stylesheet" href="css/pico.min.css">
Install from CDN
Alternatively, you can use unpkg CDN to link pico.css
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.min.css">
Install with NPM
npm install @picocss/pico
Starter HTML template:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/pico.min.css">
<title>Hello, world!</title>
</head>
<body>
<main class="container">
<h1>Hello, world!</h1>
</main>
</body>
</html>
Themes
Pico is shipped with 2 consistent themes: Light & Dark.
The Light theme is used by default. The Dark theme is automatically enabled if the user has dark mode enabled prefers-color-scheme: dark
Themes can be forced on document level <html data-theme="light">
or on any HTML element <article data-theme="dark">
Light theme
Dark theme
Customization
You can customize themes with SCSS or, you can edit the CSS variables.
Example: pick a color!
Custom theme
There are 2 ways to customize your version of Pico.css:
Overriding CSS variables
All Pico's styles and colors are set with CSS custom properties (variables). Just override the CSS variables to customize your version of Pico.
/* Light scheme (Default) */
/* Can be forced with data-theme="light" */
[data-theme="light"],
:root:not([data-theme="dark"]) {
--primary: …;
--primary-hover: …;
--primary-focus: …;
--primary-inverse: …;
}
/* Dark scheme (Auto) */
/* Automatically enabled if user has Dark mode enabled */
@media only screen and (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) {
--primary: …;
--primary-hover: …;
--primary-focus: …;
--primary-inverse: …;
}
}
/* Dark scheme (Forced) */
/* Enabled if forced with data-theme="dark" */
[data-theme="dark"] {
--primary: …;
--primary-hover: …;
--primary-focus: …;
--primary-inverse: …;
}
/* (Common styles) */
:root {
--form-element-active-border-color: var(--primary);
--form-element-focus-color: var(--primary-focus);
--switch-color: var(--primary-inverse);
--switch-checked-background-color: var(--primary);
}
You can find all the CSS variables used in the default theme here: css/themes/default.css
Importing Pico SASS library
We recommend customizing Pico by importing SASS source files into your project. This way, you can keep Pico up to date without conflicts since Pico code and your custom code are separated.
Compile the SASS file to CSS to get a custom version of Pico.
/* Custom version */
// Override default variables
$primary-500: …;
$primary-600: …;
$primary-700: …;
// Import full Pico source code
@import "path/pico";
Alternatively, you can create a custom theme and import it into your project with the components you need.
/* Custom version */
// Custom theme
@import "path/themes/custom";
// Import needed components
@import "path/layout/document";
@import "path/layout/sectioning";
…
Compiling a custom SASS version allows you to create a lighter version with only the components that are useful to you. Example here: scss/pico.slim.scss.
Class-less version
For wild HTML purists!
Pico provides a .classless
version (example).
In this version, <header>
, <main>
, and <footer>
act as containers to define a centered or a fluid viewport.
Usage:
Use the default .classless
version if you need centered viewports:
<link rel="stylesheet" href="css/pico.classless.min.css">
Or use the .fluid.classless
version if you need a fluid container:
<link rel="stylesheet" href="css/pico.fluid.classless.min.css">
These .classless
versions are also available on unpkg CDN:
// Centered viewport
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.classless.min.css">
// Fluid viewport
<link rel="stylesheet" href="https://unpkg.com/@picocss/pico@latest/css/pico.fluid.classless.min.css">
RTL
Support for right-to-left text in Pico.
To enable RTL in Pico you need to set
dir="rtl"
on the
<html>