Search documentation v0.10.1

Toplist

Display ranked list of items

Source Report Issue

Use the Toplist component to display ranked lists of items, such as best-performing products, top-rated services, or trending content.

  • Property
    Toplist ComponentSet subtitlesLast booked 2 minutes ago
    Add description with HTML support.
    1
  • Property
    Holiday ColorsBook now, pay laterLast booked 3 minutes ago
    Rated exceptional (10) out of 16 reviews.
    2
  • On sale Property
    WestSide GardenEntire apartmentLast booked 4 minutes ago
    Rated very good (8.2) out of 85 reviews.
    3
Unlock code
How to use the Toplist component in Astro
---
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:

An item object can also have the following optional properties:

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:

  • Property
    Unconnected toplistSet subtitles
    Add description with HTML support.
    1
  • Property
    Holiday ColorsBook now, pay later
    Rated exceptional (10) out of 16 reviews.
    2
  • On sale Property
    WestSide GardenEntire apartment
    Rated very good (8.2) out of 85 reviews.
    3
  • Property
    Toplist without positionSet subtitles
    Add description with HTML support.
  • Property
    Holiday ColorsBook now, pay later
    Rated exceptional (10) out of 16 reviews.
  • On sale Property
    WestSide GardenEntire apartment
    Rated 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 sale Property
    Toplist ComponentSet subtitles
    Add description with HTML support.
    1
  • On sale Property
    Holiday ColorsBook now, pay later
    Rated exceptional (10) out of 16 reviews.
    2
  • On sale Property
    WestSide GardenEntire apartment
    Rated very good (8.2) out of 85 reviews.
    3
Unlock code
How to use ribbons
---
const items = [
{
...,
ribbon: {
text: 'On sale',
theme: 'alert'
}
}, { ... }, { ... }
]
---
<Toplist items={items} />
The 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:

  • Property
    Primary (default)Set subtitles
    Add description with HTML support.
    1
  • Property
    Holiday ColorsBook now, pay later
    Rated exceptional (10) out of 16 reviews.
    2
  • On sale Property
    WestSide GardenEntire apartment
    Rated very good (8.2) out of 85 reviews.
    3
  • Property
    SecondarySet subtitles
    Add description with HTML support.
    1
  • Property
    Holiday ColorsBook now, pay later
    Rated exceptional (10) out of 16 reviews.
    2
  • On sale Property
    WestSide GardenEntire apartment
    Rated very good (8.2) out of 85 reviews.
    3
Unlock code
You can use CardProps with your toplist items
---
const items = [
{
...,
secondary: true,
}, { ... }, { ... }
]
---
<Toplist items={items} />

API

Unlock code
Component API reference
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
}
Please see the documentation of the Ribbon and Card components for the RibbonProps and CardProps types.
PropDefaultPurpose
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.