Ratings show people’s opinions of a product, helping others make more informed purchasing decisions. People can also rate products they’ve purchased.
For more details and examples visit the official docs. The R package can not handle each and every case, so for advanced use cases you need to work using the original docs to achieve the desired result.
Rating(...)
Rating.shinyInput(inputId, ..., value = defaultValue)
updateRating.shinyInput(
session = shiny::getDefaultReactiveDomain(),
inputId,
...
)
boolean
Allow the rating value to be set to 0 instead of a minimum of 1.
string
Optional label format for a rating star that will be read by screen readers. Can be used like "{0} of {1} stars selected", where {0} will be substituted by the current rating and {1} will be substituted by the max rating.
string
Deprecated: Optional id of label describing this instance of Rating.
IRefObject<IRating>
Optional callback to access the IRating interface. Use this instead of ref for accessing the public methods and properties of the component.
(rating: number, max: number) => string
string
Custom icon
number
Maximum rating, defaults to 5, has to be \>= min
number
Minimum rating, defaults to 1, has to be \>= 0
(event: React.FocusEvent<HTMLElement>, rating?: number) => void
Callback issued when the rating changes.
(rating: number) => void
number
Selected rating, has to be an integer between min and max
boolean
Optional flag to mark rating control as readOnly
RatingSize
Size of rating, defaults to small
IStyleFunctionOrObject<IRatingStyleProps, IRatingStyles>
Call to provide customized styling that will layer on top of the variant rules.
ITheme
Theme (provided through customization.)
string
Custom icon for unselected rating elements.
Make it clear which item the rating pertains to by making sure the layout and grouping are clear when several items are on the page.
Don't use the rating component for data that has a continuous range, such as the brightness of a photo. Instead, use a slider.
Use a five-star rating system.
Use sentence-style capitalization—only capitalize the first word. For more info, see Capitalization in the Microsoft Writing Style Guide.
library(shiny.fluent)
if (interactive()) {
shinyApp(
ui = div(
Rating.shinyInput("rating", value = 2),
textOutput("ratingValue")
),
server = function(input, output) {
output$ratingValue <- renderText({
sprintf("Value: %s", input$rating)
})
}
)
}