CwCardDataRowItem

Reusable sensor-style key/value row for detail panels, cards, and metadata lists. This is the same component used inside CwDataList and the expanded CwSensorCard, now with built-in freshness scheduling and a bindable timeout state.

Standard list

Use it inside a semantic list container

The component renders a list item, so wrap it with ul or ol when you use it standalone.

Device detail rows

Standalone CwCardDataRowItem usage

  • Temperature
    22.40 °C
  • Humidity
    67.30 %
  • Last Update
    ago
Live duration

Built-in freshness scheduler with bindable state

Use lastSeenAt plus expireAfterMinutes to turn the row into a freshness monitor. The row now schedules expiry internally and exposes both onExpire and bind:withinTimeout.

Current freshness state: no timer

Freshness monitor

Alarm fires a few seconds after load

  • Last Update
    ago
Flexible icons

Built-ins, emoji, or snippets all work

Use thermo, drop, or timer for the built-in SVGs, or pass a plain string like an emoji for one-off metadata rows.

Mixed metadata

Custom icon content

  • Relay State
    On
  • Lux Level
    48500 lx
List of built-in sensor rows Copy code
<ul>
	<CwCardDataRowItem
		id="temperature"
		label="Temperature"
		value="22.40"
		unit="°C"
		icon="thermo"
	/>
	<CwCardDataRowItem
		id="humidity"
		label="Humidity"
		value="67.30"
		unit="%"
		icon="drop"
	/>
	<CwCardDataRowItem
		id="updated"
		label="Last Update"
		icon="timer"
		lastSeenAt={new Date(Date.now() - 120_000)}
		expireAfterMinutes={10}
	/>
</ul>
Freshness row with bindable timeout state Copy code
<script lang="ts">
	let withinTimeout = $state<boolean | null>(null);
	let expired = $state(false);
</script>

<ul>
	<CwCardDataRowItem
		id="updated"
		label="Last Update"
		icon="timer"
		lastSeenAt={new Date(Date.now() - 120_000)}
		expireAfterMinutes={10}
		onExpire={() => (expired = true)}
		bind:withinTimeout
	/>
</ul>

<p>Within timeout: {withinTimeout}</p>
<p>Expired callback fired: {expired}</p>
Custom icon row Copy code
<CwCardDataRowItem
	id="relay-state"
	label="Relay State"
	value="On"
	icon="⚡"
/>
Documentation Upgrade

Start here

CwCardDataRowItem is the reusable detail-row primitive behind CwDataList and the expanded CwSensorCard panel. Use it anywhere you need a compact sensor-style label/value row with optional built-in icons and freshness timers.

How to think about it

  1. Wrap it in a real list The component renders an `<li>`, so use it inside `ul` or `ol` when you render it directly.
  2. Use built-ins first Set `icon` to `thermo`, `drop`, or `timer` for the shared SVG icons. Plain strings and snippets still work for custom metadata.
  3. Switch to timer mode with `lastSeenAt` When `lastSeenAt` is present, the value side renders `CwDuration` automatically and appends the `ago` suffix. `lastUpdated` still works as a backwards-compatible alias.
  4. Use expiry callbacks or bind freshness state Use `onExpire`, `onTimeoutReset`, and `bind:withinTimeout` when a parent needs to react to stale data. You can still pass the legacy `alarmCallback` names if needed.

Row props

Because the component renders `<li>`, the surrounding list container stays your responsibility.

APITypeDetails
id Required
stringStable identifier for keyed rendering, telemetry hooks, or debug attributes.
label Required
stringRow label shown on the left side.
value
string | number | nullStatic value shown on the right side when `lastUpdated` is not supplied.
unit
stringOptional suffix rendered after `value`, for example `%`, `°C`, or `km/h`.
icon
'drop' | 'thermo' | 'timer' | string | SnippetBuilt-in icon keyword, plain string content such as emoji, or a custom snippet.
lastSeenAt / lastSeen / LastSeen / lastUpdated
Date | string | numberSwitches the row into live timer mode via `CwDuration`. Prefer `lastSeenAt`; `lastUpdated` remains supported for compatibility.
expireAfterMinutes / alarmTimeoutMinutes / AlarmTimeoutMinutes / expectedUpdateAfter
numberMinutes until the freshness alarm is considered overdue. Prefer `expireAfterMinutes`; `expectedUpdateAfter` remains supported for compatibility.
onExpire
() => voidCalled once when the row crosses its freshness timeout.
onTimeoutReset
() => voidCalled when the row returns to a non-expired state after previously being overdue.
bind:withinTimeout
boolean | nullBindable freshness state. `true` means fresh, `false` means expired, and `null` means no timer inputs were supplied.
alarmScheduler
CwAlarmApiOptional shared scheduler. Omit it to let the row create and manage its own alarm scheduler internally.
alarmCallback / AlarmCallback / alarmResetCallback / AlarmResetCallback
() => voidLegacy callback aliases preserved for existing integrations.
status
'online' | 'offline' | 'warning' | 'loading'Optional metadata hook preserved on the row so parent components can round-trip row state.
class
stringExtra class applied to the root row element.

Copy-paste examples

These snippets intentionally show the full public API surface the live demo relies on.

Built-in sensor rows

The default pairing for temperature, humidity, and freshness data.

Built-in sensor rows Copy code
<ul>
	<CwCardDataRowItem id="temperature" label="Temperature" value="22.40" unit="°C" icon="thermo" />
	<CwCardDataRowItem id="humidity" label="Humidity" value="67.30" unit="%" icon="drop" />
	<CwCardDataRowItem id="updated" label="Last Update" icon="timer" lastSeenAt={new Date(Date.now() - 120_000)} expireAfterMinutes={10} />
</ul>
Bindable freshness state

Use this when a parent needs the timeout state without parsing timer text.

Bindable freshness state Copy code
<script lang="ts">
	let withinTimeout = $state<boolean | null>(null);
	let expired = $state(false);
</script>

<ul>
	<CwCardDataRowItem
		id="updated"
		label="Last Update"
		icon="timer"
		lastSeenAt={new Date(Date.now() - 120_000)}
		expireAfterMinutes={10}
		onExpire={() => (expired = true)}
		bind:withinTimeout
	/>
</ul>
Custom metadata row

Plain strings work when you need a one-off icon like an emoji or text token.

Custom metadata row Copy code
<ul>
	<CwCardDataRowItem id="relay-state" label="Relay State" value="On" icon="⚡" />
</ul>