Capital Framework UI Library
Capital Framework is a deprecated and abandoned front-end UI library developed by the Consumer Financial Protection Bureau (CFPB). It provides a collection of reusable HTML, CSS (Less), and JavaScript components designed to help build consistent user interfaces. The project's GitHub repository was archived and marked as read-only on July 10, 2020, with an explicit recommendation to migrate to the CFPB's successor design system. While the package version 11.0.1 is listed, active development ceased prior to or around the archiving date, meaning there is no ongoing maintenance, bug fixes, or new feature releases. The framework relies heavily on Less for its styling, requiring `autoprefixer` to ensure cross-browser compatibility. Its key differentiator was being the official UI framework for CFPB projects, providing a standardized, accessible base for government-related web development.
Common errors
-
Property -webkit-box-sizing is not supported by autoprefixer. Using legacy prefix instead. Autoprefixer will remove this in a future release.
cause Using a very old version of Autoprefixer or trying to prefix properties that are no longer standard or automatically handled by modern Autoprefixer versions.fixEnsure your `autoprefixer` and `postcss` (if used) dependencies are up-to-date. Configure `browserslist` correctly in your `package.json` or `.browserslistrc` file to specify your target browsers. -
NameError: variable @grid_gutter-width is undefined in ...
cause A Less variable (e.g., `@grid_gutter-width`) from Capital Framework is missing or not correctly imported/defined, often due to an incomplete or incorrect `@import` path.fixVerify that all necessary Capital Framework Less files, especially `cf-core.less` or `capital-framework.less` which define global variables, are correctly imported at the beginning of your main Less file. -
Error: `npm install less less-plugin-autoprefixer` failed with exit code 1
cause Issues during installation of `less` or `less-plugin-autoprefixer`, potentially due to Node.js version incompatibility, network issues, or corrupted npm cache.fixClear your npm cache (`npm cache clean --force`), ensure you're using a compatible Node.js version, and try installing again. Check npm output for more specific error details related to compilation or peer dependencies.
Warnings
- breaking The entire `capital-framework` project was officially deprecated and archived on July 10, 2020. The repository is read-only, and no further development, bug fixes, or security patches will be provided. Users are strongly advised to migrate to the CFPB's newer design system.
- breaking Version 1.0.0 changed the build process to use Less `@import` statements for component inclusion instead of Grunt concatenation. This significantly alters how projects should consume and build Capital Framework styles.
- breaking Version 8.0.0 involved a transition to Lerna for monorepo management. While described as an internal change, this often implies changes in package structure, file paths, or build configurations that could break consumer projects relying on specific internal module layouts or build processes. It affected several sub-packages like `cf-buttons`, `cf-core`, etc.
- gotcha The compiled Capital Framework CSS will not work perfectly in older browsers without being run through Autoprefixer. The README explicitly warns about this necessity.
Install
-
npm install capital-framework -
yarn add capital-framework -
pnpm add capital-framework
Imports
- cf-core
import { CfCore } from 'capital-framework';@import "capital-framework/less/cf-core";
- cf-buttons
require('capital-framework/cf-buttons.css');@import "capital-framework/less/cf-buttons";
- All components
import 'capital-framework';
@import "capital-framework/less/capital-framework.less";
Quickstart
{
"name": "my-capital-framework-project",
"version": "1.0.0",
"description": "Demonstrates basic usage of Capital Framework.",
"scripts": {
"build:less": "lessc --autoprefix=\"> 0.5%, not dead\" src/index.less dist/index.css"
},
"dependencies": {
"capital-framework": "^11.0.1",
"less": "^4.0.0",
"less-plugin-autoprefixer": "^2.0.0"
}
}
// src/index.less
@import "../node_modules/capital-framework/less/capital-framework.less";
body {
padding: 1rem;
}
.wrapper {
max-width: 960px;
margin: 0 auto;
.cf-btn {
margin-right: 10px;
}
}
// public/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Capital Framework Demo</title>
<link rel="stylesheet" href="./dist/index.css">
</head>
<body>
<div class="wrapper">
<h1>Welcome to Capital Framework</h1>
<button class="cf-btn cf-btn__primary">Primary Button</button>
<button class="cf-btn cf-btn__secondary">Secondary Button</button>
<p class="cf-text">This is a paragraph styled by Capital Framework.</p>
</div>
</body>
</html>