🚀 Ship faster with premium components 🚀
Search documentation v1.3.0

Tiles with Icons

Display links in a grid format

Source Report Issue
How to add this block to your project
npm create webcore@latest add Tiles

Use the Tiles component to display navigation links in a grid format to structure information clearly, allowing users to scan and find content quickly. Tiles are response, but their column count can also be set explicitly. They can be created with or without icons:

How to use the Tiles component
<Tiles
items={[
{ icon: astro, label: 'Astro', href: '#' },
{ icon: svelte, label: 'Svelte', href: '#' },
{ icon: react, label: 'React', href: '#' },
{ icon: terminal, label: 'CLI', href: '#' }
]}
/>

The Tiles component expects an items prop that defines the links in the form of an array of objects. Each object can have the following properties:

Subtext

The tile can be accompanied by a subtext, displayed below the label. The subtext can be set using the subText property on each tile:

How to add subText to tiles
<Tiles
items={[{
icon: 'home',
label: 'Home',
subText: 'Explore latest'
href: '#'
}, { ... }, { ... }, { ... }]}
/>

Badges

You can also optionally add badges to tiles. Badges will be displayed at the top-right corner of each tile. The badge can be set using the badge property:

How to add badges to a tile
<Tiles
items={[{
icon: 'github',
label: 'GitHub',
subText: 'Star us on GitHub'
href: 'github.com/Frontendland/webcoreui',
badge: {
text: '★ 123 stars',
theme: 'warning',
transparent: true
}
}, { ... }, { ... }, { ... }]}
/>

Columns

By default, the Tiles component will use a two column layout. The exceptions from this is if the tiles has 1 or 3 items. If there is only one element, it’ll display the tile using a single column. For exactly 3 items, it’ll display the tiles in a 3 column layout. An explicit column can also be specified using the columns prop:

Astro
Svelte
React
CLI
<Tiles
columns={4}
items={[ ... ]}
/>

Column can go up to a maximum of 4. If you need to have more columns, you can add the following css rules to your Tiles component:

@use 'webcoreui/config' as *;
@include media(xs) {
// For a six column layout, add the following:
.xs-6 {
grid-template-columns: repeat(6, minmax(0, 1fr));
}
}

You’ll also need to update your type definitions in tiles.ts to avoid errors:

import type { ButtonProps, IconProps } from 'webcoreui/astro'
export type TilesProps = {
columns?: 0 | 1 | 2 | 3 | 4
columns?: 0 | 1 | 2 | 3 | 4 | 6
items: {
label: string
href: string
target?: ButtonProps['target']
icon?: IconProps['type'] | string
}[]
}

API

type TilesProps = {
columns?: 0 | 1 | 2 | 3 | 4
items: {
label: string
subText?: string
href?: string
target?: '_self'
| '_blank'
| '_parent'
| '_top'
| '_unfencedTop'
icon?: string
badge?: {
text: string
icon?: string
} & BadgeProps
}[]
}
PropPurpose
columns Sets the number of columns for the tiles.
items Sets the tile items.
items.label Sets the label for the tile.
items.subText Sets the subtext for the tile under the label.
items.href Sets the link for the tile.
items.target Sets the target of the link.
items.icon Sets an icon for the tile.
items.badge.text Adds a badge on top of the tile.
items.badge.icon Sets an optional icon for the badge.