Installation
Monochrome is distributed as a single package that includes the core runtime and wrappers for React and Vue.Package managers
Import paths
Monochrome provides three entry points:Core runtime
The core runtime must be imported once at your app’s entry point. It automatically activates and handles all component interactions through event delegation:The core has side effects — it registers global event listeners for
click, keydown, pointermove, scroll, resize, and beforematch. Import it once in your main entry file.React
Import React components frommonochrome/react:
- React 18 or higher
- React DOM 18 or higher
Vue
Import Vue components frommonochrome/vue:
- Vue 3.5 or higher
Vue components use
provide/inject for component context and work with both Vue 3 Composition API and Options API.Plain HTML (no framework)
Monochrome works with plain HTML. Include the script from a CDN:TypeScript
Monochrome is written in TypeScript and includes type definitions. React exports theBaseProps type for extending components:
Package exports
The package provides three exports configured inpackage.json:
| Export | Types | Runtime |
|---|---|---|
monochrome | ./dist/index.d.ts | ./dist/index.js |
monochrome/react | ./dist/react/index.d.ts | ./dist/react/index.js |
monochrome/vue | ./dist/vue/index.d.ts | ./dist/vue/index.js |
Peer dependencies
React and Vue are optional peer dependencies. You only need to install the framework you’re using:Bundle size
The entire library including all four components is 2.2kB gzipped:- Core runtime: ~550 lines, single file
- React wrappers: thin
createElement()render functions - Vue wrappers: thin
h()render functions
Next steps
Quick Start
Build your first accordion component
Components
Explore all available components