enes

TextBox

The TextBox control lets a user type text into an app. It's typically used to capture a single line of text, but can be configured to capture multiple lines of text. The text displays on the screen in a simple, uniform, plaintext format.

Usage

<script>
	import { TextBox } from 'fluentui-svelte';
</script>

<TextBox type="text" placeholder="Type here..." />

Shape

Set shape to rounded (default), square, or circular.

Type

The type prop specifies the type of input element. It can be set to various types such as text, search, email, url, tel, password, or number. This determines the behavior and validation of the input.

Size

The size prop sets the height, the font size and the horizontal padding of the input. It can be set to small, medium or large. The default is medium.

Content Before and After

contentBefore and contentAfter render content inside the wrapper, before and after the input. They accept a string, a snippet or a component such as an icon.

https://
.com
$ .00

Readonly

The readonly prop makes the input field read-only, preventing users from modifying its value. This is useful for displaying information that should not be edited.

Hide Buttons

The hideActionButtons prop allows you to hide the extra action buttons in the input, such as clear or submit buttons. This can be useful for a cleaner UI when those actions are not needed.

Form Control Attributes

Attributes and events apply to the native form field; ref gives you access to it. For the container, use wrapperAttributes and wrapperRef.

Component Props

NameTypeDefaultDescription
shape'circular' | 'rounded' | 'square''rounded'Shape of the input surface, including its border and focus indicator.
typeTextBoxTypes'text'The type of the input element.
value bindablestring | numberThe current value of the input.
wrapperRef bindableHTMLDivElement | nullThe DOM reference of the wrapper element.
ref bindableHTMLInputElement | nullThe DOM reference of the input element.
placeholderstring'Fluent TextBox'The placeholder text for the input.
hideActionButtonsbooleanWhether to hide the extra action buttons in the input.
justifybooleanMake the input fill the full width of the container.
contentBeforestring | Snippet | ComponentContent rendered before the input, inside the wrapper.
contentAfterstring | Snippet | ComponentContent rendered after the input, inside the wrapper.
size'small' | 'medium' | 'large''medium'The size of the input element.
textChanged(e: Event & unknown, text: string) => voidOccurs when content changes in the text box.
querySubmitted(e: MouseEvent | KeyboardEvent, query: string) => voidThe QuerySubmitted event occurs when: 1. The input type is 'search'. 2. While the focus is in the text box, press Enter or click the query icon.
onClear(e: MouseEvent) => voidOccurs when the clear button is clicked.
childrenSnippetThe children elements to render inside the input.
wrapperAttributesHTMLAttributesThe attributes to spread on the wrapper element.
HTMLInputAttributes without size
Edit this Doc View as Markdown