Each field kind's value as records show it: pills, people, stars, money, dates, files and links.
- Legal name
- Northwind Freight Ltd.
- ARR
- $184,000
- Renewal
- Mar 31
- Stage
- Customer
- Segments
- LogisticsEnterprise
- Owner
- MCMaya Chen
- Signed DPA
- ✓
- Website
- northwind.example
- Billing email
- [email protected]
- Phone
- +44 20 7946 0321
- Fit
- ★★★★★
- Contracts
- msa-2026.pdforder-form.pdf
- Contacts
- Priya RamanJonas Berg
- Open deals
- 3
- Health
- #ERROR
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { type Item, type Property, ValueView } from "./ui/uicontext/components/kit/Property.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"// A company record from a CRM base, one row per field kind. The same field and value read the// same in a grid cell, on a card and in a record's side panel.export const companyFields: ReadonlyArray<Property> = [ { key: "name", label: "Legal name", kind: "text" }, { key: "arr", label: "ARR", kind: "number", format: { style: "currency", currency: "USD", decimals: 0 } }, { key: "renewal", label: "Renewal", kind: "date" }, { key: "stage", label: "Stage", kind: "select", options: [ { value: "trial", label: "Trial", tone: "blue" }, { value: "customer", label: "Customer", tone: "green" }, ], }, { key: "segments", label: "Segments", kind: "multiSelect", options: [ { value: "logistics", label: "Logistics", tone: "orange" }, { value: "enterprise", label: "Enterprise", tone: "purple" }, ], }, { key: "owner", label: "Owner", kind: "person", options: [{ value: "maya", label: "Maya Chen", glyph: { _tag: "Person", id: "maya", name: "Maya Chen", agent: false } }], }, { key: "signed", label: "Signed DPA", kind: "checkbox" }, { key: "website", label: "Website", kind: "url" }, { key: "email", label: "Billing email", kind: "email" }, { key: "phone", label: "Phone", kind: "phone" }, { key: "fit", label: "Fit", kind: "rating", max: 5 }, { key: "files", label: "Contracts", kind: "attachment" }, { key: "contacts", label: "Contacts", kind: "relation", relation: { target: "Contacts", multiple: true }, options: [ { value: "ct1", label: "Priya Raman" }, { value: "ct2", label: "Jonas Berg" }, ], }, { key: "deals", label: "Open deals", kind: "rollup", result: "number", rollup: { relation: "deals", field: "status", aggregate: "count" }, }, { key: "health", label: "Health", kind: "formula", formula: 'prop("ARR") / prop("Seats")', error: "Unknown field Seats" },]export const northwind: Item = { id: "co-1", title: "Northwind Freight", values: { name: "Northwind Freight Ltd.", arr: 184000, renewal: "2027-03-31", stage: "customer", segments: ["logistics", "enterprise"], owner: "maya", signed: true, website: "https://northwind.example", email: "[email protected]", phone: "+44 20 7946 0321", fit: 4, files: ["https://files.example/northwind/msa-2026.pdf", "https://files.example/northwind/order-form.pdf"], contacts: ["ct1", "ct2"], deals: 3, health: null, },}const styles = stylex.create({ list: { display: "grid", gridTemplateColumns: "minmax(7rem, max-content) minmax(0, 1fr)", columnGap: space.xl, rowGap: space.md, margin: 0, fontSize: font.sm, }, label: { color: color.muted }, value: { margin: 0, minWidth: 0 },})export const EveryKind = <M>(h: Html.H<M>) => h.dl.attrs(sx(styles.list)).children( ...companyFields.flatMap((field) => [ h.dt.key(`l:${field.key}`).attrs(sx(styles.label)).children(field.label), h.dd .key(`v:${field.key}`) .attrs(sx(styles.value)) .children(ValueView(h, { property: field, value: northwind.values[field.key] ?? null, locale: "en-US" })), ]), )Installation
pnpm dlx shadcn@latest add checkfu/uicontext/propertyUsage
import { type Item, type Property, ValueView } from "./ui/uicontext/components/kit/Property.ts"export const FieldValue = <M>(h: Html.H<M>, field: Property, record: Item) => ValueView(h, { property: field, value: record.values[field.key] ?? null, locale: "en-US" })Examples
Empty values
Quiet in a row (a faint ring, a dash or nothing) and in words in a panel.
| Field | In a row | In a panel |
|---|---|---|
| Assignee | No assignee | |
| Priority | – | No priority |
| Estimate | No estimate | |
| Due | No due date | No due date |
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { type Property, ValueView } from "./ui/uicontext/components/kit/Property.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"// An empty value is quiet in a dense view and says what's missing in a side panel. `emptyAs` picks// the quiet form per field; `labelEmpty` asks for the words.const fields: ReadonlyArray<Property> = [ { key: "assignee", label: "Assignee", kind: "person", empty: "No assignee", options: [] }, { key: "priority", label: "Priority", kind: "select", empty: "No priority", emptyAs: "dash", options: [] }, { key: "estimate", label: "Estimate", kind: "number", empty: "No estimate" }, { key: "due", label: "Due", kind: "date", empty: "No due date", emptyAs: "label" },]const styles = stylex.create({ table: { borderCollapse: "collapse", fontSize: font.sm }, head: { paddingBlock: space.sm, paddingInline: space.md, color: color.muted, fontWeight: 500, textAlign: "start" }, cell: { paddingBlock: space.sm, paddingInline: space.md, borderTopWidth: 1, borderTopStyle: "solid", borderTopColor: color.line, },})export const EmptyValues = <M>(h: Html.H<M>) => h.table.attrs(sx(styles.table)).children( h.thead.children( h.tr.children( h.th.attrs({ scope: "col", ...sx(styles.head) }).children("Field"), h.th.attrs({ scope: "col", ...sx(styles.head) }).children("In a row"), h.th.attrs({ scope: "col", ...sx(styles.head) }).children("In a panel"), ), ), h.tbody.children( ...fields.map((field) => h.tr.key(field.key).children( h.th.attrs({ scope: "row", ...sx(styles.cell, styles.head) }).children(field.label), h.td.attrs(sx(styles.cell)).children(ValueView(h, { property: field, value: null })), h.td.attrs(sx(styles.cell)).children(ValueView(h, { property: field, value: null, labelEmpty: true })), ), ), ), )API reference
Options
| Name | Type | Description |
|---|---|---|
propertyrequired | Property | The field the value belongs to, which decides how it's drawn |
valuerequired | Value | The value to show; undefined shows it empty |
compact | boolean | For dense rows: a choice with a glyph shows only the glyph, and fewer attachments show |
locale | string | The locale numbers and dates are formatted in; the browser's by default |
labelEmpty | boolean | An empty value shows its words ("No assignee"), as a property panel does |
Accessibility
- Every value reads as words: a rating is an image named like "4 of 5", an empty value says what's missing ("No assignee"), and a broken formula reads its error.
- The marks beside a value say who filled it, whether it's still being filled and whether its inputs changed, as named images with the same words in a tooltip.