SfInput is a single-line text field allows users to enter any combination of letters, numbers, or symbols. It adds default styles to the native <input type="text"> and supports supports adding content before/after the text input.
If you need to make this field required, it is crucial to communicate this intention clearly to your end users. You can find more information about required form fields in our guide here.
Examples
Basic input component
SfInput supports 3 sizes that can be set with the size prop: 'sm', md, and 'lg'.
This is an example of what SfInput might look like in your end code. It has a label, help text, character counting, and different styles depending on the input state.
All non-prop attributes and styles added to SfInput component are passed directly to the native input element. This means that you can add all of the input attributes directly to SfInput. If you want to style the wrapper div, you can pass your classes via the wrapperClass prop.
Since, size is a specified prop of SfInput, you won't be able to pass the native size attribute to your input element. Instead, you can use the width property with ch unit instead (eg. width: 10ch).
Accessibility notes
Since SfInput uses <input>, it inherits all the features of the native input. For example, SfInput is focusable for keyboard users with tab.
Avoid adding div tags to slots. If an input element is wrapped in label tag (recommended) then it can't have div inside.