Tile

lightning-tile

A grouping of related information associated with a record.

For Use In

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline

A lightning-tile component groups related information associated with a record. The information can be actionable and paired with a figure, such as a lightning-icon or lightning-avatar component.

Use the class attributes to customize the styling. To style the tile body, use the Lightning Design System utility classes.

This component implements styling from tiles in the Lightning Design System.

Here is an example.

1<template>
2    <lightning-tile label="Lightning component team" href="/path/to/somewhere">
3        <p class="slds-truncate" title="7 Members">7 Members</p>
4    </lightning-tile>
5</template>

To insert an icon or avatar, pass it into the media slot. You can create a tile with an icon using definition lists. This example aligns an icon and some text using utility classes like slds-dl_horizontal.

1<template>
2    <lightning-tile label="Salesforce UX" href="/path/to/somewhere">
3        <span slot="media">
4            <lightning-icon
5                icon-name="standard:groups"
6                alternative-text="Groups"
7            >
8            </lightning-icon>
9        </span>
10        <dl class="slds-dl_horizontal">
11            <dt class="slds-dl_horizontal__label">
12                <p class="slds-truncate" title="Company">Company:</p>
13            </dt>
14            <dd class="slds-dl_horizontal__detail slds-tile__meta">
15                <p class="slds-truncate" title="Salesforce">Salesforce</p>
16            </dd>
17            <dt class="slds-dl_horizontal__label">
18                <p class="slds-truncate" title="Email">Email:</p>
19            </dt>
20            <dd class="slds-dl_horizontal__detail slds-tile__meta">
21                <p class="slds-truncate" title="salesforce-ux@salesforce.com">
22                    salesforce-ux@salesforce.com
23                </p>
24            </dd>
25        </dl>
26    </lightning-tile>
27</template>

You can also create a list of tiles with avatars using an unordered list. This example places tiles in a list and creates dividers using utility classes like slds-has-dividers_bottom-space.

1<template>
2    <ul class="slds-has-dividers_bottom-space">
3        <li class="slds-item">
4            <lightning-tile
5                type="media"
6                label="Astro"
7                href="/path/to/somewhere"
8            >
9                <span slot="media">
10                    <lightning-avatar
11                        src="/path/to/img"
12                        alternative-text="Astro"
13                        fallback-icon-name="standard:person_account"
14                    >
15                    </lightning-avatar>
16                </span>
17                <ul class="slds-list_horizontal slds-has-dividers_right">
18                    <li class="slds-item">Trailblazer, Salesforce</li>
19                    <li class="slds-item">Trailhead Explorer</li>
20                </ul>
21            </lightning-tile>
22        </li>
23        <!-- More list items here -->
24    </ul>
25</template>

You can add a dropdown menu with actions to a tile. To find out which sections are active, use the actiontriggered event.

1<template>
2    <lightning-tile
3        label="My Open Cases"
4        href="/path/to/my-open-cases"
5        actions={actions}
6        onactiontriggered={handleAction}
7    >
8        <p class="slds-truncate" title="10 Cases">10 Cases</p>
9    </lightning-tile>
10</template>

Use the detail property to return the action that was triggered.

1import { LightningElement, track } from "lwc";
2
3export default class DemoTileAction extends LightningElement {
4  @track actions = [
5    { label: "Edit", value: "edit", iconName: "utility:edit" },
6    { label: "Delete", value: "delete", iconName: "utility:delete" },
7  ];
8
9  handleAction(event) {
10    // Get the value of the selected action
11    const tileAction = event.detail.action.value;
12  }
13}

Design Guidelines 

A tile requires a label and can include a supporting icon or avatar, and additional elements. You interact with elements within the tile, such as buttons and links, not the tile as a whole. Data is presented as label­-value pairs. The user interacts with elements within the tile, such as buttons and links, not the tile as a whole.

Use tiles when you are horizontally constrained for space. Tiles are appropriate for short lists, using a <ul> or <dl> for example, that are fewer than 10 items. Tile layouts do not stretch well, so to use available horizontal space, add a column of tiles. On wider screens where more than 2 columns of tiles will appear, tile lists should elegantly and responsively expand into tables.

Usage Considerations 

Icons are not available in Lightning Out, but they are available in Lightning Components for Visualforce and other experiences.

This component has usage differences from its Aura counterpart. See Base Components: Aura Vs Lightning Web Components in the Lightning Web Components Developer Guide.

Custom Events 

actiontriggered

The event fired when an action on the dropdown menu is triggered.

The actiontriggered event returns the following parameter.

ParameterTypeDescription
actionobjectThe selected action.

The event properties are as follows.

PropertyValueDescription
bubblesfalseThis event does not bubble.
cancelablefalseThis event has no default behavior that can be canceled. You can't call preventDefault() on this event.
composedfalseThis event does not propagate outside the template in which it was dispatched.

Attributes 

NameDescriptionTypeDefaultRequired
actionsA list of actions that's displayed in a dropdown menu.list
hrefThe URL of the page that the link goes to.string
labelThe text label that displays in the tile as the heading and hover text.string
typeThe tile type. Valid values are 'standard' and 'media'. The default is 'standard'.stringstandard

Slots 

NameDescription
defaultPlaceholder for your content that appears below the heading.