Getting Started
Manifoldβs Web Component UI library, powered by Stencil.
Installation
npm i @manifoldco/ui
Usage
Manifold UI can be used in any frameworkless project (βvanillaβ JS), or any modern framework like React, Vue, or Angular.
Framework | Supported? |
---|---|
Vanilla JS (no framework) | β |
Angular | β |
React | β |
Vue | β |
Ember | β |
In any setup, you can use our CDN for UI:
<!-- latest (beware of breaking changes!) -->
<script src="https://js.cdn.manifold.co/@manifoldco/ui/dist/manifold.js"></script>
<!-- specific version -->
<script src="https://js.cdn.manifold.co/@manifoldco/ui@0.6.0/dist/manifold.js"></script>
HTML (ES Modules)
<head>
<link
rel="stylesheet"
type="text/css"
href="https://js.cdn.manifold.co/@manifoldco/ui/dist/manifold/manifold.css"
/>
</head>
<body>
<manifold-connection>
<manifold-marketplace></manifold-marketplace>
</manifold-connection>
<script type="module">
import { defineCustomElements } from 'https://js.cdn.manifold.co/@manifoldco/ui/dist/esm/es2017/manifold.define.js';
defineCustomElements(window);
</script>
</body>
HTML (No ESM Support)
<head>
<link
rel="stylesheet"
type="text/css"
href="https://js.cdn.manifold.co/@manifoldco/ui/dist/manifold/manifold.css"
/>
</head>
<body>
<manifold-connection>
<manifold-marketplace></manifold-marketplace>
</manifold-connection>
<script src="https://js.cdn.manifold.co/@manifoldco/ui/dist/manifold.js"></script>
</body>
React
You may choose to load Manifold UI asynchrously with a dynamic import, or synchronously with a regular import.
Asynchronous:
import React from 'react';
import ReactDOM from 'react-dom';
import '@manifoldco/ui/dist/manifold/manifold.css';
import(/* webpackChunkName: "manifold-ui" */ '@manifoldco/ui/dist/loader').then(
({ defineCustomElements }) => defineCustomElements(window)
);
const App = () => (
<manifold-connection>
<manifold-marketplace></manifold-marketplace>
</manifold-connection>
);
ReactDOM.render(<App />, document.getElementById('root'));
Synchronous:
import React from 'react';
import ReactDOM from 'react-dom';
import '@manifoldco/ui/dist/manifold/manifold.css';
import { defineCustomElements } from '@manifoldco/ui/dist/loader';
defineCustomElements(window);
const App = () => (
<manifold-connection>
<manifold-marketplace></manifold-marketplace>
</manifold-connection>
);
ReactDOM.render(<App />, document.getElementById('root'));
TypeScript + JSX setup
When using UI with TypeScript, youβll likely see an error like this:
Property 'manifold-connection' does not exist on type 'JSX.IntrinsicElements'
To solve that, create a custom-elements.d.ts
file somewhere inside your project (must be inside
the include option in tsconfig.json
):
import { Components, JSX as LocalJSX } from '@manifoldco/ui/dist/loader';
import { DetailedHTMLProps, HTMLAttributes } from 'react';
type StencilProps<T> = {
[P in keyof T]?: Omit<T[P], 'ref'>;
};
type ReactProps<T> = {
[P in keyof T]?: DetailedHTMLProps<HTMLAttributes<T[P]>, T[P]>;
};
type StencilToReact<T = LocalJSX.IntrinsicElements, U = HTMLElementTagNameMap> = StencilProps<T> &
ReactProps<U>;
declare global {
export namespace JSX {
interface IntrinsicElements extends StencilToReact {}
}
}
This will expose the types from Stencil to JSX, and youβll be able to get typechecking as you write.
Note: Every element will have to be declared manually, at least until this PR is merged in TypeScript core.
Ember, Angular, Vue, and others
Initializing Manifold UI works the same as any other Stencil project. For more advanced instructions on integrating with your specific stack, please refer to Stencilβs docs on integration.