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..." />

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.

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.

Component Props

NameTypeDefaultDescription
typeTextBoxTypes'text'The type of the input element.
value bindablestring | numberThe current value of the input.
wrapperRef bindableHTMLDivElementThe DOM reference of the wrapper element.
ref bindableHTMLInputElementThe 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: InputEvent, 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 apply to the wrapper element.
HTMLInputAttributes without size