File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -334,7 +334,13 @@ reactable(data, columns = list(
334
334
335
335
This example uses Font Awesome icons
336
336
([ via Shiny] ( https://shiny.rstudio.com/reference/shiny/latest/icon.html ) )
337
- to render rating stars in a table:
337
+ to render rating stars in a table.
338
+
339
+ To make the rating star icons accessible, wrap them in a container with the
340
+ [ ARIA ` img ` role] ( https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Role_Img )
341
+ and add alternative text using an ` aria-label ` or ` title ` attribute. This
342
+ ensures that the multiple icons are identified as a single image by assistive
343
+ technologies.
338
344
339
345
``` {r}
340
346
library(htmltools)
@@ -350,8 +356,8 @@ rating_stars <- function(rating, max_rating = 5) {
350
356
stars <- lapply(seq_len(max_rating), function(i) {
351
357
if (i <= rounded_rating) star_icon() else star_icon(empty = TRUE)
352
358
})
353
- label <- sprintf("%s out of %s", rating, max_rating)
354
- div(title = label, "aria-label" = label, role = "img", stars)
359
+ label <- sprintf("%s out of %s stars ", rating, max_rating)
360
+ div(title = label, role = "img", stars)
355
361
}
356
362
357
363
ratings <- data.frame(
You can’t perform that action at this time.
0 commit comments