Data Display

GridListItem

Tile within a grid-list that combines an image, title, subtitle, meta, and action slots and may link via href.

import { GridListItem } from '@lostgradient/cinder';
gridtile
01

Overview

Keyboard-navigable cell within a grid-list layout for selectable item grids.

Usage

GridListItem is a compose-only leaf of GridList. The idiomatic API is GridList.Item, reached through the parent namespace — see the grid-list README for the composed snippet. The leaf is also a named export of @lostgradient/cinder.

Selection

Pass selectable to draw a Checkbox in the card's corner, and bind selected to read and write its state. onSelectedChange is called with the new state when the checkbox toggles.

svelte
<script lang="ts">
  import { GridList } from '@lostgradient/cinder';

  let selected = $state(false);
  let toggles = $state(0);
</script>

<GridList aria-label="Photos">
  <GridList.Item selectable bind:selected onSelectedChange={() => (toggles += 1)}>
    {#snippet title()}Sunrise{/snippet}
  </GridList.Item>
</GridList>
  • The checkbox is named "Select" and the title, such as "Select Sunrise", so it does not share its name with the title's link. A selectable item needs a title. Pass selectLabel to translate the word "Select".
  • With an image, the checkbox sits inside the image's top start corner, a step in from its edges. Without one, it sits at the content's top start corner and the title, subtitle and meta make room for it on one shared edge (the actions keep the card's content edge), so the box and the title's first line share a centre line. The checkbox never covers the title.
  • A selected item sets data-cinder-selected on its <li> and draws an outline from --cinder-accent-solid.
  • The checkbox is hidden at rest. It shows on hover, on focus, under a coarse pointer (@media (any-pointer: coarse), the query Checkbox's 44px hit area uses), and on every item while any item in the list is selected: GridList sets data-cinder-selecting on the list for as long as one item is selected.
  • On a linked item the checkbox's wrapper carries data-cinder-stretched-link-escape, so pressing the checkbox toggles selection and does not follow href.

selected has no effect without selectable. GridList does not hold a selection set: bind each item's selected to your own state.

Highlight

Pass highlighted to mark an item that wants attention, such as one just uploaded. It sets data-cinder-highlighted on the <li> and draws the border from --cinder-accent-border.

Color is never the only signal: pair the highlight with text or a Badge that says why the item stands out.

svelte
<script lang="ts">
  import { Badge, GridList } from '@lostgradient/cinder';
</script>

<GridList aria-label="Photos">
  <GridList.Item highlighted>
    {#snippet title()}Sunrise{/snippet}
    {#snippet meta()}<Badge variant="accent">New</Badge>{/snippet}
  </GridList.Item>
</GridList>

When an item is both highlighted and selected, the selected outline wins: its rule comes later in grid-list.css, so the selection color, not the accent border, is the one you see.

Media bleed

By default the image slot sits inside the card's padding, which makes a card with a thumbnail taller than the padding alone suggests. Pass mediaBleed to run the image to the card's left, right and top edges instead. It sets data-cinder-media-bleed on the <li>; the image takes the card's radius on its top corners and clips to it.

svelte
<script lang="ts">
  import { GridList } from '@lostgradient/cinder';
</script>

<GridList aria-label="Photos">
  <GridList.Item mediaBleed>
    {#snippet image()}<img src="/photos/sunrise.jpg" alt="" />{/snippet}
    {#snippet title()}Sunrise{/snippet}
  </GridList.Item>
</GridList>

mediaBleed applies to the image slot only. Title, subtitle, meta and actions keep the card's padding, and the stretched-link overlay still covers the whole card.

Focus ring

On a linked card the focus ring wraps the whole card, not just the title's text. It is drawn on the stretched link's overlay, a step outside the card's border with a gap between them. A selected card's outline sits over the border instead, so focused and selected differ by shape as well as by color.

Subtitle lines

A subtitle wraps freely, so a long one can stretch a card well past its neighbours at a narrow width. Pass subtitleLines (1 or 2, as on GroupedListItem) to cap the subtitle at that many lines, ending it in an ellipsis. It sets data-cinder-subtitle-lines and a --cinder-grid-list-subtitle-lines custom property on the subtitle wrapper, and the stylesheet clamps with line-clamp and -webkit-line-clamp.

svelte
<script lang="ts">
  import { GridList } from '@lostgradient/cinder';
</script>

<GridList aria-label="Videos">
  <GridList.Item subtitleLines={1} subtitleTooltip="Uploaded three days ago by the harbor team">
    {#snippet title()}Harbor at dusk{/snippet}
    {#snippet subtitle()}Uploaded three days ago by the harbor team{/snippet}
  </GridList.Item>
</GridList>

The clamp caps how tall a card can grow; it does not give every card one height, because a card with a shorter subtitle or no subtitle stays shorter. The clamp is CSS only: the full text stays in the DOM, so assistive technology reads all of it. Unset, the subtitle is unclamped.

Pass subtitleTooltip with the subtitle's full text so a pointer can read what the clamp cut. It is drawn as the card's one native tooltip, on the <li> and not on the subtitle, so it can be read anywhere on a linked card, where the link's overlay lies over the subtitle.

Interactive content on a linked item

A linked item's title is a stretched link: its ::after overlay covers the whole card, so a press anywhere on the card follows href. Only the actions slot and descendants marked with data-cinder-stretched-link-escape sit above the overlay and stay clickable.

data-cinder-stretched-link-escape is stable public API. Put it on any interactive element that lives outside actions, such as a link in meta or a control you place yourself:

svelte
<script lang="ts">
  import { GridList } from '@lostgradient/cinder';
</script>

<GridList aria-label="People">
  <GridList.Item href="/people/jane">
    {#snippet title()}Jane Cooper{/snippet}
    {#snippet meta()}
      <a href="/teams/design" data-cinder-stretched-link-escape>Design team</a>
    {/snippet}
  </GridList.Item>
</GridList>

The attribute lifts the element above the overlay with position: relative; z-index: 1, so give it no position of your own. The selection checkbox of a selectable item uses it. The contract is the test escape attribute renders inside a non-actions wrapper in grid-list-item.test.ts.

02

When to use

Use when
  • Rendering a single card cell inside a grid-list parent.
  • Turning the tile into an anchor by passing href.
Avoid when
  • Standing alone outside a grid-list — it inherits the grid layout context.
03

Props

Props for grid-list-item
Name
Type
Default
Description
href text Destination URL. When set, the title snippet is rendered as a stretched <a> anchor covering the entire tile.
target HTMLAnchorAttributes['target'] When target matches "_blank" (case-insensitive), the component automatically composes rel="noopener noreferrer" with any consumer-supplied rel tokens to prevent reverse-tabnapping.
rel HTMLAnchorAttributes['rel'] rel attribute forwarded to the stretched-link anchor; noopener noreferrer is merged automatically when target="_blank".
selectable boolean false Draws a checkbox on the card, named "Select" and the title, so the item can be selected. It sits in the image's top corner, or beside the title when there is no image. A press on the checkbox toggles selection and never follows href. The checkbox shows on hover, on focus, under a coarse pointer, and on every item while any item in the list is selected.
selected bindable boolean false Bindable selection state. Applies only when selectable. A selected item sets data-cinder-selected and draws its outline.
onSelectedChange (selected: boolean) => void Called with the new state after the checkbox toggles.
selectLabel text 'Select' The word before the title in the selection checkbox's accessible name, so the box is named "Select Sunrise" and not "Sunrise", which is the link's name. Translate it for another language.
highlighted boolean false Marks an item that wants attention, such as one just uploaded: sets data-cinder-highlighted and draws the border in the accent color. Color is never the only signal, so pair it with text or a Badge. A selected item's outline wins over the highlight.
mediaBleed boolean false Runs the image slot to the card's left, right and top edges, with the card's radius on its top corners, instead of insetting it by the card's padding. Sets data-cinder-media-bleed. Title, subtitle, meta and actions keep their padding.
subtitleLines 1 | 2 The most lines the subtitle takes, at every width, before it ends in an ellipsis. It caps how tall a card can grow, so a long subtitle cannot stretch one card far past its neighbours; it does not give every card one height. Sets data-cinder-subtitle-lines and --cinder-grid-list-subtitle-lines on the subtitle wrapper. The full text stays in the DOM, so assistive technology reads all of it; pass subtitleTooltip so a pointer can read what the clamp cut. Left unset, the subtitle wraps unclamped.
subtitleTooltip text The subtitle's full text, drawn as the card's one native tooltip. The tooltip is on the card rather than on the subtitle, so a pointer reads it anywhere on a linked card, where the link's cover lies over the subtitle.
image snippet Optional image region (avatar, thumbnail).
title snippet Primary label. Provides the accessible name for the stretched link when href is set.
subtitle snippet Secondary description.
meta snippet Tertiary metadata (badges, supplementary text).
actions snippet Action buttons. This wrapper is lifted above the stretched-link overlay via position: relative; z-index: 1 so buttons remain clickable.