Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 1.33 KB

README.md

File metadata and controls

40 lines (28 loc) · 1.33 KB

@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