You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/docs/components/form/text-input/partials/guidelines/guidelines.md
+42-23Lines changed: 42 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,8 +6,8 @@
6
6
7
7
### When not to use
8
8
9
-
-If needing a multi-line text input, consider [Textarea](/components/form/textarea)
10
-
-If needing to allow the user to make a selection from a predetermined list of options, consider [Checkbox](/components/form/checkbox), [Radio button](/components/form/radio), or [Select](/components/form/select).
9
+
-For multi-line text input, consider [Textarea](/components/form/textarea).
10
+
-To allow the user to make a selection from a predetermined list of options, consider [Checkbox](/components/form/checkbox), [Radio button](/components/form/radio), or [Select](/components/form/select).
11
11
12
12
## Types of text inputs
13
13
@@ -29,11 +29,13 @@ The `TextInput` component has a visibility toggle feature for password fields. B
29
29
30
30
### Search
31
31
32
+
#### Default state
33
+
32
34
<Hds::Form::TextInput::Field @type="search" placeholder="Search" @width="300px" as |F|>
33
35
<F.Label>Search</F.Label>
34
36
</Hds::Form::TextInput::Field>
35
37
36
-
#### Loading
38
+
#### Loading state
37
39
38
40
<Hds::Form::TextInput::Field @type="search" placeholder="Search" @width="300px" @isLoading="true" as |F|>
39
41
<F.Label>Search</F.Label>
@@ -48,25 +50,25 @@ The `TextInput` component has a visibility toggle feature for password fields. B
48
50
Date and time fields use the native browser functionality for the popovers. Some browsers do not display an icon or popover.
49
51
!!!
50
52
51
-
<Hds::Form::TextInput::Field @type="date" placeholder="mm/dd/yy" as |F|>
52
-
<F.Label>Date</F.Label>
53
-
</Hds::Form::TextInput::Field>
54
-
55
-
<Hds::Form::TextInput::Field@type="time" placeholder="--:-- --" as |F|>
56
-
<F.Label>Time</F.Label>
57
-
</Hds::Form::TextInput::Field>
58
-
59
-
<Hds::Form::TextInput::Field @type="datetime-local" placeholder="mm/dd/yyT--:-- --" as |F|>
60
-
<F.Label>Datetime</F.Label>
61
-
</Hds::Form::TextInput::Field>
62
-
63
-
<Hds::Form::TextInput::Field @type="month" placeholder="yyyy-mm" as |F|>
64
-
<F.Label>Month</F.Label>
65
-
</Hds::Form::TextInput::Field>
66
-
67
-
<Hds::Form::TextInput::Field@type="week" placeholder="yyyy-W00" as |F|>
68
-
<F.Label>Week</F.Label>
69
-
</Hds::Form::TextInput::Field>
53
+
<Hds::Formas |FORM|>
54
+
<FORM.Section>
55
+
<Hds::Form::TextInput::Field@type="date" placeholder="mm/dd/yy" as |F|>
56
+
<F.Label>Date</F.Label>
57
+
</Hds::Form::TextInput::Field>
58
+
<Hds::Form::TextInput::Field @type="time" placeholder="--:-- --" as |F|>
59
+
<F.Label>Time</F.Label>
60
+
</Hds::Form::TextInput::Field>
61
+
<Hds::Form::TextInput::Field @type="datetime-local" placeholder="mm/dd/yyT--:-- --" as |F|>
62
+
<F.Label>Datetime</F.Label>
63
+
</Hds::Form::TextInput::Field>
64
+
<Hds::Form::TextInput::Field @type="month" placeholder="yyyy-mm" as |F|>
65
+
<F.Label>Month</F.Label>
66
+
</Hds::Form::TextInput::Field>
67
+
<Hds::Form::TextInput::Field@type="week" placeholder="yyyy-W00" as |F|>
68
+
<F.Label>Week</F.Label>
69
+
</Hds::Form::TextInput::Field>
70
+
</FORM.Section>
71
+
</Hds::Form>
70
72
71
73
### Telephone
72
74
@@ -78,10 +80,14 @@ Date and time fields use the native browser functionality for the popovers. Some
78
80
79
81
For complex forms, indicate **required** fields. This is the most explicit and transparent method and ensures users don’t have to make assumptions. Read more about best practices for [marking required fields in forms](https://www.nngroup.com/articles/required-fields/).
80
82
83
+
### Required
84
+
81
85
<Hds::Form::TextInput::Field @type="text" @isRequired={{true}} @width="300px" as |F|>
82
86
<F.Label>Label</F.Label>
83
87
</Hds::Form::TextInput::Field>
84
88
89
+
### Optional
90
+
85
91
For shorter, simpler forms (e.g., login/signup and feedback requests), indicate **optional** fields instead.
86
92
87
93
<Hds::Form::TextInput::Field @type="text" @isOptional={{true}} @width="300px" as |F|>
@@ -92,18 +98,31 @@ For shorter, simpler forms (e.g., login/signup and feedback requests), indicate
92
98
93
99
Readonly, disabled, and hidden fields are very similar, but there are key differences to be aware of when choosing the correct type of Text Input. Since these fields are not editable by a user, we recommend using them sparingly.
94
100
101
+
### Readonly
102
+
95
103
Readonly fields are not editable by the user but the value in the field **is** passed when the form is submitted.
96
104
97
105
<Hds::Form::TextInput::Field @type="text" @width="300px" @value="helios-cluster-31" readonly as |F|>
98
106
<F.Label>Cluster ID</F.Label>
99
107
</Hds::Form::TextInput::Field>
100
108
101
-
Disabled fields are not editable by the user and the value in the field **is not** passed when the form is submitted.
109
+
### Disabled
110
+
111
+
Disabled fields are also not editable by the user and the value in the field **is not** passed when the form is submitted.
112
+
113
+
!!! Warning
114
+
115
+
**Accessibility alert**
116
+
117
+
Screen readers do not have access to disabled fields; therefore, we recommend against disabling fields. Please read more about [showing, hiding, or disabling elements](https://helios.hashicorp.design/patterns/disabled-patterns).
118
+
!!!
102
119
103
120
<Hds::Form::TextInput::Field @type="text" @width="300px" @value="helios-cluster-31" disabled as |F|>
104
121
<F.Label>Cluster ID</F.Label>
105
122
</Hds::Form::TextInput::Field>
106
123
124
+
### Hidden
125
+
107
126
Hidden fields are not visible to the user but the value in the field **is** passed when the form is submitted.
108
127
109
128
| Field type | Visible in UI | Editable by user | Value passed on `submit`|
0 commit comments