Toplist
Display ranked list of items
Use the Toplist
component to display ranked lists of items, such as best-performing products, top-rated services, or trending content.
- Toplist ComponentSet subtitlesLast booked 2 minutes ago1Add description with HTML support.
- Holiday ColorsBook now, pay laterLast booked 3 minutes ago2Rated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartmentLast booked 4 minutes ago3Rated very good (8.2) out of 85 reviews.
---const items = [ { img: { src: '/img/property.png', alt: 'Property', width: 100, height: 125 }, title: 'Toplist Component', subTitle: 'Set subtitles', meta: 'Last booked 2 minutes ago', text: 'Add description with <b>HTML</b> support.' }, { ... } { ... }]---
<Toplist items={items} />
The Toplist
component expects an items
prop that describes each toplist item in the form of an objects. Each object must have the following properties:
img
: Sets an image for the item.title
: Sets a title.text
: Sets a short description.
An item object can also have the following optional properties:
href
: Adds a link for the item. Ifhref
is not set, the element will be rendered as adiv
. This behavior can be changed inside the component here.target
: Sets the target for the link when thehref
property is used.subTitle
: Sets a sub-title under thetitle
property.meta
: Sets additional information under thesubTitle
property.
Connection and Position Numbers
The component supports two different variants; connected and numbered toplists. Both options are enabled by default and can be disabled using the connected
and showPosition
props:
- Unconnected toplistSet subtitles1Add description with HTML support.
- Holiday ColorsBook now, pay later2Rated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartment3Rated very good (8.2) out of 85 reviews.
- Toplist without positionSet subtitlesAdd description with HTML support.
- Holiday ColorsBook now, pay laterRated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartmentRated very good (8.2) out of 85 reviews.
Ribbons
The items can be highlighted using ribbons. To set a ribbon, specify a ribbon
object on your item with a text
property:
- On saleToplist ComponentSet subtitles1Add description with HTML support.
- On saleHoliday ColorsBook now, pay later2Rated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartment3Rated very good (8.2) out of 85 reviews.
---const items = [ { ..., ribbon: { text: 'On sale', theme: 'alert' } }, { ... }, { ... }]---
<Toplist items={items} />
ribbon
property can also be described using RibbonProps
. Please see the documentation of the Ribbon
component to learn more about how to customize ribbons. Card Types
Toplist items extend the Card
component, meaning you can use card-specific props with your item to change its appearance, such as secondary
, or compact
:
- Primary (default)Set subtitles1Add description with HTML support.
- Holiday ColorsBook now, pay later2Rated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartment3Rated very good (8.2) out of 85 reviews.
- SecondarySet subtitles1Add description with HTML support.
- Holiday ColorsBook now, pay later2Rated exceptional (10) out of 16 reviews.
- On saleWestSide GardenEntire apartment3Rated very good (8.2) out of 85 reviews.
---const items = [ { ..., secondary: true, }, { ... }, { ... }]---
<Toplist items={items} />
API
type ToplistProps = { items: ({ href?: string target?: '_self' | '_blank' | '_parent' | '_top' | '_unfencedTop' img: { src: string alt: string width: number height: number lazy?: boolean } title: string subTitle?: string meta?: string text: string ribbon?: ({ text: string } & RibbonProps) } & CardProps)[] showPosition?: boolean connected?: boolean className?: string}
Prop | Default | Purpose |
---|---|---|
items | - | Pass an array of objects to set the toplist items. |
items.href | - | Sets a link for the toplist item. |
items.target | - | Sets the target for the link. |
items.img | - | Sets an image for the toplist item. |
items.img.src | - | Sets the path for the image. |
items.img.alt | - | Sets an alternate text for the image. |
items.img.width | - | Sets the width of the image. |
items.img.height | - | Sets the height of the image. |
items.img.lazy | - | Set to true to enable lazy loading for the image. |
items.title | - | Sets the title for the item. |
items.subTitle | - | Sets a sub-title for the item. |
items.meta | - | Sets additional information under the sub-title. |
items.text | - | Sets a description for the item. |
ribbon.text | - | Sets a ribbon for the item. |
showPosition | true | Shows position numbers in the top-right corner of each item. |
connected | true | Connects the toplist items with a line. |
className | - | Pass additional CSS classes for your toplist. |