error
Description
Optional. Defines whether error styling is applied to a MultiComboUsage
error?: boolean;
Parameters
- true - error styling is applied
- false - (default) error styling is not applied
Example
const dataset = [
{ id: 1, label: "First option" },
{ id: 2, label: "Second option" },
{ id: 3, label: "Third option" }
];
export const Example = () => (
<MultiCombo options={dataset} value={[1, 2]} error={true} />
);
Details
The prop is useful during form validation. If the prop is set to true
a MultiCombo gets red error styling.
To add a red error label for the control, use the error prop of the Field component:
import { MultiCombo, Field } from "@svar-ui/react-core";
export const ExampleField = () => (
<Field label="Error message" error={true}>
{({ id }) => <MultiCombo id={id} error={true} />}
</Field>
);
Related article: Styling an option validation error
Related sample: MultiCombo