Checkbox Cards
The CheckboxCards component provides a user-friendly interface for toggling between checked and unchecked states, with customizable labels and state management.
Installation
Install the package
npm i @start-base/react-form-elementsAdd the styles
To use the React form elements styles in a Next.js project, import the styles in your layout.tsx file.
app/layout.tsx
import "@start-base/react-form-elements/styles.css";Import the component
import CheckboxCards from '@start-base/react-form-elements/CheckboxCards';Usages
Checkbox Cards Component Checked
Checkbox Option 1
Checkbox Option 2
Checkbox Cards Component Row
Checkbox Option 1
Checkbox Option 2
Checkbox Cards Component Disabled
Checkbox Option 1
Checkbox Option 2
Checkbox Cards Component With Input
Checkbox Option 1
Checkbox Option 2
Checkbox Cards Component Error
Checkbox Option 1
Checkbox Option 2
Error Message
API
A card-style checkbox group component for enhanced visual presentation.
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | Name of the input | |
| label | string | null | Label of the input |
| value | string or number | Value of the input | |
| onChange | function | Callback function that is fired when the value changes. | |
| inputClassName | string | null | Classname for input element |
| labelClassName | string | null | Classname for label element |
| errorClassName | string | null | Classname for error element |
| disabled | boolean | false | Disable the input |
| error | string or boolean or object | null | Error message to display below the input. if value is a boolean input border will be change. Also you can pass schema validator error objects. |
| options | array | [] | Array of options to display |
| optionLabelClassName | string | null | Classname for option label |
| cardClassName | string | null | Classname for option card |
| direction | string | column | Options direction column or row |
| hideInput | boolean | true | Input hide option |