CodyHouse Framework v3
CodyHouse Framework v3 is a lightweight, front-end framework primarily built with SCSS for creating accessible and custom user interfaces. It emphasizes a 'no override' approach using CSS custom properties and provides a foundational set of CSS rules and utility classes. While the current stable version discussed here is v3.0.14, the project actively promotes v4.0.0 as the latest major release, suggesting v3 is now in a maintenance or legacy state with no further feature development or breaking changes expected. Its key differentiators include a focus on accessibility, ease of learning, and seamless integration with CodyHouse's library of HTML, CSS, and JS components and visual Global Editors for design system management.
Common errors
-
Error: Node Sass does not yet support your current environment: OS X 64-bit with Node.js X.X.X
cause Incompatibility between the `node-sass` version used by Gulp/Webpack and your Node.js version. `node-sass` is often sensitive to Node.js updates.fixUpdate `node-sass` and related dependencies to versions compatible with your Node.js installation. Often, running `npm rebuild node-sass` or `npm update` can resolve this. Alternatively, consider migrating to `sass` (Dart Sass) which is more actively maintained and less prone to Node.js version issues. -
ReferenceError: require is not defined in ES module scope
cause Attempting to use CommonJS `require()` syntax in an ES module (`.mjs` or `type: "module"` in `package.json`).fixCodyHouse Framework's `util.js` is not an ES module. If you need to include it in an ES module context, you'll need a bundler (like Webpack or Rollup) to handle its CommonJS-like inclusion. For direct browser use, include it via a `<script>` tag. -
CSS custom property `--color-primary` is not defined
cause Trying to use a CSS custom property (variable) that hasn't been defined in your active stylesheet or accessible scope.fixEnsure that your `_colors.scss` (or equivalent file where custom properties are defined) is correctly imported and compiled into your final `style.css`. Verify the variable name is correct and global custom properties are accessible.
Warnings
- breaking CodyHouse Framework v4 has been released and is actively promoted. While v3.x has received no breaking changes, users should be aware that future development and new features will focus on v4, making v3 a legacy version.
- gotcha The framework primarily uses SCSS and CSS custom properties. While it ships with compiled CSS, direct customization is intended through SCSS variables and partials, requiring a build process (e.g., Gulp, Webpack) for optimal use.
- gotcha The `util.js` file is a collection of global utility functions, primarily used by CodyHouse's separate component library. It is designed to be included as a standard script, not an ES module, and relies on being present before component-specific scripts.
Install
-
npm install codyhouse-framework -
yarn add codyhouse-framework -
pnpm add codyhouse-framework
Imports
- CSS Stylesheet
@import 'codyhouse-framework/main/assets/css/style.css';
<link rel="stylesheet" href="/path/to/codyhouse-framework/main/assets/css/style.css">
- SCSS Custom Styles
@import 'custom-style/your-custom-file';
@import 'codyhouse-framework/main/assets/css/custom-style/your-custom-file';
- util.js
import { util } from 'codyhouse-framework/main/assets/js/util.js';<script src="/path/to/codyhouse-framework/main/assets/js/util.js"></script>
- JavaScript Enabled Check
if (typeof window !== 'undefined') { document.documentElement.classList.add('js'); }<script>document.getElementsByTagName("html")[0].className += " js";</script>
Quickstart
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CodyHouse Framework Quickstart</title>
<script>document.getElementsByTagName("html")[0].className += " js";</script>
<!-- Link the compiled CSS from your build process or directly from node_modules -->
<link rel="stylesheet" href="./node_modules/codyhouse-framework/main/assets/css/style.css">
<style>
/* Custom styles using framework variables */
:root {
--color-primary-dark: hsl(210, 50%, 20%);
}
.my-custom-heading {
color: var(--color-primary-dark);
font-size: var(--text-xxl);
margin-bottom: var(--space-md);
}
</style>
</head>
<body>
<header class="container padding-y-md">
<h1 class="my-custom-heading">Welcome to CodyHouse Framework</h1>
<p class="color-contrast-medium text-sm">A lightweight, accessible front-end framework.</p>
</header>
<main class="container padding-y-lg">
<button class="btn btn--primary margin-right-sm">Primary Button</button>
<button class="btn btn--secondary">Secondary Button</button>
<div class="grid gap-md margin-top-lg">
<div class="col-6@md text-component">
<p>This is a column using the framework's grid system. CodyFrame provides a flexible grid for responsive layouts.</p>
<p>Text components allow for easy styling of paragraph elements without applying individual classes.</p>
</div>
<div class="col-6@md bg-primary-light radius-md padding-md text-component">
<p>Another column with a light primary background and rounded corners. Utility classes like <code>bg-primary-light</code>, <code>radius-md</code>, and <code>padding-md</code> are used here.</p>
</div>
</div>
</main>
<footer class="container padding-y-md text-center border-top-alpha">
<p class="text-sm color-contrast-low">Built with CodyHouse Framework.</p>
</footer>
<!-- Include the utility JS file if using CodyHouse components -->
<script src="./node_modules/codyhouse-framework/main/assets/js/util.js"></script>
</body>
</html>