- Welcome
- Getting started
- Monthly update
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- Aria Live
- Autosuggest
- Badge
- Banner Alert
- Bar Chart
- Blockquote
- Bottom Navigation
- Bottom Sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card Button
- Carousel
- Checkbox
- Chip
- Code
- Content Cards
- Data Table
- Datepicker
- Description List
- Dialog
- Divider
- Drawer
- Field Set
- Flare
- Flat List
- Flight Leg
- Floating Action Button
- Floating Notification
- Form Label
- Form Validation
- Graphic Promotion
- Horizontal Navigation
- Icon
- Image
- Infinite Scroll
- Link
- List
- Map
- Mobile Scroll Container
- Modal
- Navigation Bar
- Nudger
- Overlay
- Page Indicator
- Pagination
- Panel
- Phone Input
- Picker
- Popover
- Price
- Progress Bar
- Radio Button
- Rating
- Scrollable Calendar
- Section List
- Select
- Skeleton
- Skip Link
- Slider
- Snackbar
- Spinner
- Split Input
- Star Rating
- Switch
- Table
- Text
- Text Input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable Native Feedback
- Touchable Overlay
- Content
- Accessibility
Star Rating
Star Ratings are used for displaying a score within a given range.
Backpack-SwiftUI/StarRating
Day | Night |
---|---|
![]() |
![]() |
Usage
To use the star rating component in your code you will need to bind the rating property and set the maxRating property. The maxRating is the maximum number of stars that can be displayed.
Basic star rating
@State var rating: Float = 3.5
BPKStarRating(rating: $rating, maxRating: 5)
Interactive star rating
@State var rating: Float = 3.5
BPKStarRating(rating: $rating, maxRating: 5) { selectedRating in
rating = selectedRating
}
Hotel star rating
@State var hotelRating: Int = 3
BPKHotelStarRating(rating: $hotelRating)
Star rating with Large size
@State var rating: Float = 3.5
BPKStarRating(rating: $rating, maxRating: 5, size: .large)
Customise Rating Rounding
Rounding can be customised by setting the rounding property. The default is .down.
@State var rating: Float = 3.5
BPKStarRating(rating: $rating, maxRating: 5, rounding: .down)
Made with ❤️ by Skyscanner © 2023
© 2023 Skyscanner Backpack. Page last updated on Apr 28, 2023, 02:20