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: site/content/docs/05-accessibility-warnings.md
+49Lines changed: 49 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,6 +128,55 @@ There are two supported ways to associate a label with a control:
128
128
<label>A</label>
129
129
```
130
130
131
+
If your label and input are Svelte components, you can configure the rule to be aware of your custom components.
132
+
133
+
```svelte
134
+
<CustomInputLabel label="Surname">
135
+
<CustomInput type="text" bind:value />
136
+
</CustomInputLabel>
137
+
```
138
+
139
+
And the configuration:
140
+
141
+
```js
142
+
// svelte.config.js
143
+
exportdefault {
144
+
compilerOptions: {
145
+
a11y: {
146
+
rules: {
147
+
'label-has-associated-control': {
148
+
labelComponents: ['CustomInputLabel'],
149
+
controlComponents: ['CustomInput'],
150
+
}
151
+
}
152
+
}
153
+
},
154
+
}
155
+
```
156
+
157
+
**Configuration**
158
+
159
+
```js
160
+
// svelte.config.js
161
+
exportdefault {
162
+
compilerOptions: {
163
+
a11y: {
164
+
rules: {
165
+
'label-has-associated-control': {
166
+
labelComponents: ['CustomInputLabel'],
167
+
controlComponents: ['CustomInput'],
168
+
depth:3,
169
+
}
170
+
}
171
+
}
172
+
},
173
+
}
174
+
```
175
+
176
+
-`labelComponents` is a list of Svelte component names that should be checked for an associated control.
177
+
-`controlComponents` is a list of Svelte component names that will output an input element.
178
+
-`depth` (default 3, max 25) is an integer that determines how deep within the label element the rule should look for an element to determine if the label element has associated control.
0 commit comments