This article from the leaflet R package is a good example to use addLayersControl. Since the palette are already defined, it's straightforward, with one call of addPolygons for each map/year. Finally, htmlwidgets::saveWidget() allow to export the map into a file.
map1 = leaflet(st_trans ) |>
addPolygons( col = ~pal_2020(total_cat_2020), group= "2020") |>
addPolygons( col = ~pal_2021(total_cat_2021), group= "2021") |>
addPolygons( col = ~pal_2022(total_cat_2022), group= "2022") |>
addLayersControl(baseGroups =c("2020","2021","2022"),
options = layersControlOptions(collapsed = FALSE))
htmlwidgets::saveWidget(map1, file="map1.html")