@public-ui/react
Version:
React framework adapter for KoliBri - The accessible HTML-Standard.
58 lines (43 loc) • 2.02 kB
Markdown
# KoliBri - React-Adapter
[](https://www.npmjs.com/package/@public-ui/components)
[](https://github.com/public-ui/kolibri/blob/main/LICENSE)
[](https://www.npmjs.com/package/@public-ui/react)
[](https://github.com/public-ui/kolibri/issues)
[](https://github.com/public-ui/kolibri/pulls)
[](https://bundlephobia.com/result?p=@public-ui/react)

## Motivation
Provide an adapter for [React](https://reactjs.org) to use the KoliBri components.
## Installation
Install the adapter with `npm`, `pnpm` or `yarn`:
```bash
npm i @public-ui/react
pnpm i @public-ui/react
yarn add @public-ui/react
```
## Usage
First, initialize KoliBri with a [theme](https://github.com/public-ui/kolibri/tree/develop/packages/themes) and create a React root:
```ts
import { defineCustomElements } from '@public-ui/components/dist/loader';
import { register } from '@public-ui/components';
import { DEFAULT } from '@public-ui/theme-default';
register(DEFAULT, defineCustomElements)
.then(() => {
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<App />
</React.StrictMode>
);
})
.catch((error) => {
/* Handle errors */
});
```
Then, you can import any component from `@public-ui/react` and render it within React components:
```tsx
import React from 'react';
import type { FC } from 'react';
import { KolButton } from '@public-ui/react';
export default (): FC => <KolButton _label="Hello World" />;
```
For available design tokens see the [default theme README](../../themes/default/README.md).