No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Input

⚠️ Preview components are considered unstable:

  • Features and APIs may change before final release
  • Please contact us if you intend to use this in your product

Default

Open in CodeSandbox
NameDescriptionDefaultControl
input

The actual <input> element. type="text" will be automatically applied unless overridden.

This is the "primary" slot, so native props specified directly on the <Input> will go here (except className and style, which go to the root slot). The top-level ref will also go here.

ShorthandProps<{ as?: "input"; } & Pick<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof InputHTMLAttributes<...>> & { ...; } & { ...; }>
-
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 <Input>. All other top-level native props will be applied to the primary slot, input.

ShorthandProps<{ as?: "span"; } & Pick<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof HTMLAttributes<...>> & { ...; } & { ...; }>
-
contentBefore
Element before the input text, within the input border
ShorthandProps<{ as?: "span"; } & Pick<DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof HTMLAttributes<...>> & { ...; } & { ...; }>
-
contentAfter
Element after the input text, within the input border
ShorthandProps<{ 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'"
inline

If true, the input will have inline display, allowing it be used within text content. If false (the default), the input will have block display.

boolean
-
appearance
Controls the colors and borders of the input.
"outline""underline""filledDarker""filledLighter"
"'outline'"
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
-
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
-
onChange
Called when the user changes the input's value.
((ev: FormEvent<HTMLInputElement>, data: InputOnChangeData) => void)
--
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 <input> element instead.)

"number""time""text""tel""url""email""search""date"
"'text'"
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
-
disabled
Whether the input is disabled
boolean
-

Stories

Appearance

An input can have different appearances.

Open in CodeSandbox

Content before/after

An input can have visual content (such as an icon) before or after the entered text, within the input border.

Open in CodeSandbox

Disabled

An input can be disabled.

Open in CodeSandbox

Inline

An input can be rendered inline with text.

This is some text with an inside it.
Open in CodeSandbox

Placeholder

An input can have placeholder text. If using the placeholder as a label (which is not recommended for usability), be sure to provide an aria-label for screen reader users.

Size

An input can have different sizes.

Open in CodeSandbox

Type

An input can have a custom text-based type such as email, url, or password 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.

Open in CodeSandbox

Uncontrolled

An input can be uncontrolled: it's passed a default value and handles updates internally.

Open in CodeSandbox

Controlled

An input can be controlled: the consuming component tracks the input's value in its state and manually handles all updates.

Open in CodeSandbox