KRadioButton: Improve flexibility and accessibility of labels #348
Labels
category: library
Shared code library
Component: KRadioButton
DEV: frontend
product: Kolibri
Relevant to a specific issue in Kolibri
TAG: a11y
TODO: needs decisions
Further discussion and planning necessary
type: proposal
New feature or request
Milestone
Product
Kolibri
Example: choosing a new super admin when changing facility
Desired behavior
(1)
KRadioButton
can receive HTML label contentSo that we can easily use components to render label content, for example, this radio button label
can't be provided as mere text as it's generated by
KLabeledIcon
component:(2)
KRadioButton
uses explicit labelsExplicit labels are labels that are linked to
input
via itsid
passed to<label>
'sfor
attribute.In support of (3)
Explicit labels are said to work better in regards to a11y:
(3)
<label>
can be defined outside ofKRadioButton
<label>
the same way we'd work with it when using it together with the native<input
> thatKRadioButton
models:<input>
and<label>
orderKCheckbox
andKRadioButton
when the label is the same without the need to duplicate label code (useful especially for more complex labels that are generated by other components):id
toKRadioButton
so that we can use it infor
attribute oflabel
.Summary
Label content could be provided in several ways
(a) Simple text via the
label
property(b) HTML content via slot
(c) Independently of
KRadioButton
In regards to (a) and (b), when
<label>
would be rendered inside ofKRadioButton
, we'd use explicit labels. To achieve explicit labels support for (c),KRadioButton
will need to receive its insideinput
's id from outside via aprop
.Current behavior
KRadioButton
only supports passing text for the label via thelabel
property<input>
wrapped in<label>
without having these two linked withid
andfor
)The Value Add
Possible Tradeoffs
label
property.label
property would not be provided which is helpful to make sure we don't forget to labelHowever, I think there's no need to limit ourselves in regards to supporting more complex scenarios. To solve this, I'd suggest that in documentation, we encourage (a) whenever possible, provide usage examples, and include truncation and a11y warnings for other use-cases.
The text was updated successfully, but these errors were encountered: