ai-thing is an innovative React utility that generates UI components directly from natural language descriptions. Whether you need to rapidly prototype or want to streamline your development process, ai-thing accelerates component creation by interpreting plain English into fully functional React components.
The library supports multiple UI frameworks, including Material-UI (MUI), Bootstrap, Ant Design, Chakra UI, and Semantic UI, allowing you to configure your project with the framework of your choice.
Install ai-thing via npm:
npm install ai-thing
Start by configuring your preferred UI framework. ai-thing supports MUI, Bootstrap, Ant Design, Chakra UI, and Semantic UI. You can switch frameworks at any time.
import aiThing from 'ai-thing';
// Configure the framework (e.g., MUI, Bootstrap, etc.)
aiThing.configureFramework('mui');
Use ai.gen
to describe your components in natural language. ai-thing will translate these descriptions into ready-to-use React components.
const Button = await aiThing.gen('A large blue button labeled "Submit"');
const Layout = await aiThing.gen('A grid layout with 3 equally spaced columns.');
const Select = await aiThing.gen('A dropdown menu with options: Podcast, Book, Movie.');
The components returned by aiThing.gen
are React components that you can directly use in your application. You can also pass additional props when rendering them.
export const App = () => {
return (
<Layout>
<Select />
<Button disabled />
</Layout>
);
};
import aiThing from 'ai-thing';
aiThing.configureFramework('bootstrap');
const App = async () => {
const Button = await aiThing.gen('A primary button labeled "Continue"');
const Input = await aiThing.gen('A text input field with a placeholder "Enter your name"');
return (
<div>
<Input />
<Button />
</div>
);
};
resetFramework: () => {
framework = 'mui';
}
Resets the current framework to Material-UI (MUI).
getComponentType: async (description) => {
return parseDescription(description);
}
Parses a natural language description to determine the type of component.
getComponent: async (componentType) => {
return getComponent(componentType, getFramework());
}
Fetches the component based on the component type and the current framework.
getFramework: () => {
return getFramework();
}
Returns the current UI framework being used.
getFrameworks: () => {
return ['mui', 'bootstrap', 'ant-design', 'chakra', 'semantic-ui', 'materialize', 'tailwind', 'grommet', 'evergreen', 'rebass', 'baseui', 'carbon', 'fluentui', 'elasticui', 'blueprint', 'gestalt', 'reakit', 'rimble', 'theme-ui', 'vuetify', 'quasar', 'buefy', 'element', 'vue-material', 'vuesax'];
}
Returns a list of all supported UI frameworks.
ai-thing currently supports the following React UI frameworks:
Feel free to suggest other frameworks or contribute to expanding the supported frameworks!
We use Jest for testing. If you’d like to run the tests:
Install the dependencies:
npm install
Run the tests:
npm test
This will run the suite of unit tests that ensure the functionality of the NLP parser, component mapper, and overall framework integration.
We welcome contributions from the community! Here are some ways you can help:
git checkout -b my-feature
.git commit -m 'Add some feature'
.git push origin my-feature
.ai-thing is licensed under the MIT License. For more details, please refer to the LICENSE file.
By collaborating on this project, we can make ai-thing even more powerful and versatile. Happy coding!