- Code
- Export
- Import
- Theme builder
Dependencies
App.tsx
import { useState } from 'react';
import type { RuleGroupType } from 'react-querybuilder';
import { QueryBuilder } from 'react-querybuilder';
import { fields } from './fields';
import 'react-querybuilder/dist/query-builder.css';
import './styles.css';
import { QueryBuilderBootstrap } from '@react-querybuilder/bootstrap';
import 'bootstrap-icons/font/bootstrap-icons.scss';
import 'bootstrap/scss/bootstrap.scss';
const initialQuery: RuleGroupType = { combinator: 'and', rules: [] };
export const App = () => {
const [query, setQuery] = useState(initialQuery);
return (
<QueryBuilderBootstrap>
<QueryBuilder fields={fields} query={query} onQueryChange={setQuery} />
</QueryBuilderBootstrap>
);
};
Styles
Other files
- JSON
- SQL
- MongoDB
- CEL
- SpEL
- JsonLogic
- ElasticSearch
- JSONata
- Natural language
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
Call
import { formatQuery } from 'react-querybuilder';
formatQuery(query, 'json_without_ids');
Return
{
"combinator": "and",
"not": false,
"rules": [
{
"field": "firstName",
"value": "Stev",
"operator": "beginsWith"
},
{
"field": "lastName",
"value": "Vai, Vaughan",
"operator": "in"
},
{
"field": "age",
"operator": ">",
"value": "28"
},
{
"combinator": "or",
"rules": [
{
"field": "isMusician",
"operator": "=",
"value": true
},
{
"field": "instrument",
"operator": "=",
"value": "Guitar"
}
]
},
{
"field": "groupedField1",
"operator": "=",
"value": "groupedField4",
"valueSource": "field"
},
{
"field": "birthdate",
"operator": "between",
"value": "1954-10-03,1960-06-06"
}
]
}
- SQL
- MongoDB
- JsonLogic
- SpEL
- CEL
- JSONata
SQL can either be the full SELECT
statement or the WHERE
clause by itself. Trailing semicolon is optional.
Available fields
Input must conform to the JSON specification. MongoDB queries support an extended JSON format, so you may need to pre-parse query strings with a library like mongodb-query-parser
before submitting them here or passing them to parseMongoDB
.
Available fields
Only strings that evaluate to JavaScript objects when processed with JSON.parse
will translate into queries.
Available fields
Available fields
Available fields
Available fields
- CSS
- SCSS
@import "react-querybuilder/dist/query-builder.css";
:root {
}
@use "react-querybuilder/dist/query-builder.scss" with {
};