JSPM

  • Created
  • Published
  • Downloads 1304
  • Score
    100M100P100Q114306F
  • License MIT

Custom Bootstrap components for react-querybuilder

Package Exports

  • @react-querybuilder/bootstrap
  • @react-querybuilder/bootstrap/dist/index.cjs.js
  • @react-querybuilder/bootstrap/dist/index.es.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@react-querybuilder/bootstrap) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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.

Installation

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

Usage

import {
  bootstrapControlClassnames,
  bootstrapControlElements,
} from '@react-querybuilder/bootstrap';
import { QueryBuilder, RuleGroupType } from 'react-querybuilder';
import 'bootstrap/scss/bootstrap.scss';

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

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

  return (
    <QueryBuilder
      fields={fields}
      query={query}
      onQueryChange={q => setQuery(q)}
      controlClassnames={bootstrapControlClassnames}
      controlElements={bootstrapControlElements}
    />
  );
};

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

.queryBuilder .form-control,
.queryBuilder .form-select {
  display: inline-block;
  width: auto;
}