|
| 1 | +--- |
| 2 | +title: CSS classes |
| 3 | +hide_table_of_contents: true |
| 4 | +description: Visual guide to CSS classes for each component element |
| 5 | +--- |
| 6 | + |
| 7 | +The `<QueryBuilder />` component assigns [standard classes](./misc#defaults) to each element. In the (fully operational) query builder below, the `title` and `label` for each element have been set to the element's standard class. |
| 8 | + |
| 9 | +The following standard classnames are not visible below: |
| 10 | + |
| 11 | +- `.queryBuilder` (black outline; the outer-most `<div>`) |
| 12 | +- `.ruleGroup` (maroon outline) |
| 13 | +- `.ruleGroup-header` (purple outline) |
| 14 | +- `.ruleGroup-body` (blue outline) |
| 15 | +- `.rule.queryBuilder-disabled` (gray outline for locked/disabled rules) |
| 16 | +- `.rule.queryBuilder-valid` (green outline for valid rules) |
| 17 | +- `.rule.queryBuilder-invalid` (red outline for invalid rules) |
| 18 | +- `.dndDragging` (applied to "preview" element while dragging) |
| 19 | +- `.dndOver` (applied to "hovered over" element while dragging) |
| 20 | + |
| 21 | +import { QueryBuilderEmbed } from '@site/src/components/QueryBuilderEmbed'; |
| 22 | +import { standardClassnames as sc } from 'react-querybuilder'; |
| 23 | + |
| 24 | +<QueryBuilderEmbed |
| 25 | + showNotToggle |
| 26 | + showCloneButtons |
| 27 | + showLockButtons |
| 28 | + enableDragAndDrop |
| 29 | + fields={[ |
| 30 | + { |
| 31 | + name: 'f1', |
| 32 | + label: `.${sc.fields}`, |
| 33 | + defaultValue: 'This rule is valid', |
| 34 | + validator: () => true, |
| 35 | + }, |
| 36 | + { |
| 37 | + name: 'f2', |
| 38 | + label: `.${sc.fields}`, |
| 39 | + defaultValue: 'This rule is invalid', |
| 40 | + validator: () => false, |
| 41 | + }, |
| 42 | + { |
| 43 | + name: 'f3', |
| 44 | + label: `.${sc.valueSource}`, |
| 45 | + valueSources: ['value', 'field'], |
| 46 | + }, |
| 47 | + { |
| 48 | + name: 'fb1', |
| 49 | + label: `Value list`, |
| 50 | + operators: [{ name: 'between', label: 'between' }], |
| 51 | + valueSources: ['field', 'value'], |
| 52 | + comparator: f => f.name === 'fb2', |
| 53 | + }, |
| 54 | + { |
| 55 | + name: 'fb2', |
| 56 | + label: `.${sc.valueListItem}`, |
| 57 | + }, |
| 58 | + ]} |
| 59 | + combinators={[{ name: 'and', label: `.${sc.combinators}` }]} |
| 60 | + getOperators={() => [{ name: '=', label: `.${sc.operators}` }]} |
| 61 | + controlClassnames={{ |
| 62 | + queryBuilder: 'rqb-structure', |
| 63 | + }} |
| 64 | + translations={{ |
| 65 | + fields: { |
| 66 | + title: `.${sc.fields}`, |
| 67 | + }, |
| 68 | + operators: { |
| 69 | + title: `.${sc.operators}`, |
| 70 | + }, |
| 71 | + value: { |
| 72 | + title: `.${sc.value}`, |
| 73 | + }, |
| 74 | + removeRule: { |
| 75 | + label: `.${sc.removeRule}`, |
| 76 | + title: `.${sc.removeRule}`, |
| 77 | + }, |
| 78 | + removeGroup: { |
| 79 | + label: `.${sc.removeGroup}`, |
| 80 | + title: `.${sc.removeGroup}`, |
| 81 | + }, |
| 82 | + addRule: { |
| 83 | + label: `.${sc.addRule}`, |
| 84 | + title: `.${sc.addRule}`, |
| 85 | + }, |
| 86 | + addGroup: { |
| 87 | + label: `.${sc.addGroup}`, |
| 88 | + title: `.${sc.addGroup}`, |
| 89 | + }, |
| 90 | + combinators: { |
| 91 | + title: `.${sc.combinators}`, |
| 92 | + }, |
| 93 | + notToggle: { |
| 94 | + label: `.${sc.notToggle}`, |
| 95 | + title: `.${sc.notToggle}`, |
| 96 | + }, |
| 97 | + cloneRule: { |
| 98 | + label: `.${sc.cloneRule}`, |
| 99 | + title: `.${sc.cloneRule}`, |
| 100 | + }, |
| 101 | + cloneRuleGroup: { |
| 102 | + label: `.${sc.cloneGroup}`, |
| 103 | + title: `.${sc.cloneGroup}`, |
| 104 | + }, |
| 105 | + dragHandle: { |
| 106 | + label: `.${sc.dragHandle}`, |
| 107 | + title: `.${sc.dragHandle}`, |
| 108 | + }, |
| 109 | + lockRule: { |
| 110 | + label: `.${sc.lockRule}`, |
| 111 | + title: `.${sc.lockRule}`, |
| 112 | + }, |
| 113 | + lockGroup: { |
| 114 | + label: `.${sc.lockGroup}`, |
| 115 | + title: `.${sc.lockGroup}`, |
| 116 | + }, |
| 117 | + lockRuleDisabled: { |
| 118 | + label: `.${sc.lockRuleDisabled}`, |
| 119 | + title: `.${sc.lockRuleDisabled}`, |
| 120 | + }, |
| 121 | + lockGroupDisabled: { |
| 122 | + label: `.${sc.lockGroupDisabled}`, |
| 123 | + title: `.${sc.lockGroupDisabled}`, |
| 124 | + }, |
| 125 | + valueSourceSelector: { |
| 126 | + title: `.${sc.valueSource}`, |
| 127 | + }, |
| 128 | + }} |
| 129 | + defaultQuery={{ |
| 130 | + combinator: 'and', |
| 131 | + rules: [ |
| 132 | + { field: 'f1', operator: '=', value: `.${sc.value}` }, |
| 133 | + { |
| 134 | + combinator: 'and', |
| 135 | + rules: [ |
| 136 | + { field: 'f1', operator: '=', value: 'This rule is valid' }, |
| 137 | + { field: 'f2', operator: '=', value: 'This rule is invalid' }, |
| 138 | + { |
| 139 | + disabled: true, |
| 140 | + combinator: 'and', |
| 141 | + rules: [ |
| 142 | + { |
| 143 | + field: 'f1', |
| 144 | + operator: '=', |
| 145 | + value: `This rule's group is disabled, therefore this rule is also disabled`, |
| 146 | + }, |
| 147 | + ], |
| 148 | + }, |
| 149 | + ], |
| 150 | + }, |
| 151 | + { field: 'f3', operator: '=', value: 'f1' }, |
| 152 | + { field: 'fb1', operator: 'between', value: 'fb2,fb2', valueSource: 'field' }, |
| 153 | + ], |
| 154 | + }} |
| 155 | +/> |
0 commit comments