Core Form Components
This document covers the Core Form system built on top of Inertia.js forms. These components provide a consistent, type-safe way to build forms with automatic error handling, validation display, and form state management.Base Documentation: See Inertia.js Forms Documentation for core functionality.
CoreForm Component
TheCoreForm component wraps Inertia’s Form component and provides a context for all form fields. It supports both controlled (using useForm hook) and uncontrolled (using Inertia’s built-in form handling) modes.
Controlled Mode (Recommended)
Use controlled mode when you need programmatic control over form data, validation, or need to access form state:Uncontrolled Mode
Use uncontrolled mode for simpler forms that rely on Inertia’s built-in form handling:Props
CoreFormPropsWithForm (Controlled)
form: Inertia form object fromuseForm()hookonSubmit: Form submission handleraction?: URL string (optional, for form action attribute)footer?: ReactNode to render in the form footer (typically submit buttons)disabled?: Boolean to disable all form fieldsclassName?: Additional CSS classes for the form layoutchildren: ReactNode or function that receives form props
CoreFormPropsWithoutForm (Uncontrolled)
action: URL string (required for form submission)method?: HTTP method (default: ‘post’)footer?: ReactNode to render in the form footerdisabled?: Boolean to disable all form fieldsclassName?: Additional CSS classes for the form layoutchildren: ReactNode or function that receivesFormComponentSlotProps
For Action Forms: If you need to execute a
CoreAction instead of submitting to a regular route, use CoreActionForm instead of CoreForm.Footer Layout
Thefooter prop renders buttons in a consistent layout at the bottom of the form:
- Buttons are arranged horizontally on larger screens
- Stacked vertically on mobile
- Includes a top border separator
- Proper spacing between buttons
Disabled State
You can disable the entire form and all its fields:Form Field Components
All form field components automatically:- Display validation errors from the server
- Integrate with form state (disabled/processing)
- Support both controlled and uncontrolled modes
- Provide consistent styling and spacing
CoreFormInput
Text input field for various input types.Props
name: Field name (required)label: Field labeltype: Input type ('text' | 'email' | 'password' | 'number' | 'url' | 'tel' | 'date' | 'time' | 'datetime-local')placeholder?: Placeholder textdisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help text displayed below the labelinputProps?: Additional props passed to the underlyingInputcomponentclassName?: Additional CSS classes
CoreFormSelect
Dropdown select field for choosing from a list of options.Props
name: Field name (required)label: Field labeloptions: Array of{ value: string, label: string | ReactNode }placeholder?: Placeholder textdisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textallowEmpty?: Allow selecting empty value (only works with controlled forms)selectProps?: Additional props passed to the underlyingSelectcomponentselectValueProps?: Props for theSelectValuecomponentclassName?: Additional CSS classes
CoreFormCombobox
Searchable combobox for selecting from a list of options.Props
name: Field name (required)label: Field labeloptions: Array of{ value: string, label: string }placeholder?: Placeholder textdisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textcomboboxProps?: Additional props passed to the underlyingComboboxcomponentclassName?: Additional CSS classes
CoreFormMultiSelect
Multi-select field for choosing multiple options from a list. Built on top of the MultiSelect component with full form integration.Single Select Mode
You can enable single select mode to allow only one selection:Custom Badge Labels
You can display different text in badges than in the dropdown:Search Configuration
Customize or disable search functionality:Overflow Behavior
Control how selected values display when they overflow:Props
name: Field name (required)label: Field labeloptions: Array of{ value: string, label: string | ReactNode, badgeLabel?: ReactNode }placeholder?: Placeholder text when no values selecteddisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textdefaultValues?: Default selected values (for uncontrolled forms)multiSelectProps?: Additional props passed to theMultiSelectcomponentsingle?: Enable single selection mode (default: false)onValuesChange?: Callback when values change
multiSelectValueProps?: Props for theMultiSelectValuecomponentoverflowBehavior?: How to handle overflow (‘wrap’ | ‘wrap-when-open’ | ‘cutoff’)clickToRemove?: Allow clicking badges to remove them (default: true)
multiSelectContentProps?: Props for theMultiSelectContentcomponentsearch?: Enable search (boolean) or configure it ({ placeholder?, emptyMessage? })
className?: Additional CSS classes
CoreFormSearchCombobox
Searchable combobox that fetches options from the server as you type.Props
name: Field name (required)label: Field labeldisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textsearchComboboxProps: Props for the underlyingSearchComboboxcomponent (see Search Combobox Documentation)className?: Additional CSS classes
CoreFormTextarea
Multi-line text input field.Props
name: Field name (required)label: Field labelplaceholder?: Placeholder textdisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help texttextareaProps?: Additional props passed to the underlyingTextareacomponentclassName?: Additional CSS classes
CoreFormCheckbox
Single checkbox field.Props
name: Field name (required)label: Checkbox labeldescription?: Help text displayed below the labeldisabled?: Disable this specific fieldrequired?: Mark field as requiredcheckboxProps?: Additional props passed to the underlyingCheckboxcomponentlabelProps?: Props for the label componentclassName?: Additional CSS classes
CoreFormSwitch
Toggle switch field (similar to checkbox but with different UI).Props
name: Field name (required)label: Switch labeldescription?: Help text displayed below the labeldisabled?: Disable this specific fieldrequired?: Mark field as requiredswitchProps?: Additional props passed to the underlyingSwitchcomponentlabelProps?: Props for the label componentclassName?: Additional CSS classes
CoreFormPhoneInput
Phone number input with international formatting.Props
name: Field name (required)label: Field labelplaceholder?: Placeholder textdisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textphoneInputProps?: Additional props passed to the underlying phone input componentclassName?: Additional CSS classes
CoreFormEntityInput
Input field for entity identification (SSN or organization number) with validation.Props
name: Field name (required)label: Field labeltype: Entity type ('ssn' | 'organization')disabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textinputProps?: Additional props passed to the underlying input componentclassName?: Additional CSS classes
CoreFormFileSelector
File selector field for choosing files from a file tree or data loader.Props
name: Field name (required)label: Field labelfileTree?: File tree data structuredataLoader?: Function to load file data asynchronouslydisabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textcomboboxProps?: Additional props passed to the underlying combobox componentclassName?: Additional CSS classes
CoreFormMoneyInput
Input field specifically for monetary values with currency formatting.Props
name: Field name (required)label: Field labelcurrency: Currency code (required, e.g.,'SEK','USD')step?: Step value for number input (default:0.01)placeholder?: Placeholder text (default:'0.00')disabled?: Disable this specific fieldrequired?: Mark field as requireddescription?: Help textinputProps?: Additional props passed to the underlying input componentclassName?: Additional CSS classes
CoreFormSubmitButton
Submit button that automatically integrates with form state (disabled during processing, shows loading state).Props
All props from theButton component are supported. The button automatically:
- Disables when the form is processing or disabled
- Shows a loading spinner when processing
- Sets
type="submit"
useCoreForm Hook
Access form context from withinCoreForm:
Return Value
data: Form data objectsetData: Function to update form data (controlled mode only)errors: Validation errors objectprocessing: Boolean indicating if form is submittingdisabled: Boolean indicating if form is disabledisControlled: Boolean indicating if form is in controlled mode
Complete Example
Here’s a complete example showing a user creation form:Best Practices
-
Use Controlled Mode: Prefer controlled mode (
useFormhook) for most forms as it provides better type safety and programmatic control. -
Consistent Footer Layout: Always place submit buttons in the
footerprop rather than inline with form fields. This ensures consistent spacing and layout. - Field Grouping: Use CSS Grid or Flexbox to group related fields horizontally on larger screens:
- Error Handling: Form fields automatically display validation errors from the server. Ensure your backend returns errors in the standard Laravel format:
-
Loading States: The form automatically handles loading states.
CoreFormSubmitButtonshows a loading spinner and disables during submission. - Nested Field Names: Use dot notation for nested form data:
- Conditional Fields: Use conditional rendering based on form state:
-
Form Validation: Always validate on the server side. Client-side validation can be added using the
requiredprop and custom validation logic in theonSubmithandler. -
Accessibility: All form fields include proper labels, error messages, and ARIA attributes. Ensure
labelprops are always provided for accessibility. - Type Safety: When using TypeScript, define your form data type:
-
Action Integration: When using actions with forms, leverage backend defaults and use
getParamsfor dynamic data. Form data is automatically merged with action parameters - you only need to specify what’s different or additional. - Action Validation: Validation errors from actions are automatically displayed on form fields. Don’t manually handle validation errors - they’re mapped to field names automatically.
-
Action Confirmation: If an action requires confirmation (via
confirm()), the form will show a confirmation dialog before submission automatically.