# Device Tile

> A smart-home device (from Google Home, Apple Home, SmartThings, tado°, Dyson, eufy, Dreame …): its reading, its state and the controls its kind needs.

Component · Connectors · Pro kit · [Live page](https://ui.twentyfirst.media/pro/components/DeviceTile/)

A smart-home device (from Google Home, Apple Home, SmartThings, tado°, Dyson, eufy, Dreame …):
its reading, its state and the controls its kind needs.

- `kind`: `switch`, `light`, `thermostat`, `vacuum`, `purifier`, `camera`, `lock` or `sensor` sets the icon.
- `onToggle` adds a switch; `target` with `onTarget` adds a − / + stepper for thermostats.
- `battery` (low below 15 %), quick `actions`, `offline`, and the `service` it comes from.

## Example

```tsx
import * as React from "react";
import { DeviceTile } from "@twentyfirstmedia/pro";
import "./_connectors";

export default function Preview() {
  const [target, setTarget] = React.useState(21.5);
  const [light, setLight] = React.useState(true);
  return (
    <div
      className="tf-grid"
      style={
        {
          "--cols": "repeat(3, minmax(0, 1fr))",
          "--cols-sm": "1fr",
          gap: 16,
        } as React.CSSProperties
      }
    >
      <DeviceTile
        kind="thermostat"
        name="Living room"
        room="Heating"
        on
        value="20.8 °C"
        status={`Heating · humidity 46 %`}
        target={target}
        onTarget={setTarget}
        service={{ name: "tado°", icon: "brandTado" }}
      />
      <DeviceTile
        kind="light"
        name="Ceiling light"
        room="Kitchen"
        on={light}
        onToggle={setLight}
        value={light ? "80 %" : undefined}
        status={light ? "Warm white" : undefined}
        service={{ name: "Google Home", icon: "brandGooglehome" }}
      />
      <DeviceTile
        kind="vacuum"
        name="Robot vacuum"
        room="Ground floor"
        on
        value="Cleaning"
        status="Hallway · 18 m² to go"
        battery={64}
        actions={[
          { label: "Pause", icon: "pause" },
          { label: "Dock", icon: "home" },
        ]}
      />
      <DeviceTile
        kind="purifier"
        name="Air purifier"
        room="Bedroom"
        on
        value="AQI 12"
        status="Good · night mode"
        onToggle={() => {}}
      />
      <DeviceTile kind="camera" name="Front door" room="Outside" offline />
      <DeviceTile
        kind="sensor"
        name="Window sensor"
        room="Office"
        on={false}
        value="Closed"
        battery={12}
      />
    </div>
  );
}
```

## Props

### DeviceTile

| Prop | Type | Notes |
| --- | --- | --- |
| `name` | `string` | Required |
| `room?` | `string` |  |
| `icon?` | `IconName` |  |
| `kind?` | `"switch" \| "light" \| "thermostat" \| "vacuum" \| "purifier" \| "camera" \| "lock" \| "sensor"` | The kind sets the default icon and which controls appear. |
| `on?` | `boolean` | On or off; with `onToggle` a switch. |
| `onToggle?` | `(on: boolean) => void` |  |
| `value?` | `ReactNode` | The main reading: "21.5 °C", "Cleaning", "AQI 12". |
| `status?` | `ReactNode` | A line under the value: "Heating to 22 °C", "Kitchen · 18 m² left". |
| `target?` | `number` | Thermostat target in °C; with `onTarget` a − / + stepper (steps of `step`, default 0.5). |
| `onTarget?` | `(value: number) => void` |  |
| `step?` | `number` |  |
| `battery?` | `number` | Battery in percent (vacuums, sensors, locks). |
| `actions?` | `{ label: string; icon?: IconName; onClick?: () => void }[]` | Quick actions: "Start", "Dock", "Boost". |
| `offline?` | `boolean` | The device does not answer. |
| `service?` | `ServiceRef` |  |
| `className?` | `string` | Extra class on the root element. |
| `style?` | `CSSProperties` | Inline style on the root element. |
