# SbTextField A text input component with support for labels, placeholders, adornments, password visibility toggle, and form validation. Can be used with its own **Label** and **Required** parameters, or wrapped in **SbFormField** for label, helper text, and error message layout. ## Parameters | Parameter | Type | Default | Description | |-----------|------|---------|-------------| | Value | TValue | - | The current value (two-way bindable) | | ValueChanged | EventCallback\ | - | Callback when value changes | | Label | string? | null | Label text displayed above the input | | Placeholder | string? | null | Placeholder text | | Type | string | "text" | Input type (text, password, email, search, etc.) | | Required | bool | false | Whether the field is required | | Disabled | bool | false | Whether the input is disabled | | ReadOnly | bool | false | Whether the input is read-only | | Clearable | bool | false | Whether to show a clear button | | Id | string? | auto-generated | Element ID | | InputMode | string? | null | Input mode hint for mobile keyboards | | AutoComplete | string? | null | Autocomplete attribute value. When Type is "password" and not set, defaults to "new-password" to prevent browser autofill with cached credentials (e.g., connection strings, API keys). Use "current-password" explicitly for login forms. | | AriaDescribedBy | string? | null | IDs of elements that describe this input | | Style | string? | null | Inline styles for the wrapper | | ClearAriaLabel | string? | null | Aria label for clear button (when null, uses localized default) | | ShowPasswordAriaLabel | string? | null | Aria label for show password button (when null, uses localized default) | | HidePasswordAriaLabel | string? | null | Aria label for hide password button (when null, uses localized default) | | InvalidValueMessage | string | "The value '{0}' is not valid." | Validation error message format (used for non-string TValue parse errors) | | AdditionalAttributes | Dictionary? | - | Additional HTML attributes for the input (from InputBase) | ## Events | Event | Type | Description | |-------|------|-------------| | ValueChanged | EventCallback\ | Fired when the value changes | | OnClear | EventCallback | Fired when the clear button is clicked | ## Templates / Slots (RenderFragments) | Slot | Type | Description | |------|------|-------------| | StartAdornment | RenderFragment | Content shown at the start of the input (e.g., icon) | | EndAdornment | RenderFragment | Content shown at the end of the input (e.g., icon) | ### Template Usage Examples #### StartAdornment ```razor ``` #### EndAdornment ```razor ``` ## CSS Classes - `sb-text-field-wrapper` - Outer wrapper - `sb-text-field` - Input container - `sb-text-field__label` - Label element - `sb-text-field__input` - The actual input element - `sb-text-field__required` - Required asterisk - `sb-text-field__adornment` - Adornment wrapper - `sb-text-field__adornment--start` - Start adornment - `sb-text-field__adornment--end` - End adornment - `sb-text-field__clear` - Clear button - `sb-text-field__toggle-password` - Password visibility toggle - `sb-text-field--disabled` - Disabled state - `sb-text-field--readonly` - Read-only state - `sb-text-field--error` - Error state - `sb-text-field--has-start` - Has start adornment - `sb-text-field--has-end` - Has end adornment ## Accessibility - Uses native `` element - `aria-invalid` set when there are validation errors - `aria-required` set when Required is true - `aria-describedby` for error message association - Password toggle buttons have appropriate aria-labels - Label properly associated via `for` attribute ## Examples ### Basic Usage (standalone label) ```razor ``` ### With SbFormField (label, helper text, error) ```razor ``` ### Password Field ```razor ``` Password fields default to `autocomplete="new-password"` to prevent browsers from autofilling with cached credentials (useful for connection strings, API keys, and other sensitive non-login fields). For login forms where autofill is desired, set `AutoComplete="current-password"`: ```razor ``` ### Email with Icon ```razor ``` ### Clearable Search ```razor ``` ### With Form Validation ```razor ``` ### Read-Only Field ```razor ```