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/code-block/partials/code/how-to-use.md
+7-1Lines changed: 7 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## How to use this component
2
2
3
-
The basic invocation requires a `@value` argument. The component encodes this argument before displaying it.
3
+
The basic invocation requires a `@value` argument. The component encodes this argument before displaying it. To use this component, you must either include the yielded `Title` component, provide an `@ariaLabel`, or specify an `@ariaLabelledBy`.
4
4
5
5
!!! Info
6
6
@@ -10,6 +10,7 @@ If the `\n` escape sequence is used in the `@value` string in Handlebars, it wil
@@ -70,6 +71,7 @@ The `language` argument sets the syntax highlighting used. We only support the f
70
71
71
72
```handlebars
72
73
<Hds::CodeBlock
74
+
@ariaLabel="language"
73
75
@language="go"
74
76
@value="package main
75
77
import fmt
@@ -85,6 +87,7 @@ Set `hasCopyButton` to `true` to display a button for users to copy `CodeBlock`
85
87
86
88
```handlebars
87
89
<Hds::CodeBlock
90
+
@ariaLabel="copy button"
88
91
@language="javascript"
89
92
@hasCopyButton={{true}}
90
93
@copyButtonText="Copy javascript code"
@@ -99,6 +102,7 @@ Line numbers are displayed by default. Set `hasLineNumbers` to `false` to hide t
99
102
100
103
```handlebars
101
104
<Hds::CodeBlock
105
+
@ariaLabel="line numbers"
102
106
@language="javascript"
103
107
@hasLineNumbers={{false}}
104
108
@value="let codeLang=`JavaScript`;
@@ -118,6 +122,7 @@ By default, long lines of code will overflow the `CodeBlock` container requiring
118
122
119
123
```handlebars
120
124
<Hds::CodeBlock
125
+
@ariaLabel="line wrapping"
121
126
@language="javascript"
122
127
@hasLineWrapping={{true}}
123
128
@value="console.log(`I am JavaScript code`, `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam`);"
@@ -130,6 +135,7 @@ Highlight either individual code lines or a range of code lines. (Examples: `2,
130
135
131
136
```handlebars
132
137
<Hds::CodeBlock
138
+
@ariaLabel="line highlighting"
133
139
@language="javascript"
134
140
@highlightLines={{"2, 4"}}
135
141
@value="import Application from `@ember/application`;
0 commit comments