Label
Create a label that should be associated with some target form element.
Labels are used to associate a text caption with some HTML form control, such as a text input or checkbox. When connected up correctly, a11y tools will be able to associate the label with the control, and clicking on the label will focus the control.
Row {
Label(target = ElementTarget.NextSibling, label = "Name")
TextInput(...)
}
If the target element does not have an ID already set on it, this widget will create a random ID for it, as having one is required to associate a label with it.
Note that HTML provides an alternate pattern for labels, where you can create one as a parent container for some text and a child labelable element, at which point they can be connected without requiring an ID. If you want to use that pattern in your own code, you can do that using the default Compose HTML Label widget instead.
See also: https://html.spec.whatwg.org/multipage/forms.html#the-label-element
Parameters
An element finder that returns the element that this label should be associated with. Note that if the element returned is not itself labelable, its children will be recursively searched (in a breadth-first manner) for one that is. This is useful as Silk provides various widgets which expose an opaque container type with a child from element wrapped within it.