Text Field
Usage
Text Field is a single-line input for short free-form text values such as names, titles, and identifiers. Use it when users should type one value in a single-line input and when shared field features such as hint, helpText, error, or inheritance are helpful.
import { MtTextField } from "@shopware-ag/meteor-component-library";
Examples
Disabled
Error
Hint
API reference
Props
| Prop | Type | Default |
|---|---|---|
copyableToggles the copy function of the text field. | boolean | false |
errorAn error in your business logic related to this field. | Record<string, any> | null |
labelA label for your text field. Usually used to guide the user what value this field controls. | string | null |
requiredDetermines if the field is required. | boolean | false |
is-inheritance-fieldDetermines if the field is inheritable. | boolean | false |
is-inheritedToggles the inheritance visualization. | boolean | false |
help-textA text that helps the user to understand what this field does. | string | null |
disabledDetermines if the field is disabled. | boolean | false |
placeholderA placeholder text being displayed if no value is set. | string | "" |
name | string | null |
sizeThe size of the text field. | string | "default" |
model-valueThe value of the text field. | string | number | "" |
disable-inheritance-toggleDetermines the active state of the inheritance toggle. | boolean | false |
copyable-tooltipIf set to true the tooltip will change on successful copy. | boolean | false |
max-lengthIf set to a value a character counter will be displayed. | number | undefined |
id-suffix | string | "" |
on-update:model-value | ((...args: any[]) => any) | undefined | |
on-change | ((...args: any[]) => any) | undefined | |
on-inheritance-remove | ((...args: any[]) => any) | undefined | |
on-inheritance-restore | ((...args: any[]) => any) | undefined | |
on-blur | ((...args: any[]) => any) | undefined | |
on-focus | ((...args: any[]) => any) | undefined |
Exposed
| Name | Type |
|---|---|
currentValue | string | number |
hasFocus | boolean |
hasError | boolean |
hasDisabledInput | boolean |
Best practices
Do
- Use a clear visible label that describes the expected value.
- Keep the content short enough for a single-line input.
- Add help text or hint content when users need more context.
Don't
- Do not use Text Field for longer multi-line content.
- Do not rely on the placeholder as the only instruction.
- Do not use it when a more specific field type would guide input better.
Behavior
- Text Field supports shared field features such as
prefix,suffix,hint,helpText,error, and inheritance handling. copyableadds a copy button for reference-heavy values that users may need to copy out of the field.maxLengthcan show a live character counter when the value length matters.
Accessibility
- Always provide a visible label so users understand what value is expected.
- Use a more specific field type when browser input behavior or validation would improve accessibility.
Related components
- Email Field: when the value must be an email address.
- URL Field: when the value should be a link and URL-specific behavior is helpful.
- Number Field: when the value should behave like a number with numeric constraints or stepping.
- Unit Field: when users should enter a number together with a selectable unit.
- Password Field: when the value is sensitive and should be hidden by default.
- Search: when the value is meant to filter or find content in the interface.