Tiles with Icons
Display links in a grid format
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:
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:
icon
: To specify an icon, either import an SVG string and pass it to theicon
property, or use an existing icon type in Astro as a string. For available icon types, see the API documentation of theIcons
component. Icons are optional.label
: Sets a label for the tile.href
: Sets the link for the tile.target
: Sets the target of the link. Can be a valida
tag target.
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:
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:
You’ll also need to update your type definitions in tiles.ts
to avoid errors:
API
Prop | Purpose |
---|---|
columns | Sets the number of columns for the tiles. |
items | Sets the tile items. |
items.label | Sets the label for the tile. |
items.href | Sets the link for the tile. |
items.target | Sets the target of the link. |
items.icon | Sets an icon for the tile. |
Request improvement for this page