Elemental UI Framework
Elemental is an open-source React & CSS UI Framework designed for building web applications, developed by Thinkmill. The project's latest version is 0.6.1, and its primary focus was to provide a modular set of UI components built to natively implement React patterns, particularly for use with KeystoneJS. While the original vision included being 'currently under development' and responsive to feedback for API experimentation and styling transitions, the project has not seen updates since around 2017, making it effectively abandoned. It supported older React versions (0.14 and 15) and leveraged LESS for styling, requiring a LESS compiler in the build process. Key differentiators included its unopinionated default style and flexible theming capabilities, built upon React.js, LESS, Babel, and Gulp.
Common errors
-
Error: Invariant Violation: Minified React error #XXX; visit https://reactjs.org/docs/error-decoder.html?invariant=XXX for the full message.
cause This generic React error often indicates a mismatch between Elemental UI's expected React environment (very old versions) and the React version installed in your project, or a misuse of old React APIs.fixVerify that your `react` and `react-dom` peer dependencies exactly match the `^0.14.0 || ^15.0.0` range specified by Elemental. Downgrade your React versions if necessary, or use `npm install --legacy-peer-deps` (if applicable) to force install compatible versions. -
Module not found: Error: Can't resolve 'elemental/less/elemental.less' in 'your-app-path'
cause The main LESS stylesheet for Elemental UI is not being correctly resolved or imported by your build system, or `less-loader` is not configured.fixEnsure `less-loader` is installed and properly configured in your Webpack (or equivalent) setup to handle `.less` files. Add `@import '~elemental/less/elemental.less';` to your main stylesheet. Verify `node_modules` is included in your loader paths. -
TypeError: Cannot read property 'propTypes' of undefined
cause This often occurs when trying to use React components that rely on the `React.PropTypes` API, which was removed in React v15.5. Elemental UI predates this change.fixWhile `prop-types` package can polyfill this for *some* cases, the fundamental incompatibility with modern React due to other API changes remains. The only true fix is to use Elemental with `react@<15.5` or migrate to a new UI library.
Warnings
- breaking Elemental UI is built for React versions `^0.14.0 || ^15.0.0`. It is incompatible with modern React versions (16+), requiring significant polyfills or wrappers, and will likely break without extensive modifications due to changes in React's API and lifecycle methods.
- gotcha Elemental UI relies on LESS for its styling. You must configure your build process (e.g., Webpack with `less-loader`) to compile and include the `elemental.less` stylesheet, otherwise components will render unstyled.
- breaking The Elemental UI project is effectively abandoned, with its last npm publish and GitHub activity dating back approximately seven years (as of late 2017). This means no further bug fixes, security updates, or feature development will occur.
- gotcha The peer dependency `react-addons-css-transition-group` is deprecated in modern React. Using Elemental UI with newer React setups might lead to warnings or require manual integration of `react-transition-group` (its spiritual successor), if a compatible version can even be found for the old React versions Elemental requires.
Install
-
npm install elemental -
yarn add elemental -
pnpm add elemental
Imports
- Button
const { Button } = require('elemental');import { Button } from 'elemental'; - Alert
import Alert from 'elemental/lib/Alert';
import { Alert } from 'elemental'; - Spinner
import * as Elemental from 'elemental'; const MySpinner = Elemental.Spinner;
import { Spinner } from 'elemental';
Quickstart
import React from 'react';
import ReactDOM from 'react-dom';
import { Button, Alert, Spinner } from 'elemental';
// Elemental's styles are written in LESS and need to be imported or compiled.
// For a modern setup, you would typically configure your build tool (e.g., Webpack)
// to process LESS files and import the main stylesheet.
// E.g., in your main JS/TS entry file or a global CSS file:
// @import './node_modules/elemental/less/elemental.less';
// Or compile it via CLI: lessc ./node_modules/elemental/less/elemental.less styles.min.css
function App() {
const [showAlert, setShowAlert] = React.useState(false);
return (
<div>
<h1>Elemental UI Demo</h1>
<Button onClick={() => alert('Hello from Elemental!')} type="primary">
Click Me
</Button>
<Button onClick={() => setShowAlert(!showAlert)} type="link">
Toggle Alert
</Button>
{showAlert && (
<Alert type="info">
This is an Elemental Alert!
<Button type="link" onClick={() => setShowAlert(false)}>Close</Button>
</Alert>
)}
<div style={{ padding: '20px' }}>
<Spinner size="lg" />
</div>
</div>
);
}
ReactDOM.render(<App />, document.getElementById('root'));