Condition editor row
A card that edits one rule condition with a field, an operator, a value and a case-sensitivity switch.
Desativado ignora maiúsculas.
Change the operator, type a value and use the switch. The remove button is in the top corner of the card.
When to use
- To edit a list of conditions of a rule, where each condition compares a field of a case with a value: “parte.autora.nome contém Silva”.
- When the same editor must appear on a wide page and in a narrow side panel (
layout).
When not to use
- A single filter above a table. Use Select and an Input in the toolbar.
- A field with several unrelated settings. Use a Form with its own layout.
- Choosing only the field. Use Combobox directly.
The row is composed of other components: the operator is a Select, the field slot is usually a Combobox, and the value slot is an Input.
Layouts
Stacked
Field and operator share a row above the value. Use it in side panels and narrow containers. It is the default.
Desativado ignora maiúsculas.
Inline
Field, operator, value and switch share one row from the xl viewport width (1280px) upward. Below it the card falls back to two columns, then one.
Desativado ignora maiúsculas.
States
With errors
Pass fieldPathError and valueError. The card changes to the warning tone and each message is shown under its control with role="alert".
Selecione um campo.
Informe o valor da condição.
Desativado ignora maiúsculas.
Content
- Labels are single words: “Campo”, “Operador”, “Valor”, “Maiúsculas”.
- Operators read as a sentence between field and value: “É igual a”, “Contém”, “Começa com”.
- Error messages say how to fix it: “Selecione um campo.”, “Informe o valor da condição.”
- The
*HelpTooltiptexts explain, in one sentence, what the control does. Every tooltip needs its*InfoLabelas the accessible name of the info icon. - The component has no built-in copy, so pass all labels from the app, translated.
Accessibility
- The operator select is a Base UI Select: a
buttonwithrole="combobox"that opens alistbox, with arrow keys, typeahead andEscape(see Select). - Labels are linked to controls: the operator label with
htmlForand the triggerid; the case switch witharia-labeland a labelhtmlFor. For a field slot that is not a native input, passfieldLabelIdand point the slot’s accessible name at it; for a native input, passfieldInputId. - Error texts use
role="alert", so they are announced when they appear. They carry the ids{idPrefix}-field-errorand{idPrefix}-value-error. Put these inaria-describedbyof your slots. - Mark the slots with
aria-invalidwhen there is an error. The row does not set it for you. - The remove button is an icon button named by
removeLabel, with a tooltip of the same text. - The invalid state is shown by color and by the messages. The card also sets
data-invalid.
Code
import { ConditionEditorRow } from "@repo/ui/condition-editor-row";
<ConditionEditorRow
caseSensitive={condition.caseSensitive}
caseSensitiveLabel="Maiúsculas"
fieldHelpTooltip="Campo do processo usado na condição."
fieldInfoLabel="Ajuda sobre o campo"
fieldLabel="Campo"
fieldLabelId="condition-1-field-label"
fieldSlot={<Combobox ariaLabel="condition-1-field-label" … />}
idPrefix="condition-1"
onCaseSensitiveChange={setCaseSensitive}
onOperatorChange={setOperator}
onRemove={removeCondition}
operator={operator}
operatorLabel="Operador"
operators={[{ label: "Contém", value: "contains" }]}
removeLabel="Remover condição"
valueHelpTooltip="Texto a procurar no campo."
valueInfoLabel="Ajuda sobre o valor"
valueLabel="Valor"
valueSlot={<Input aria-label="Valor" … />}
/>;
Props
ConditionEditorRow| Prop | Type | Default | Description |
|---|---|---|---|
caseSensitive | boolean | — | State of the case-sensitivity switch |
fieldSlot | ReactNode | — | The control that picks the field, usually a Combobox. Not rendered by the row, so it owns its value |
idPrefix | string | — | Prefix of the generated ids (`-operator`, `-case-sensitive`, `-field-error`, `-value-error`). Unique per row |
layout | "inline" | "stacked" | "stacked" | `inline` keeps everything on one row on wide viewports; `stacked` always puts field and operator above the value |
onOperatorChange | (operator: TOperator) => void | — | Called with the chosen operator value |
operator | TOperator | — | Selected operator value |
operators | { value: TOperator; label: string }[] | — | Operator options shown in the select |
valueSlot | ReactNode | — | The control that edits the value, usually an Input |
More props| Prop | Type | Default | Description |
|---|---|---|---|
fieldInputId | string | — | Id of a native control in `fieldSlot`; pairs the label through `htmlFor`. |
fieldLabelId | string | — | Id given to the field label, for a non-native control that reads it with `aria-labelledby`. Must differ from any id the slot renders. |
fieldLabel / fieldInfoLabel / fieldHelpTooltip | string | — | Label, accessible name of its info icon, and the tooltip text. Required. |
fieldPathError | string | — | Error under the field slot. |
operatorLabel | string | — | Label of the operator select. Required. |
operatorInfoLabel / operatorHelpTooltip | string | — | Optional tooltip for the operator. |
valueLabel | string | — | Label above the value slot. Required. |
valueInfoLabel / valueHelpTooltip | string | — | Optional tooltip for the value. |
valueError | string | — | Error under the value slot. |
onCaseSensitiveChange | (checked: boolean) => void | — | Called when the switch changes. Required. |
caseSensitiveLabel | string | — | Label of the switch. Required. |
caseSensitiveHelperText | string | — | Small text under the switch label. |
caseSensitiveInfoLabel / caseSensitiveHelpTooltip | string | — | Optional tooltip for the switch. |
removeLabel | string | — | Name and tooltip of the remove button. Required. |
onRemove | () => void | — | Called by the remove button. Required. |
popoverContainer | HTMLElement | null | — | Portal target of the operator list, for use inside a Dialog or Sheet. |
Known issues
| Issue | Effect |
|---|---|
The valueLabel Label has no htmlFor and the valueSlot has no id. |
Clicking the label does not focus the value control; the caller must give the control its own aria-label. |
| The error ids are generated but nothing references them. | A screen reader does not link an error to its field unless the caller adds aria-describedby to the slot. |
The inline layout switches at viewport breakpoints (md, xl), not at the width of the container. |
In a narrow panel on a wide screen, inline squeezes the four columns; use layout="stacked" there. |
The invalid card uses border-warning bg-warning while the message uses text-critical. |
Mixed severity: a warning card holding red text. |