User-friendly query builder for React
The npm package “react-awesome-query-builder” is a user-friendly React component that allows users to build queries or filters. It is inspired by jQuery QueryBuilder and supports various UI frameworks such as Ant Design, Material-UI, Bootstrap, and Fluent UI. The library offers highly configurable features and supports different types of fields, comparison operators, and RHS and LHS values. It also includes features like reordering, theme support, export/import functionality, TypeScript support, and server-side functionality. The package is divided into different packages based on the UI framework used, making it easy to install and use.
To install and use the react-awesome-query-builder package with Material-UI, follow these steps:
npm install -g pnpm
pnpm install @react-awesome-query-builder/ui @react-awesome-query-builder/mui
import {
Query,
Builder,
BasicConfig
} from "@react-awesome-query-builder/ui";
import "@react-awesome-query-builder/styles/css/compact.css";
const config = new BasicConfig([/* add your fields and operators here */]);
function App() {
return (
<Query config={config}>
{(queryProps) => (
<div>
<Builder {...queryProps} />
<pre>{JSON.stringify(queryProps.query, null, 2)}</pre>
</div>
)}
</Query>
);
}
export default App;
For more detailed usage examples and documentation, refer to the API and config and demo apps sections.
The react-awesome-query-builder package is a versatile and customizable React component that allows users to easily build queries or filters in their web applications. It offers support for various UI frameworks, highly configurable options, and different export/import formats. With its user-friendly interface and powerful features, it provides a convenient solution for implementing query building functionality in React applications.