Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit e289eb3

Browse files
committed
docs(cb-a11y): Content - Form controls
1 parent a7c97c1 commit e289eb3

File tree

1 file changed

+34
-28
lines changed

1 file changed

+34
-28
lines changed

public/docs/ts/latest/cookbook/a11y.jade

+34-28
Original file line numberDiff line numberDiff line change
@@ -138,43 +138,49 @@ include ../_util-fns
138138
You will see the `ng-content` tag making its appearance a lot in the examples. This is because we are making use
139139
of `Content Projection` to load content into the templates of our components.
140140

141-
:marked
142-
### Implicit labelling
141+
.l-sub-section
142+
:marked
143+
It is very important to note that a `LABEL` element can describe one and only form input element. You cannot
144+
label multiple form fields with one label. We will look at ways to do this with `ARIA` later.
143145

144-
Firstly we will look at the absolute easiest way to furnish your form controls with accessible labels, and that is
145-
with a technique called `implicit labelling`.
146+
.l-sub-section
147+
:marked
148+
And finally the label text position matters. For `inputs`, `textareas` and `selects`, the label text precedes
149+
the element. Whilst for `checkboxes` and `radionbuttons` the text should follow the element in the flow.
146150

147-
With this technique you get all the benefits of `a11y` for your controls by simply writing your `HTML` in a specific way.
151+
:marked
152+
### Implicit labelling
148153

149-
With this writing style you simply wrap the `HTML` element inside a label tag and you are done. There is no need to
150-
generate or suppply field id's as you will see with the other methods.
154+
Firstly we will look at the absolute easiest, quickest way to furnish our form controls with accessible labels,
155+
and that is with a pattern called `implicit labelling`.
151156

152-
Implicit labelling is done as follows:
157+
`Implicit labelling` is done like this:
153158

154159
code-example(language="html" escape="html").
155160
<label>label text
156161
<input>
157162
</label>
158163

159164
:marked
160-
Of course, here the `INPUT` element can be any native `HTML` form element.
165+
Easy hey? Of course, here the `INPUT` element can be any native `HTML` form element.
161166

162-
Let us see how we would write the commonly used native `HTML` form elements in our Angular&nbsp;2 components.
167+
Let us now explore how we can use `implicit labelling` to decorate the commonly used native `HTML` form elements
168+
in our Angular&nbsp;2 components.
163169

164170
:marked
165171
#### Inputs
166172

167-
Your component template:
173+
Component template:
168174

169175
+makeExample('cb-a11y/ts/app/form-controls/a11y-input.component.html')
170176

171177
:marked
172-
Used as:
178+
User writes:
173179

174180
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-input-usage')
175181

176182
:marked
177-
Which is then rendered as:
183+
Rendered out:
178184

179185
code-example(language="html" escape="html" format="linenums").
180186
<a11y-input>
@@ -189,17 +195,17 @@ code-example(language="html" escape="html" format="linenums").
189195
:marked
190196
#### Textareas
191197

192-
Your component template:
198+
Component template:
193199

194200
+makeExample('cb-a11y/ts/app/form-controls/a11y-textarea.component.html')
195201

196202
:marked
197-
Used as:
203+
User writes:
198204

199205
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-textarea-usage')
200206

201207
:marked
202-
Which is then rendered as:
208+
Rendered out:
203209

204210
code-example(language="html" escape="html" format="linenums").
205211
<a11y-textarea>
@@ -213,17 +219,17 @@ code-example(language="html" escape="html" format="linenums").
213219
:marked
214220
#### Checkboxes
215221

216-
Your component template:
222+
Component template:
217223

218224
+makeExample('cb-a11y/ts/app/form-controls/a11y-checkboxes.component.html')
219225

220226
:marked
221-
Used as:
227+
User writes:
222228

223229
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-checkboxes-usage')
224230

225231
:marked
226-
Which is then rendered as:
232+
Rendered out:
227233

228234
code-example(language="html" escape="html" format="linenums").
229235
<a11y-checkboxes>
@@ -261,17 +267,17 @@ code-example(language="html" escape="html" format="linenums").
261267
:marked
262268
#### Radiobuttons
263269

264-
Your component template:
270+
Component template:
265271

266272
+makeExample('cb-a11y/ts/app/form-controls/a11y-radiobuttons.component.html')
267273

268274
:marked
269-
Used as:
275+
User writes:
270276

271277
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-radiobuttons-usage')
272278

273279
:marked
274-
Which is then rendered as:
280+
Rendered out:
275281

276282
code-example(language="html" escape="html" format="linenums").
277283
<a11y-radiobuttons>
@@ -309,17 +315,17 @@ code-example(language="html" escape="html" format="linenums").
309315
:marked
310316
#### Select lists
311317

312-
Your component template:
318+
Component template:
313319

314320
+makeExample('cb-a11y/ts/app/form-controls/a11y-select.component.html')
315321

316322
:marked
317-
Used as:
323+
User writes:
318324

319325
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-select-usage')
320326

321327
:marked
322-
Which is then rendered as:
328+
Rendered out:
323329

324330
code-example(language="html" escape="html" format="linenums").
325331
<a11y-select>
@@ -355,17 +361,17 @@ code-example(language="html" escape="html" format="linenums").
355361
**NOTE:** In the example code we are generating `GUID's` for id's to ensure that they are unique. You can use your
356362
own method to do this, as long as every page id is unique.
357363

358-
Your component template:
364+
Component template:
359365

360366
+makeExample('cb-a11y/ts/app/form-controls/a11y-input-explicit.component.html')
361367

362368
:marked
363-
Used as:
369+
User writes:
364370

365371
+makeExample('cb-a11y/ts/app/form-controls/a11y-form-controls.component.html','cb-a11y-form-controls-input-explicit-usage')
366372

367373
:marked
368-
Which is then rendered as:
374+
Rendered out:
369375

370376
code-example(language="html" escape="html" format="linenums").
371377
<a11y-input-explicit>

0 commit comments

Comments
 (0)