Value — dir/ui
Numbers, dates and choices formatted the same way in every grid, list and detail.
# Value
Numbers, dates and choices formatted the same way in every grid, list and detail.
Live preview of every variant and state: https://ui.usedir.com/components/value
## Install
```sh
npx shadcn@4.21.0 add lr-run/dir-ui/value#v0.4.0
```
[Registry item with source and dependencies](https://github.com/lr-run/dir-ui/blob/v0.4.0/registry.json)
Requires React 19, Tailwind CSS 4 and shadcn initialized with Base UI: npx shadcn@4.21.0 init --base base --preset base-nova (in Vite, set up the @/* path alias in tsconfig.json and vite.config.ts first). Registry target placeholders resolve through components.json: @ui, @components, @hooks and @lib. Imports below use the conventional @/ prefix for illustration; the CLI rewrites them to your configured aliases. Shared components are installed once through registryDependencies. The installer merges shared theme rules into the stylesheet configured in components.json. Existing files are never forcibly overwritten; review CLI conflicts before accepting changes. No Dir runtime is required.
## NumberValue, formatNumber
```tsx
import { NumberValue, formatNumber } from '@/components/ui/value.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| value | number \| null \| undefined | Required | |
| format | "number" \| "currency" \| "percent" | number | |
| currency | string | USD | |
| locale | string | en-US | |
| maximumFractionDigits | number | 2 | |
Percent values use percentage points: 60 renders as 60%. Null, undefined, and non-finite values render an em dash.
## DateValue, formatDate
```tsx
import { DateValue, formatDate } from '@/components/ui/value.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| value | string \| null \| undefined | Required | YYYY-MM-DD or an ISO timestamp. |
| locale | string | en-US | |
| timeZone | string | UTC | |
| includeTime | boolean | false | |
Date-only values preserve the calendar date. Use an explicit timestamp offset for timezone conversion.
## ChoiceValue
```tsx
import { ChoiceValue } from '@/components/ui/value.tsx'
```
| Prop | Type | Default / required | Notes |
| --- | --- | --- | --- |
| items | readonly Choice[] | Required | |
| empty | ReactNode | — | |
| onSelect | (item: Choice) => void | — | When supplied, each label becomes a button. |
```ts
type Choice = { value: string; label: string; description?: string; color?: string; avatar?: string; disabled?: boolean; keywords?: string[] }
type LoadChoices = (query: string, context: { signal: AbortSignal; cursor?: string }) => Promise<{ items: Choice[]; cursor?: string }>
```