Widgets
A widget is the small, glanceable face of your app on someone’s home screen. There are three sizes and they are fixed, because every app’s widgets share one grid and a widget that sets its own height breaks the alignment of everything beside it.
The three sizes
| Size | Pixels | Grid | What belongs in it |
|---|---|---|---|
| Small | 170 × 170 | 1 × 1 | One number or one status. The thing you check most. |
| Medium | 360 × 170 | 2 × 1 | A short list, a few days of a forecast, or three stats side by side. |
| Large | 360 × 360 | 2 × 2 | A chart, a longer list, or several rows of detail. |
The column pitch is 170 with a 20px gap, which is where the other numbers come from: 170 + 20 + 170 = 360. Large is square at 360, not 376, so that two stacked mediums line up with one large exactly.
Use the toolkit
It handles the sizes, the spacing and the tap targets, and it is what the gates check against.
npm install @clarittyai/widget-toolkitLayout
WidgetContainer, locks the widget to its size and clips overflow.WidgetHeader, the title row.WidgetList,WidgetMetric,WidgetStat, the three things a widget usually is.
Controls and marks
WidgetButton, meets the 44px minimum tap target on its own.WidgetToggle,WidgetBadge,WidgetAvatar,WidgetAvatarGroup.widgetText, text styles that never fall below the 12px minimum.
import { WidgetContainer, WidgetHeader, WidgetMetric } from '@clarittyai/widget-toolkit';
export default function Widget({ data }) {
return (
<WidgetContainer size="small">
<WidgetHeader title="Overdue" />
<WidgetMetric value={data.count} label="invoices" />
</WidgetContainer>
);
}Where the data comes from
The dashboard polls GET /api/widget about every 30 seconds and hands the result to your component. Keep the endpoint’s shape and the component in step. A widget that renders empty on the dashboard is nearly always this contract drifting.
The rules the gates enforce
| Rule | Why |
|---|---|
| One of the three sizes, exactly | Everything on the grid has to line up. |
| Tap targets at least 44 × 44 | Smaller than that is not reliably hittable with a thumb. |
| Text at least 12px | Below that it is decoration, not information. |
| One glance, one action | A widget is not a small dashboard. If it needs a second look, it belongs on the dashboard. |