Introduction
CSS Classes
React Components
Cssville is a utility-first CSS framework with zero dependencies. It is a single stylesheet, cssville.css, made of small classes that each set one CSS property, so you style elements by adding classes to your HTML instead of writing CSS.
Install the package from npm:
npm install cssvilleThen import the stylesheet once, in your app's entry file:
import "cssville/cssville.css";To try it without a build step, link the stylesheet from the jsDelivr CDN instead:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/cssville/cssville.css" />A class name is a CSS property followed by its value. The property part uses the first three letters of each word, so display becomes dis and flex-direction becomes fle-dir:
.dis-flex { display: flex; }
.fle-dir-column { flex-direction: column; }
.pad-y-4 { padding-top: 8px; padding-bottom: 8px; }Combine classes on an element to style it:
<div class="dis-flex fle-dir-column gap-4 pad-6 bor-rad-4 box-sha-lg">
<span class="fon-siz-xl fon-wei-bold">Cssville</span>
<span class="col-blue-grey-600">Styled with utility classes only.</span>
</div>The CSS classes pages in the menu list every class and value, for example display and padding.
Put a breakpoint name in front of a class to apply it only on screens up to that width. The prefixes and their widths are:
This row becomes a column on screens 768px wide or narrower:
<div class="dis-flex fle-dir-row md-fle-dir-column gap-4">
<div>Menu</div>
<div>Content</div>
</div>Color, background color and border color classes have no prefixed versions.
Add -hover to the end of a class to apply it only while the pointer is over the element:
<a href="/docs" class="col-blue-700 tex-dec-none tex-dec-underline-hover">Read the docs</a>Hover classes work with prefixes too: md-dis-flex-hover applies on hover on screens up to 768px wide.
cssville.css contains every class and is about 3.2 MB. For production, remove the classes you don't use at build time with a tool such as PurgeCSS, as this site does.