Skip to content

A flexible middlewares driven json schema form with Chakra UI

License

Notifications You must be signed in to change notification settings

gravel-form/chakra-ui-form

Repository files navigation

@gravel-form/chakra-ui

A flexible middlewares driven json schema form. The only limitation is your imagination.

Quick start

npm install @chakra-ui/core @emotion/core @emotion/styled emotion-theming
npm install @gravel-form/chakra-ui
import React from 'react';
import { theme, ThemeProvider, CSSReset } from '@chakra-ui/core';
import { Form } from '@gravel-form/chakra-ui/lib';

function MyFirstForm() {
  const schema = {
    type: 'object',
    properties: {
      username: { type: 'string' },
      password: { type: 'string' },
    },
  };

  const extraProps = {
    properties: {
      password: {
        props: { type: 'password' },
      },
    },
  };

  const [data, setData] = React.useState();

  return (
    <Form
      schema={schema}
      extraProps={extraProps}
      data={data}
      onChange={setData}
      size="md"
      onSubmit={(data) => {
        alert(JSON.stringify(data, null, 2));
      }}
    />
  );
}

function App() {
  return (
    <ThemeProvider theme={theme}>
      <CSSReset />
      <MyFirstForm />
    </ThemeProvider>
  );
}

export default App;

Playground

More examples can be found on the playground.

About

A flexible middlewares driven json schema form with Chakra UI

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published