Tally UI

CustomerForm

CustomerForm provides controlled name, email, phone, and address fields for a customer record, with an optional submit button and label.

Import

import { CustomerForm } from '@tallyui/components';

Usage

<CustomerForm
  values={{ firstName: '', lastName: '', email: '', phone: '', address: '' }}
  onChangeField={(field, value) => updateField(field, value)}
  onSubmit={() => saveCustomer()}
/>

A structured form with labeled inputs for first name, last name, email, phone, and address. First and last name render side by side; email and phone use the appropriate keyboard types. An optional submit button appears when onSubmit is provided. When addresses and onChangeAddresses are both set, an AddressEditor for billing and shipping (with Same as billing) replaces the free-text Address field.

Props

PropTypeDefaultDescription
valuesCustomerFormValuesrequiredCurrent form field values
onChangeField(field: keyof CustomerFormValues, value: string) => voidrequiredCalled when any field changes
onSubmit() => void---Called on submit button press; hides button if omitted
submitLabelstring'Save Customer'Custom label for the submit button
showAddressbooleantrueShows the Address field
showCompanybooleanfalseShows a Company field after Email and Phone
emailErrorstring---Shown as an alert under the Email field; the form does not validate
addressesAddressEditorValue---Billing and shipping for the AddressEditor
onChangeAddresses(next: AddressEditorValue) => void---Called with the next billing and shipping
countriesAddressEditorProps['countries']---Passed through to AddressEditor
statesForAddressEditorProps['statesFor']---Passed through to AddressEditor
defaultCountrystring---Passed through to AddressEditor; a new address starts in this country
classNamestring---Override container styles

CustomerFormValues

interface CustomerFormValues {
  firstName: string;
  lastName: string;
  email: string;
  phone: string;
  address: string;
  company?: string;
}

Live demo