Skip to content

jide/react-querybuilder-shadcn-ui

Repository files navigation

@react-querybuilder/shadcn-ui

react-querybuilder-shadcn-ui

Unofficial react-querybuilder components for shadcn/ui.

Installation

Copy and paste the src/components/react-querybuilder-shadcn-ui in your project.

Usage

To render shadcn-ui-compatible components in the query builder, wrap the <QueryBuilder /> element in <QueryBuilderShadcnUi />.

import { QueryBuilderShadcnUi } from "@/components/react-querybuilder-shadcn-ui";
import { QueryBuilder, RuleGroupType } from "react-querybuilder";

const fields = [
  { name: "firstName", label: "First Name" },
  { name: "lastName", label: "Last Name" },
];

const App = () => {
  const [query, setQuery] = useState<RuleGroupType>({
    combinator: "and",
    rules: [],
  });

  return (
    <QueryBuilderShadcnUi>
      <QueryBuilder fields={fields} query={query} onQueryChange={setQuery} />
    </QueryBuilderShadcnUi>
  );
};

Notes

About

Custom shadcn/ui components for react-querybuilder

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published