Input Preview
An input allows people to enter short, free-form text data.
If you need to collect more than one line of information, try a textarea.
Properties
appearance
Controls the colors and borders of the input.
“outline”
“underline”
“filled-darker”
“filled-lighter”
“filled-darker-shadow”
“filled-lighter-shadow”
“‘outline’\n\nNote: ‘filled-darker-shadow’ and ‘filled-lighter-shadow’ are deprecated and will be removed in the future.”
contentAfter
Element after the input text, within the input border
WithSlotShorthandValue<{ as?: "span"; } & Pick<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof HTMLAttributes<...>> & { ...; } & { ...; }> | null
contentBefore
Element before the input text, within the input border
WithSlotShorthandValue<{ as?: "span"; } & Pick<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof HTMLAttributes<...>> & { ...; } & { ...; }> | null
defaultValue
Default value of the input. Provide this if the input should be an uncontrolled component which tracks its current state internally; otherwise, use
value
.
(This prop is mutually exclusive with
value
.)
string
disabled
Whether the input is disabled
boolean
input
The actual
element.
<input>
type=“text”
will be automatically applied unless overridden.
This is the “primary” slot, so native props specified directly on the
will go here (except
<Input>
className
and
style
, which go to the
root
slot). The top-level
ref
will also go here.
({ as?: "input"; } & Omit<Pick<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof InputHTMLAttributes<...>> & { ...; }, "children"> & { ...; })
onChange
Called when the user changes the input’s value.
((ev: ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => void)
placeholder
Placeholder text for the input. If using this instead of a label (which is not recommended), be sure to provide an
aria-label
for screen reader users.
string
root
Wrapper element which visually appears to be the input and is used for borders, focus styling, etc. (A wrapper is needed to properly position
contentBefore
and
contentAfter
relative to
input
.)
The root slot receives the
className
and
style
specified directly on the
. All other top-level native props will be applied to the primary slot,
<Input>
input
.
WithSlotShorthandValue<{ as?: "span"; } & Pick<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof HTMLAttributes<...>> & { ...; } & { ...; }>
size
Size of the input (changes the font size and spacing).
“small”
“medium”
“large”
“‘medium’”
type
An input can have different text-based types based on the type of value the user will enter.
Note that no custom styling is currently applied for alternative types, and some types may activate browser-default styling which does not match the Fluent design language.
(For non-text-based types such as
button
or
checkbox
, use the appropriate component or an
element instead.)<input>
“number”
“time”
“text”
“search”
“tel”
“url”
“email”
“date”
“datetime-local”
“month”
“password”
“week”
“‘text’”
value
Current value of the input. Provide this if the input is a controlled component where you are maintaining its current state; otherwise, use
defaultValue.
(This prop is mutually exclusive with
defaultValue
.)
string