### Install Dependencies Source: https://github.com/dohomi/react-hook-form-mui/blob/master/README.md Install project dependencies using Yarn. ```bash yarn ``` -------------------------------- ### Install react-hook-form-mui and dependencies Source: https://github.com/dohomi/react-hook-form-mui/blob/master/packages/rhf-mui/README.md Install the core package and necessary Material-UI dependencies for pickers and icons. ```bash # npm install react-hook-form react-hook-form-mui # yarn add react-hook-form react-hook-form-mui ``` ```bash # npm install @mui/x-date-pickers @mui/icons-material # yarn add @mui/x-date-pickers @mui/icons-material ``` -------------------------------- ### Run Storybook Source: https://github.com/dohomi/react-hook-form-mui/blob/master/README.md Start the Storybook development server using Yarn. ```bash yarn sb-start ``` -------------------------------- ### Typesafe Form Setup with useForm Source: https://github.com/dohomi/react-hook-form-mui/blob/master/README.md A more advanced form setup demonstrating typesafety using useForm, TextFieldElement, AutocompleteElement, and CheckboxElement. ```tsx function Form() { const {control, handleSubmit} = useForm({ defaultValues: { name: '', auto: '', check: false }, }) const options = [ {id: 'one', label: 'One'}, {id: 'two', label: 'Two'}, {id: 'three', label: 'Three'}, ] return (
console.log(data))} noValidate>
) } ``` -------------------------------- ### FormContainer with External FormContext Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use this variant when you need to manage the form state externally, for example, to implement custom submit logic or reuse a form context. Pass the externally created formContext and a handleSubmit function. ```tsx import { FormContainer, TextFieldElement, useForm, } from 'react-hook-form-mui' import {Button, Stack} from '@mui/material' type LoginForm = {email: string; password: string} // ── Variant B: external formContext for custom submit logic ────────────────── function ExternalContextForm() { const formContext = useForm({ defaultValues: {email: '', password: ''}, }) const handleSubmit = formContext.handleSubmit( (data) => console.log('OK:', data), (errors) => console.error('Fail:', errors), ) return ( ) } ``` -------------------------------- ### Build Project Source: https://github.com/dohomi/react-hook-form-mui/blob/master/README.md Build the project using Yarn. ```bash yarn build ``` -------------------------------- ### Clone Repository Source: https://github.com/dohomi/react-hook-form-mui/blob/master/README.md Clone your forked repository and navigate into the project directory. Optionally, add the original repository as an upstream remote. ```bash git clone https://github.com//react-hook-form-mui.git cd react-hook-form-mui ``` ```bash git remote add upstream https://github.com/dohomi/react-hook-form-mui.git ``` -------------------------------- ### Storybook Options Configuration Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Sets configuration options for Storybook's documentation and tags features. 'defaultName' for Docs is specified here. ```javascript window.DOCS_OPTIONS = {"defaultName":"Docs"}; window.TAGS_OPTIONS = {}; ``` -------------------------------- ### Fullscreen Storybook Layout Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html CSS to make the Storybook preview take up the entire viewport. It removes all margins and padding, allowing the story to fill the screen. ```css .sb-show-main.sb-main-fullscreen { margin: 0; padding: 0; display: block; } ``` -------------------------------- ### Basic Form with TextFieldElement Source: https://github.com/dohomi/react-hook-form-mui/blob/master/packages/rhf-mui/README.md Use FormContainer to set up a form and TextFieldElement for input fields. The form state is managed by react-hook-form. ```tsx import {FormContainer, TextFieldElement} from 'react-hook-form-mui' function Form() { return ( console.log(data)} > ) } ``` -------------------------------- ### Centered Storybook Layout Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html CSS for centering the Storybook preview in the main view. It removes margins, uses flexbox for alignment, and sets a minimum viewport height. ```css .sb-show-main.sb-main-centered { margin: 0; display: flex; align-items: center; min-height: 100vh; } .sb-show-main.sb-main-centered #storybook-root { box-sizing: border-box; margin: auto; padding: 1rem; max-height: 100%; /* Hack for centering correctly in IE11 */ } ``` -------------------------------- ### Padded Storybook Layout Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html CSS to apply padding to the Storybook preview area. This creates a consistent margin around the story content. ```css .sb-show-main.sb-main-padded { margin: 0; padding: 1rem; display: block; box-sizing: border-box; } ``` -------------------------------- ### Storybook Global Configuration Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Sets global configuration variables for Storybook, including the environment type, log level, and framework/channel options. These settings influence Storybook's runtime behavior. ```javascript window.CONFIG_TYPE = 'PRODUCTION'; window.LOGLEVEL = 'info'; window.FRAMEWORK_OPTIONS = {}; window.CHANNEL_OPTIONS = {}; ``` -------------------------------- ### TextareaAutosizeElement for Multi-line Input Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Shows how to use TextareaAutosizeElement for dynamic multi-line text input. Configurable with min/max rows and resize style, suitable for comments or descriptions. ```tsx import {FormContainer, TextareaAutosizeElement} from 'react-hook-form-mui' import {Button} from '@mui/material' function CommentForm() { return ( console.log(data)} > ) } ``` -------------------------------- ### Storybook Wrapper Styles Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Defines the main wrapper styles for the Storybook UI, including fixed positioning, padding, and font settings. It ensures the UI is consistently displayed across the viewport. ```css .sb-wrapper { position: fixed; top: 0; bottom: 0; left: 0; right: 0; box-sizing: border-box; padding: 40px; font-family: 'Nunito Sans', -apple-system, '.SFNSText-Regular', 'San Francisco', BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; overflow: auto; } @media (max-width: 700px) { .sb-wrapper { padding: 20px; } } @media (max-width: 500px) { .sb-wrapper { padding: 10px; } } ``` -------------------------------- ### AutocompleteElement for User Assignment Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Integrate MUI Autocomplete with RHF using AutocompleteElement. Supports single and multiple selections, loading states, checkboxes, and free-form input. Use matchId to store only the option ID. Configure autocompleteProps for advanced behavior. ```tsx import {FormContainer, AutocompleteElement} from 'react-hook-form-mui' import {Button} from '@mui/material' const USERS = [ {id: 1, label: 'Alice Johnson'}, {id: 2, label: 'Bob Smith'}, {id: 3, label: 'Carol White'}, ] function AssignForm() { return ( console.log(data)} > {/* Single select — stores the full option object */} {/* Multiple select — stores only IDs via matchId */} ) } ``` -------------------------------- ### Use re-exported useWatch from react-hook-form-mui Source: https://github.com/dohomi/react-hook-form-mui/blob/master/packages/rhf-mui/README.md Import useWatch from 'react-hook-form-mui' instead of 'react-hook-form' to avoid potential context issues within the library. ```tsx import {useWatch} from 'react-hook-form-mui' // instead of react-hook-form const MySubmit = () => { const value = useWatch('fieldName') return ( ) } ``` -------------------------------- ### No Preview State Styles Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html CSS for the 'no preview' state in Storybook. It styles the container and its content to indicate that no story is currently selected or available. ```css .sb-nopreview { display: flex; align-content: center; justify-content: center; box-sizing: border-box; } .sb-nopreview_main { margin: auto; padding: 30px; border-radius: 10px; background: rgb(247, 247, 247); color: rgb(46, 52, 56); & * { background: rgb(247, 247, 247); color: rgb(46, 52, 56); } } .sb-nopreview_heading { text-align: center; } ``` -------------------------------- ### Handle Vite App Loading Errors Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html This JavaScript function handles errors when loading the Storybook preview file in a Vite environment. It checks the hostname and configuration type to provide specific error messages and guidance, including recommended command-line flags or configuration options. ```javascript function __onViteAppLoadingError(event) { const hostname = globalThis.location.hostname; if (hostname !== 'localhost' && globalThis.CONFIG_TYPE === 'DEVELOPMENT') { const message = `Failed to load the Storybook preview file 'vite-app.js': It looks like you're visiting the Storybook development server on another hostname than localhost: '${hostname}', but you haven't configured the necessary security features to support this. Please re-run your Storybook development server with the '--host ${hostname}' flag, or manually configure your Vite allowedHosts configuration with viteFinal. See:`; const docs = [ 'https://storybook.js.org/docs/api/cli-options#dev', 'https://storybook.js.org/docs/api/main-config/main-config-vite-final', 'https://vite.dev/config/server-options.html#server-allowedhosts', ]; console.error(`${message}\n${docs.map((doc) => `- ${doc}`).join('\n')}`); document.getElementById('storybook-root').innerHTML = `

:not(.sb-preparing-story) { display: none; } .sb-show-preparing-docs:not(.sb-show-main) > :not(.sb-preparing-docs) { display: none; } ``` -------------------------------- ### RadioButtonGroup for Plan and Size Selection Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use RadioButtonGroup to render MUI RadioGroups. Options are mapped via valueKey and labelKey. Supports horizontal layout with 'row', returning full objects with 'returnObject', numeric coercion with 'type="number"', and an empty option with 'emptyOptionLabel'. ```tsx import {FormContainer, RadioButtonGroup} from 'react-hook-form-mui' import {Button} from '@mui/material' function PlanForm() { return ( console.log(data)} > {/* Numeric radio values */} ) } ``` -------------------------------- ### MultiSelectElement for Skills Selection Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use MultiSelectElement for multi-select scenarios with options. Configure showChips, showCheckbox, and preserveOrder for custom display. Ensure options use itemKey and itemLabel. Requires validation rules for minimum selections. ```tsx import {FormContainer, MultiSelectElement} from 'react-hook-form-mui' import {Button} from '@mui/material' const SKILLS = [ {id: 'ts', label: 'TypeScript'}, {id: 'react', label: 'React'}, {id: 'node', label: 'Node.js'}, {id: 'python', label: 'Python'}, ] function SkillsForm() { return ( console.log('Selected skills:', data.skills)} > v.length >= 2 || 'Pick at least 2 skills', }} /> ) } ``` -------------------------------- ### SelectElement for Dropdown Selection Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Illustrates the use of SelectElement for single-select dropdowns. Supports custom options arrays, value/label key mapping, and numeric type casting for selected values. ```tsx import {FormContainer, SelectElement} from 'react-hook-form-mui' import {Button} from '@mui/material' const COUNTRIES = [ {id: 'us', label: 'United States'}, {id: 'de', label: 'Germany'}, {id: 'jp', label: 'Japan'}, {id: 'br', label: 'Brazil', disabled: true}, ] function ShippingForm() { return ( console.log(data)} > {/* Numeric select */} ) } ``` -------------------------------- ### Storybook Story Definition Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Defines how Storybook discovers and imports stories. It specifies the directory, file pattern, and import path matcher for story files. ```javascript window.STORIES = [{"titlePrefix":"","directory":"./stories","files":"**/*.stories.@(js|jsx|ts|tsx|mdx)","importPathMatcher":"^\\.["\\/\\](?:stories(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)\\/|\\/|$)(?!\\.)(?=.)[^/]*?\\.stories\\.(js|jsx|ts|tsx|mdx))$"}]; ``` -------------------------------- ### Storybook Heading Styles Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Styles for headings within the Storybook UI, defining font size, weight, letter spacing, and margins. Used for section titles and labels. ```css .sb-heading { font-size: 14px; font-weight: 600; letter-spacing: 0.2px; margin: 10px 0; padding-right: 25px; } ``` -------------------------------- ### Define Nunito Sans Font Faces Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Defines multiple font face rules for 'Nunito Sans' with different weights and styles. Ensures the font is available for use within Storybook. ```css @font-face { font-family: 'Nunito Sans'; font-style: normal; font-weight: 400; font-display: swap; src: url('./sb-common-assets/nunito-sans-regular.woff2') format('woff2'); } @font-face { font-family: 'Nunito Sans'; font-style: italic; font-weight: 400; font-display: swap; src: url('./sb-common-assets/nunito-sans-italic.woff2') format('woff2'); } @font-face { font-family: 'Nunito Sans'; font-style: normal; font-weight: 700; font-display: swap; src: url('./sb-common-assets/nunito-sans-bold.woff2') format('woff2'); } @font-face { font-family: 'Nunito Sans'; font-style: italic; font-weight: 700; font-display: swap; src: url('./sb-common-assets/nunito-sans-bold-italic.woff2') format('woff2'); } ``` -------------------------------- ### Disable Hot Module Replacement Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Sets window.module to undefined to prevent potential errors in Storybook's source code related to hot module replacement when it's not available. ```javascript window.module = undefined; window.global = window; ``` -------------------------------- ### TextFieldElement Usage with React Hook Form Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Demonstrates various configurations of TextFieldElement for different input types like text, number, and email. Includes required validation, min/max length rules, and custom error parsing. ```tsx import {FormContainer, TextFieldElement} from 'react-hook-form-mui' import {Button, Stack} from '@mui/material' type ProfileForm = { username: string age: number | null email: string bio: string } function ProfileForm() { return ( defaultValues={{username: '', age: null, email: '', bio: ''}} onSuccess={(data) => console.log(data)} > {/* Simple required text field */} {/* Numeric field: stores a number (or null) instead of string */} {/* Email with auto regex validation */} {/* Custom error renderer */} `⚠ ${err.message}`} rules={{maxLength: {value: 200, message: 'Max 200 chars'}}} /> ) } ``` -------------------------------- ### Error Display Styles Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Styles for displaying errors within Storybook. This includes background, color, z-index, and box-sizing for the error container, ensuring errors are prominent. ```css .sb-errordisplay { background: #f6f9fc; color: black; z-index: 999999; width: 100vw; min-height: 100vh; box-sizing: border-box; } .sb-errordisplay_main { margin: auto; padding: 24px; display: flex; box-sizing: border-box; flex-direction: column; min-height: 100%; width: 100%; border-radius: 6px; background: white; color: black; border: 1px solid #ff0000; box-shadow: 0 0 64px rgba(0, 0, 0, 0.1); gap: 24px; & ol { padding-left: 18px; margin: 0; } /* Redefine colors to ensure readability regardless of user-provided * selectors. */ * { background: white; color: black; } & h1 { font-family: Nunito Sans; font-size: 22px; font-weight: 400; line-height: 30px; font-weight: normal; margin: 0; &::before { content: ''; display: inline-block; width: 12px; height: 12px; background: #ff4400; border-radius: 50%; margin-right: 8px; } } & p, & ol { font-family: Nunito Sans; font-size: 14px; font-weight: 400; line-height: 19px; margin: 0; } & li + li { margin: 0; padding: 0; padding-top: 12px; } & a { color: currentColor; } & .sb-errordisplay_code { padding: 10px; flex: 1; background: #242424; color: #c6c6c6; box-siz } } ``` -------------------------------- ### SwitchElement for Boolean Toggles Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Employ SwitchElement for boolean toggles, integrating with MUI's Switch component. It allows forwarding props to the Switch and supports custom value mapping. ```tsx import {FormContainer, SwitchElement} from 'react-hook-form-mui' import {Button, Stack} from '@mui/material' function SettingsForm() { return ( console.log(data)} > ) } ``` -------------------------------- ### Storybook Feature Flags Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html Configures various feature flags for Storybook, enabling or disabling specific functionalities. This allows for customization of the Storybook interface and behavior. ```javascript window.FEATURES = {"argTypeTargetsV7":true,"legacyDecoratorFileOrder":false,"disallowImplicitActionsInRenderV8":true,"viewport":true,"highlight":true,"controls":true,"interactions":true,"actions":true,"backgrounds":true,"outline":true,"measure":true,"sidebarOnboardingChecklist":true,"componentsManifest":false}; ``` -------------------------------- ### PasswordRepeatElement for Password Confirmation Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use PasswordRepeatElement to ensure a user's password and confirmation password fields match. Specify the original password field name using `passwordFieldName` and optionally customize the mismatch error message. ```tsx import { FormContainer, PasswordElement, PasswordRepeatElement, } from 'react-hook-form-mui' import {Button, Stack} from '@mui/material' type RegisterForm = {password: string; confirmPassword: string} function RegisterForm() { return ( defaultValues={{password: '', confirmPassword: ''}} onSuccess={(data) => console.log('Registered:', data)} > ) } ``` -------------------------------- ### Self-Managed Form with FormContainer Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use this variant when FormContainer should internally manage the form state using useForm. It's suitable for most common form scenarios. ```tsx import { FormContainer, TextFieldElement, useForm, } from 'react-hook-form-mui' import {Button, Stack} from '@mui/material' type LoginForm = {email: string; password: string} // ── Variant A: self-managed form (most common) ────────────────────────────── function LoginForm() { return ( defaultValues={{email: '', password: ''}} onSuccess={(data) => { // data is fully typed as LoginForm console.log('Submitted:', data) }} onError={(errors) => { console.warn('Validation errors:', errors) }} FormProps={{noValidate: true, style: {width: 400}}} > ) } ``` -------------------------------- ### PasswordElement with Show/Hide Toggle Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use PasswordElement for password input fields, which includes a built-in show/hide toggle. It extends TextFieldElement and allows customization of the visibility icons. ```tsx import {FormContainer, PasswordElement} from 'react-hook-form-mui' import {Button} from '@mui/material' import LockOpenIcon from '@mui/icons-material/LockOpen' import LockIcon from '@mui/icons-material/Lock' function ChangePasswordForm() { return ( console.log(data)} > ( visible ? : )} rules={{ minLength: {value: 8, message: 'Password must be at least 8 characters'}, pattern: { value: /[A-Z]/, message: 'Must contain at least one uppercase letter', }, }} /> ) } ``` -------------------------------- ### DatePickerElement with Date Validation Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Integrate MUI X DatePicker with React Hook Form using DatePickerElement. Configure date validation rules like `disablePast` or `minDate` and customize error messages with `overwriteErrorMessages`. The `textReadOnly` prop disables keyboard input. ```tsx import { FormContainer, DatePickerElement } from 'react-hook-form-mui' import {LocalizationProvider} from '@mui/x-date-pickers' import {AdapterDateFns} from '@mui/x-date-pickers/AdapterDateFns' import {Button, Stack} from '@mui/material' import {addDays, startOfToday} from 'date-fns' function EventForm() { return ( console.log(data)} > ) } ``` -------------------------------- ### Hide Specific Storybook UI Blocks Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html CSS rules to hide Storybook UI blocks like 'preparing-story', 'nopreview', or 'errordisplay' when their corresponding show classes are not active. This manages the visibility of different UI states. ```css :not(.sb-show-preparing-story) > .sb-preparing-story, :not(.sb-show-preparing-docs) > .sb-preparing-docs, :not(.sb-show-nopreview) > .sb-nopreview, :not(.sb-show-errordisplay) > .sb-errordisplay { display: none; } ``` -------------------------------- ### IE11 Vertical Centering Fix Source: https://github.com/dohomi/react-hook-form-mui/blob/master/apps/storybook/storybook-static/iframe.html A media query specific fix for Internet Explorer 11 to ensure vertical centering works correctly with the centered layout. ```css /* Vertical centering fix for IE11 */ @media screen and (-ms-high-contrast: none), (-ms-high-contrast: active) { .sb-show-main.sb-main-centered:after { content: ''; min-height: inherit; font-size: 0; } } ``` -------------------------------- ### Global Error Provider for RHF Components Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt A React context provider that defines a single, application-wide error message renderer. Wrap the application (or a section of it) in FormErrorProvider to override the default error.message display on all react-hook-form-mui components without setting parseError on each one individually. Use useFormError to read the error function in custom components. ```tsx import { FormContainer, FormErrorProvider, TextFieldElement, useFormError, } from 'react-hook-form-mui' import {Alert, Button, Stack} from '@mui/material' import type {FieldError} from 'react-hook-form' // Global error renderer: renders a coloured Alert instead of plain text function globalErrorRenderer(error: FieldError) { return ( {error.message} ) } // Custom field that reads the global renderer function StatusField() { const onError = useFormError() // onError is now globalErrorRenderer; use it in custom logic if needed return } function App() { return ( console.log(data)} > ) } ``` -------------------------------- ### Use Transform Hook for Value Transformation Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt A low-level hook that decouples how a value is stored in the form from how it is displayed. Accepts 'input' (form state → display value) and 'output' (UI event → form state) transform functions. Used internally by every component's 'transform' prop; can also be used directly in custom controlled inputs. ```tsx import { FormContainer, TextFieldElement, useTransform, useController, } from 'react-hook-form-mui' import {TextField} from '@mui/material' // Example: store a comma-separated string in form state, // but display it as an array of tags joined by " | " function TagsInput({name, control}: {name: string; control?: any}) { const {field} = useController({name, control}) const {value, onChange} = useTransform({ value: field.value as string, onChange: field.onChange, transform: { // form stores "react,typescript,mui" → display "react | typescript | mui" input: (v: string) => (v ? v.split(',').join(' | ') : ''), // display "react | typescript | mui" → store "react,typescript,mui" output: (e: React.ChangeEvent) => e.target.value.split(' | ').join(','), }, }) return ( ) } // Using the built-in transform prop on TextFieldElement for cents ↔ dollars function PriceForm() { return ( console.log('Price in cents:', data.priceInCents)} > cents / 100, output: (e) => Math.round(Number(e.target.value) * 100), }} /> ) } ``` -------------------------------- ### SliderElement for Range and Single Value Selection Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use SliderElement to bind MUI Slider components to form fields. Supports range selection (array values) and single value selection, with options for min, max, step, marks, and custom value transformation. Validation rules can be applied directly. ```tsx import { FormContainer, SliderElement } from 'react-hook-form-mui' import {Button} from '@mui/material' function FilterForm() { return ( console.log(data)} > {/* Range slider (stores number[]) */} {/* Single value slider */} ) } ``` -------------------------------- ### Toggle Button Group Element with RHF Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Integrates MUI ToggleButtonGroup with React Hook Form. Options are provided as {id, label} objects. Use 'exclusive' for single-selection and 'enforceAtLeastOneSelected' to prevent deselecting the last active button. ```tsx import {FormContainer, ToggleButtonGroupElement} from 'react-hook-form-mui' import {Button} from '@mui/material' function EditorForm() { return ( console.log(data)} > {/* Single-select: stores a string */} {/* Multi-select: stores string[] */} v.length > 0 || 'Pick a tag'}} /> ) } ``` -------------------------------- ### CheckboxElement for Boolean Fields Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Utilize CheckboxElement for single boolean fields, providing label and error display. It supports custom transformations and error message parsing. ```tsx import {FormContainer, CheckboxElement} from 'react-hook-form-mui' import {Button} from '@mui/material' function TermsForm() { return ( console.log(data)} > v || 'You must accept the terms', }} /> ) } ``` -------------------------------- ### CheckboxButtonGroup for Multi-Select Source: https://context7.com/dohomi/react-hook-form-mui/llms.txt Use CheckboxButtonGroup for multi-value selection where selected items are stored as an array. It supports horizontal layout and custom checkbox colors. ```tsx import {FormContainer, CheckboxButtonGroup} from 'react-hook-form-mui' import {Button} from '@mui/material' function NotificationForm() { return ( console.log('Channels:', data.channels)} > v.length > 0 || 'Select at least one channel', }} /> ) } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.