Collection Deprecated
Deprecated
Do not use it in new code. It stays documented to help migrate its remaining usages.
Use instead:
Lays items out in a set number of columns, under a shared header. Use for a grid of cards.
- Overview
- Props
- Figma
Basic usage
- Specify the number of columns you want to display in the
Collectioncomponent. - Add a collection header to define the title.
- Add as many
Collection.Itemcomponents as needed, ensuring each has the same number of children as the columns you specified.
Collection demo
Item 1 - Column 1
Item 1 - Column 2
Item 1 - Column 3
Item 2 - Column 1
Item 2 - Column 2
Item 2 - Column 3
Bleeding variant
Expend the border of the Collection.Header to create a visually appealing finish that fully utilizes the available space.
You can adjust the padding or margin of your container by using the bleedingOffset prop.
Collection demo
Item 1 - Column 1
Item 1 - Column 2
Item 1 - Column 3
Item 2 - Column 1
Item 2 - Column 2
Item 2 - Column 3
Advanced usages
With row links
Just wrap the Collection.Item in an A, Link, React router Link, or NavLink to make it clickable.
👉 Don't forget to add the hasLinkArrow prop to the Collection.Item to add the arrow icon.
🌐 If you're building a universal component, we recommend you to rely as much as possible on A to manage the link.
With a right section
If you need to align a component to the right of the Collection.Item, you can use the rightSection prop.
Collection demo
Item 1 - Column 1
Item 1 - Column 2
Item 1 - Column 3
Item 2 - Column 1
Item 2 - Column 2
Item 2 - Column 3
Enhanced first column
By passing a title or a description to the Collection.Item, it will be rendered in the first column with predefined styles.
Collection demo
Item title
An additional description
Item 1 - Column 2
Item 1 - Column 3
Item title
An additional description
Item 2 - Column 2
Item 2 - Column 3
Handling possible empty columns
The display of the component is based on the number of children of Collection.Item. Make sure you have the exact number of children according to the columns number.
For example, don't use a React fragment to display multiple children.
Don't
<Collection.Item>
<Text>Item X - Column 1</Text>
{/* Don't */}
{YOUR_CONDITION && (
<>
<Text>Item X - Column 2</Text>
<Text>Item X - Column 3</Text>
</>
)}
</Collection.Item>
Do
<Collection.Item>
<Text>Item 2 - Column 1</Text>
{/* Do */}
{YOUR_CONDITION && <Text>Item 2 - Column 2</Text>}
{YOUR_CONDITION && <Text>Item 2 - Column 3</Text>}
</Collection.Item>
Playground
murray and murray/mobile.Collection props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| bleeding | booleanundefined | defaultContext.bleeding | Makes the separator under the header overflow. Preferably used on full-page layouts | |
| bleedingOffset | 58 possibilitiesundefinednumber"$0""$1""$2""$4""$6""$8""$10""$12""$14""$16""$20""$24""$28""$32""$36""$40""$44""$48""$56""$64""$80""$96""$112""$128""$144""$160""$176""$192""$px0""$px1""$px2""$px4""$px6""$px8""$px10""$px12""$px14""$px16""$px20""$px24""$px28""$px32""$px36""$px40""$px44""$px48""$px56""$px64""$px80""$px96""$px112""$px128""$px144""$px160""$px176""$px192" | defaultContext.bleedingOffset | Define the size of the bleeding. Ensure it matches the padding of the container (default is $px40) | |
| children* | ReactNode | Should contain at least one <Collection.Header/> and as many as you want of <Collection.Item/>. You can also wrap <Collection.Item/> with any link components to make them pressable | ||
| columns | numbernullundefined | defaultContext.columns | Define the number of columns you want visually in your collection | |
| highlightOnHover | booleanundefined | defaultContext.highlightOnHover | Highlights the entire line on hover. Preferably used with the bleeding mode |
Collection.Item props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| description | stringundefined | Define the description of your item. If defined, it will be added at the start of the row | ||
| hasLinkArrow | booleanundefined | false | ||
| leftSection | ReactNode | Only displayed if you define a title or a description. Allows you to use components to illustrate your row. Size is fixed to 40px and the component will be centered inside it. We recommend to use a maximum of 32px for your Icons, Blobbys, Emojis... | ||
| rightSection | ReactNode | Allows you to add components at the end of your row. | ||
| title | stringundefined | Define the title of your item. If defined, it will be added at the start of the row |
Collection.Header props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| label | stringundefined | Additional label next to the title in different level of gray. Useful to add a counter for example | ||
| title | stringundefined | Title of your collection |