@react-querybuilder/bootstrap
TypeScript icon, indicating that this package has built-in type declarations

7.2.0 • Public • Published

@react-querybuilder/bootstrap

Official react-querybuilder components for Bootstrap.

To see them in action, check out the react-querybuilder demo or load the example in CodeSandbox.

Full documentation

Installation

npm i react-querybuilder @react-querybuilder/bootstrap bootstrap bootstrap-icons
# OR yarn add / pnpm add / bun add

Usage

To render Bootstrap-compatible components in the query builder, wrap the <QueryBuilder /> element in <QueryBuilderBootstrap />.

import { QueryBuilderBootstrap } from '@react-querybuilder/bootstrap';
import 'bootstrap-icons/font/bootstrap-icons.scss';
import 'bootstrap/scss/bootstrap.scss';
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 (
    <QueryBuilderBootstrap>
      <QueryBuilder fields={fields} query={query} onQueryChange={setQuery} />
    </QueryBuilderBootstrap>
  );
};

Notes

  • Some additional styling may be necessary, e.g.:

    .queryBuilder .form-control,
    .queryBuilder .form-select {
      display: inline-block;
      width: auto;
    }
  • This package exports bootstrapControlClassnames and bootstrapControlElements which can be assigned directly to the controlClassnames and controlElements props, respectively, on <QueryBuilder /> (each component is also exported individually). However, the recommended usage is to wrap a <QueryBuilder /> element in <QueryBuilderBootstrap />.

Readme

Keywords

none

Package Sidebar

Install

npm i @react-querybuilder/bootstrap

Weekly Downloads

1,022

Version

7.2.0

License

MIT

Unpacked Size

102 kB

Total Files

20

Last publish

Collaborators

  • jakeboone02