Some props/prop values deprecated in SWAN v3.3
Refer to the information on props/prop values provided further down this page. Find more information and migration documentation in the Deprecation roadmap.
Text Input
Input field for entering alpha-numerical information.
Use Text Input...
- To input or edit freeform alpha-numerical information.
- To input a single line of text.
Don't use Text Input...
- To input information that can be predicted from a list of suggested values. Use Combobox instead.
- To input multiple lines of text. Use Text Area instead.
- To create a search field. Use Search Input or Combobox With Search Input instead.
Type
Use an input type
that is appropriate for the Text Input's function (e.g., type="email"
for an email address field).
Placeholder
Use placeholder
to provide hints for what to enter.
Size
size
is deprecated in SWAN v3.3
The component now automatically handles sizing based on the selected mode(standardMode
/compactMode
). Please update your implementation to rely on the new mode-based sizing.
Mini
Use size="mini"
to reduce the height of a Text Input.
With Floating Label
- Use
TextInputWithFloatingLabel
to create a label inside the input field that shifts position once the user starts entering text. - Note: the floating label looks like a
placeholder
text but it is not an HTMLplaceholder
; any actualplaceholder
attribute on the input is transparent.
With Button beside
Use TextInputWithButtonBeside
to group a text input and button together.
With icon-only Button inset
Use TextInputWithButtonInset
to place an icon-only Button within the Text Input.
- The typical use case is for search bars, and sign in forms.
- You can also position the enclosed button either "left" or "right" by using the prop
buttonPosition
.
Labels, Errors, and Helper Text
Refer to Form guidelines.
Managing State in React
Refer to Form guidelines.
Accessibility
Refer to the Accessibility guidelines for Form.
Implementation
- Inputs default to a width of 100%, filling up their container; this is a best practice for responsive design.
- To limit an input's width, you should constrain its container, e.g., by putting it into a Grid element of a certain number of columns.
Props
TextInput
This component is implemented using the
<input />
as the root element. You can utilize the native attributes supported by <input />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.See core props for additional props that can be applied to this component.
prop | type | required | description | default |
---|---|---|---|---|
size | "standard" | "mini" | null | false | ⚠️ Deprecated - This is deprecated without a replacement.
The size variation
Available options: 'standard', 'mini', | null |
skin | "standard" | "error" | null | false | The visual variant.
Note that error is implied if the TextInput is used inside of a FormInput that also contains a FormError.
Available options: 'standard', 'error' | standard |
TextInputFloatingLabel
This component is implemented using the
<label />
as the root element. You can utilize the native attributes supported by <label />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.See core props for additional props that can be applied to this component.
TextInputWithFloatingLabel
This component is implemented using the
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.See core props for additional props that can be applied to this component.
TextInputWithButtonBeside
This component is implemented using the
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.See core props for additional props that can be applied to this component.
TextInputWithButtonInset
This component is implemented using the
<div />
as the root element. You can utilize the native attributes supported by <div />
tag. The ref
is directly assigned to the root element, allowing you to access and manipulate it as needed.See core props for additional props that can be applied to this component.
prop | type | required | description | default |
---|---|---|---|---|
buttonPosition | "left" | "right" | null | false | Position of the button.
Available options: 'left', 'right' | null |
Related
Was this page useful?
Published: Jan 7, 2022Last updated: Oct 17, 2024