Skip to content

Commit 1e4a7b4

Browse files
Tweak spacing and wording of Text Input docs for clarity (#3374)
Co-authored-by: Heather Larsen <[email protected]>
1 parent 1c38cc0 commit 1e4a7b4

File tree

1 file changed

+42
-23
lines changed
  • website/docs/components/form/text-input/partials/guidelines

1 file changed

+42
-23
lines changed

website/docs/components/form/text-input/partials/guidelines/guidelines.md

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
### When not to use
88

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).
1111

1212
## Types of text inputs
1313

@@ -29,11 +29,13 @@ The `TextInput` component has a visibility toggle feature for password fields. B
2929

3030
### Search
3131

32+
#### Default state
33+
3234
<Hds::Form::TextInput::Field @type="search" placeholder="Search" @width="300px" as |F|>
3335
<F.Label>Search</F.Label>
3436
</Hds::Form::TextInput::Field>
3537

36-
#### Loading
38+
#### Loading state
3739

3840
<Hds::Form::TextInput::Field @type="search" placeholder="Search" @width="300px" @isLoading="true" as |F|>
3941
<F.Label>Search</F.Label>
@@ -48,25 +50,25 @@ The `TextInput` component has a visibility toggle feature for password fields. B
4850
Date and time fields use the native browser functionality for the popovers. Some browsers do not display an icon or popover.
4951
!!!
5052

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::Form as |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>
7072

7173
### Telephone
7274

@@ -78,10 +80,14 @@ Date and time fields use the native browser functionality for the popovers. Some
7880

7981
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/).
8082

83+
### Required
84+
8185
<Hds::Form::TextInput::Field @type="text" @isRequired={{true}} @width="300px" as |F|>
8286
<F.Label>Label</F.Label>
8387
</Hds::Form::TextInput::Field>
8488

89+
### Optional
90+
8591
For shorter, simpler forms (e.g., login/signup and feedback requests), indicate **optional** fields instead.
8692

8793
<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
9298

9399
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.
94100

101+
### Readonly
102+
95103
Readonly fields are not editable by the user but the value in the field **is** passed when the form is submitted.
96104

97105
<Hds::Form::TextInput::Field @type="text" @width="300px" @value="helios-cluster-31" readonly as |F|>
98106
<F.Label>Cluster ID</F.Label>
99107
</Hds::Form::TextInput::Field>
100108

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+
!!!
102119

103120
<Hds::Form::TextInput::Field @type="text" @width="300px" @value="helios-cluster-31" disabled as |F|>
104121
<F.Label>Cluster ID</F.Label>
105122
</Hds::Form::TextInput::Field>
106123

124+
### Hidden
125+
107126
Hidden fields are not visible to the user but the value in the field **is** passed when the form is submitted.
108127

109128
| Field type | Visible in UI | Editable by user | Value passed on `submit` |

0 commit comments

Comments
 (0)