Skip to content

Input Fields

Edit on GitHub

Input fields allow users to enter text, dates, and other structured data within a form. Each field type includes clear labeling and validation to support a consistent, accessible experience.

@volvo-cars/css v2.5.1@volvo-cars/react-forms v2.0.1
Show codeHide code
import { TextInput } from '@volvo-cars/react-forms';
export function TextInputFloatingLabel() {
return (
<TextInput name="full-name" label="Full name" variant="floating-label" />
);
}
Show codeHide code
import {
EmailInput,
PasswordInput,
TelInput,
TextInput,
} from '@volvo-cars/react-forms';
export function InputTypes() {
return (
<div className="flex-col gap-16">
<TextInput name="full-name" label="Full name" variant="top-label" />
<EmailInput name="email" label="Email address" variant="top-label" />
<PasswordInput
name="password"
label="Password"
showPasswordLabel="Show password"
variant="top-label"
/>
<TelInput name="phone" label="Phone number" variant="top-label" />
</div>
);
}
Show codeHide code
import { DateInput } from '@volvo-cars/react-forms';
export function DateInputExample() {
return <DateInput name="start-date" label="Start date" variant="top-label" />;
}
Show codeHide code
import { CurrencyInput } from '@volvo-cars/react-forms';
export function CurrencyInputExample() {
return <CurrencyInput name="price" label="Price" currency="EUR" />;
}
km
Show codeHide code
import { UnitInput } from '@volvo-cars/react-forms';
export function UnitInputExample() {
return <UnitInput name="distance" label="Distance" unit="kilometer" />;
}
Show codeHide code
import { TextArea } from '@volvo-cars/react-forms';
export function TextAreaBasic() {
return (
<TextArea name="message" label="Message" variant="top-label" rows={4} />
);
}

Enter a valid email address

We use this to find dealers near you

Show codeHide code
import { TextInput } from '@volvo-cars/react-forms';
export function InputValidation() {
return (
<div className="flex-col gap-16">
<TextInput
name="email"
label="Email"
errorMessage="Enter a valid email address"
variant="top-label"
/>
<TextInput
name="city"
label="City"
hint="We use this to find dealers near you"
variant="top-label"
/>
</div>
);
}
Show codeHide code
import { TextInput } from '@volvo-cars/react-forms';
import { useState } from 'react';
export function TextInputControlled() {
const [value, setValue] = useState('');
return (
<TextInput
name="city"
label="City"
value={value}
onChange={(e) => setValue(e.target.value)}
variant="top-label"
/>
);
}