- Welcome
- Getting started
- Latest updates
- Foundations
-
Components
- Accordion
- Alert
- Alignment
- App Search Modal
- Aria live
- Autosuggest
- Badge
- Banner alert
- Bar chart
- Blockquote
- Bottom navigation
- Bottom sheet
- Breadcrumb
- Breakpoint
- Button
- Calendar
- Card
- Card list
- Card button
- Carousel
- Checkbox
- Chip
- Chip group
- 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
- Image Gallery
- Infinite scroll
- Info Banner
- Inset Banner
- Link
- List
- Map
- Mobile scroll container
- Modal
- Navigation bar
- Navigation Tab Group
- Nudger
- Overlay
- Page indicator
- Pagination
- Panel
- Phone input
- Picker
- Popover
- Price
- Progress bar
- Radio button
- Rating
- Rating Bar
- Scrollable calendar
- Search Modal
- Section header
- Section list
- Select
- Skeleton
- Skip link
- Slider
- Snackbar
- Snippet
- Spinner
- Split input
- Star rating
- Swap Button
- Switch
- Table
- Text
- Text input
- Theming
- Ticket
- Toast
- Tooltip
- Touchable native feedback
- Touchable overlay
- Search Input Summary
- Content
- Accessibility
- Contributing
- Localisation
Rating
The rating component is used to represent a score as an exact number.
Default
The rating component's appearance changes based on the value provided. The title can also be customised to pass through an image such as a partners rating logo or BpkStarRating .
Large rating
Title-only rating
The rating component can have just a title with no subtitle. Here it's seen in both horizontal and vertical styles.
Alternate scale
By default, ratings follow a 0-5 scale. Set the ratingScale prop to use a 0-10 scale instead.
The 0-10 scale should only be used in specific circumstances, like ratings coming from an external provider that use a 0-10 scale. Most things should use the 0-5 scale to give users consistency.
bpk-component-rating
Backpack rating component.
Installation
Check the main Readme for a complete installation guide.
Usage
import BpkRating, { RATING_SIZES, RATING_SCALES } from '@skyscanner/backpack-web/bpk-component-rating';
export default () => (
<BpkRating
ariaLabel="4.8 Excellent 2,420 reviews"
value={4.8}
title="Excellent"
subtitle="2,420 reviews"
/>
// Large size rating
<BpkRating
ariaLabel="4.4 Very good 120 reviews"
title="Very good"
subtitle="120 reviews"
size={RATING_SIZES.large}
value={4.4}
/>
// Title only rating
<BpkRating
ariaLabel="2.3 Bad"
title="Bad"
value={2.3}
/>
// Subtitle only rating
<BpkRating
ariaLabel="4.8 2,420 reviews"
value={4.8}
subtitle="2,420 reviews"
/>
// Show scale rating
<BpkRating
ariaLabel="3.8 Good 530 reviews"
title="Good"
subtitle="530 reviews"
value={3.8}
/>
// Hide scale rating
<BpkRating
ariaLabel="3.8 Good 530 reviews"
title="Good"
subtitle="530 reviews"
value={3.8}
showScale={false}
/>
// 0-10 scale
<BpkRating
ariaLabel="9.9 Awesome 6,549 reviews"
title="Awesome"
subtitle="6,549 reviews"
value={9.9}
ratingScale={RATING_SCALES.zeroToTen}
/>
// With a React Node element as the title
<BpkRating
ariaLabel="3 Average 1,230 reviews"
value={3}
title={
<BpkStarRating
rating={3}
ratingLabel={(rating: number, maxRating: number) =>
`Rated ${rating} out of ${maxRating} stars`
}
/>
}
subtitle="1,230 reviews"
/>
);
Props
Check out the full list of props on Skyscanner's design system documentation website.
Props
Made with ❤️ by Skyscanner © 2024
© 2024 Skyscanner Backpack. Page last updated on Oct 2, 2023, 16:01