Input
A single-line text input with Fluent styling: a 1px border with an accessible bottom stroke, a primary bottom border while focused, optional contentBefore/contentAfter slots and an optional error message. Inside a Field it picks up the label, hint, error, required (native attribute) and invalid state automatically.
size resolves from its own prop, then the surrounding Field's size, then WaveProvider inputDefaults.size, else 'medium'; appearance from its own prop, then WaveProvider inputDefaults.appearance, else 'outline'; both render as data-size and data-appearance on the element that draws the field (the <input>, or the wrapper with slot content).
Every prop reaches the <input>, except with slot content: then a bordered <span> wrapper draws the field and receives className, style and hidden (ref stays on the input).
Examples
Default
export const Default: Story = {};With Content Before
export const WithContentBefore: Story = {
args: {
'aria-label': 'Search',
placeholder: 'Search...',
contentBefore: { children: '🔍', 'aria-hidden': true },
},
};With Content After
export const WithContentAfter: Story = {
args: {
'aria-label': 'Weight',
placeholder: '0',
contentAfter: { children: 'kg' },
},
};Error
export const Error: Story = {
args: {
'aria-label': 'Email',
placeholder: 'you@example.com',
error: 'This field is required',
defaultValue: '',
},
};Error Flag Only
export const ErrorFlagOnly: Story = {
args: {
'aria-label': 'Email',
placeholder: 'you@example.com',
error: true,
},
};Disabled
export const Disabled: Story = {
args: {
'aria-label': 'Disabled input',
placeholder: 'Disabled',
disabled: true,
},
};Sizes And Appearances
export const SizesAndAppearances: Story = {
render: (args) => (
<SizeAppearanceGrid
render={(size, appearance) => (
<Input
{...args}
size={size}
appearance={appearance}
aria-label={`${size} ${appearance}`}
placeholder={`${size} ${appearance}`}
/>
)}
/>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
error | string | boolean | No | Validation error. The error border also shows whenever the input ends up | |
errorMessageProps | InputErrorMessageProps | No | Props of the error message element ( | |
size | 'small' | 'medium' | 'large' | No | Size of the field: | |
htmlSize | number | No | The native | |
appearance | 'outline' | 'underline' | 'filled-darker' | 'filled-lighter' | No | Look of the field: | |
contentBefore | Slot<'span'> | No | Slot rendered before the input text (e.g., an icon). With content in either slot, a bordered | |
contentAfter | Slot<'span'> | No | Slot rendered after the input text (e.g., a suffix). Same wrapper as | |
onValueChange | (value: string) => void | No | Called with the new string value on every change, next to the native | |
ref | React.Ref<HTMLInputElement> | No | Ref to the | |
slotProps | { root?: SlotPartWithRef<'span', HTMLElement>; input?: SlotPart<'input'> } | No | Props for the elements the Input draws, by part, merged into each part's own (Fluent UI's Without |
Any other prop is passed to the element it renders (HTMLInputElement).
Parts
rootinput
Stable class names
| Part | Class |
|---|---|
root | wave-input |
input | wave-input__input |
contentBefore | wave-input__content-before |
contentAfter | wave-input__content-after |
errorMessage | wave-input__error-message |