- Accordion
- Alert
- Alert Dialog
- Avatar
- Badge
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Circular Progress
- Collapsible
- Compare Slider
- Dialog
- Dropdown Menu
- Gauge
- Input
- Label
- Marquee
- Navigation Menu
- Number Field
- Pagination
- Popover
- Progress
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Tooltip
Demos
The bio clock with its default domains and severity scale.
"use client"
import { BioClock } from "@workspace/ui/predict/bio-clock"
export function BioClockDemo() {
return (
<div className="mx-auto flex flex-wrap items-center justify-center gap-3">
<BioClock />
</div>
)
}
Usage
Use the bio clock to sum up a person's results on one dial. It has three hands:
- Domain hand — The dashed hand on the outer arc. It points at the domain with the highest
value. - Severity hand — The solid hand on the inner arc, with a bubble showing the score as given, such as
1.1. - Age hand — The thick hand on the lower scale, from 0 to 100. The badge shows
yearsValueand the biological age, such as+4 Years (51).
Hover or focus a domain on the outer arc to see a tooltip with its full name and value.
Import it from @workspace/ui/predict/bio-clock.
Defaults
- Domains — Seven segments: IFR, VAF, MHF, BMF, PNF, CMF, and RFF, each with a full name for its tooltip. PNF has the highest value, so the domain hand points at it.
- Severity — A 0 to 5 scale in five steps, coloured
--status-normal,--status-mild,--status-moderate,--status-severe, and--status-extreme. The score is 1.1. - Age —
bioAgeis 60, and the badge shows+7 YEARS (60). Always passyearsValuewith real data, or the badge shows the placeholder.
Notes
- The clock is a fixed square, 450 pixels by default. Set
sizeto change it. On narrow screens, pick a size that fits or pass a number from your own layout. currentValuereplacesseverity.current, so you can keep one scale and change only the score.- The age hand stops at 0 and 100. The severity hand does not, so keep
currentValueinside the scale. - When two domains share the highest value, the hand points at the first.
- Colours are any CSS colour. Use the
--color-status-*variables to follow the theme. - The bubble and badge show numbers as you pass them. Round them first, such as
Math.round(age * 10) / 10. - Each domain can be reached with Tab, which opens its tooltip.
Examples
Custom values
Pass bioAge, yearsValue, and currentValue to show a person's own result.
"use client"
import { BioClock } from "@workspace/ui/predict/bio-clock"
export function BioClockCustom() {
return (
<div className="mx-auto flex flex-wrap items-center justify-center gap-3">
<BioClock bioAge={42} yearsValue="-3 Years" currentValue={0.6} />
</div>
)
}
Custom domains
Pass domains to set each segment's label, full name, colour, and value. HRT has the highest value, so the domain hand points at it.
"use client"
import { BioClock, type DomainSegment } from "@workspace/ui/predict/bio-clock"
const domains: DomainSegment[] = [
{ label: "HRT", fullName: "Heart health", color: "var(--color-status-normal)", value: 80 },
{ label: "MET", fullName: "Metabolic health", color: "var(--color-status-mild)", value: 60 },
{ label: "INF", fullName: "Inflammation", color: "var(--color-status-moderate)", value: 45 },
{ label: "HRM", fullName: "Hormones", color: "var(--color-status-normal)", value: 70 },
{ label: "KID", fullName: "Kidney function", color: "var(--color-status-severe)", value: 30 },
]
export function BioClockDomains() {
return (
<div className="mx-auto flex flex-wrap items-center justify-center gap-3">
<BioClock domains={domains} bioAge={51} yearsValue="+4 Years" currentValue={2.4} />
</div>
)
}
Custom severity scale
Pass severity to change the inner arc. This one runs from 0 to 10 in three steps, with a score of 6.5.
"use client"
import { BioClock, type SeverityScale } from "@workspace/ui/predict/bio-clock"
const severity: SeverityScale = {
ranges: [
{ min: 0, max: 4, color: "var(--color-status-normal)" },
{ min: 4, max: 7, color: "var(--color-status-mild)" },
{ min: 7, max: 10, color: "var(--color-status-extreme)" },
],
current: 6.5,
}
export function BioClockSeverity() {
return (
<div className="mx-auto flex flex-wrap items-center justify-center gap-3">
<BioClock severity={severity} bioAge={47} yearsValue="+2 Years" />
</div>
)
}
Sizes
size takes sm (320), default (450), lg (600), xl (720), or any number of pixels. This shows 240 and sm.
"use client"
import { BioClock } from "@workspace/ui/predict/bio-clock"
export function BioClockSizes() {
return (
<div className="mx-auto flex flex-wrap items-end justify-center gap-6">
<BioClock size={240} />
<BioClock size="sm" />
</div>
)
}
Props
Unlisted props pass through to the wrapping div, which also takes a ref.
BioClock
| Prop | Type | Default | Description |
|---|---|---|---|
bioAge | number | 60 | Biological age, placed on the 0 to 100 scale. |
yearsValue | string | +7 YEARS | The gap from real age, such as +4 Years. Shown in the badge. |
yearsDiff | string | — | Same as yearsValue. yearsValue wins when both are set. |
currentValue | number | 1.1 | The severity score. Replaces severity.current. |
severity | SeverityScale | 0 to 5, five steps | The scale on the inner arc. |
domains | DomainSegment[] | seven domains | The segments on the outer arc. |
segments | Segment[] | — | Older form of domains. A missing value becomes 10, 20, 30, and so on. Ignored when domains is set. |
size | "sm", "default", "lg", "xl", or number | default | Width and height in pixels. The named sizes are 320, 450, 600, and 720. |
className | string | — | Classes merged onto the wrapper. |
DomainSegment
| Field | Type | Description |
|---|---|---|
label | string | Short name shown outside the arc, such as HRT. |
fullName | string | Full name shown in the tooltip, such as Heart health. |
color | string | Segment colour. |
value | number | Shown in the tooltip. The domain hand points at the highest. |
Segment has label, color, and an optional value. Its tooltip shows the label as the name.
SeverityScale
| Field | Type | Description |
|---|---|---|
ranges | SeverityRange[] | Steps from low to high. The arc runs from the first min to the last max. |
current | number | The score. Overridden by currentValue. |
SeverityRange
| Field | Type | Description |
|---|---|---|
min | number | Start of the step. |
max | number | End of the step. |
color | string | Colour at the middle of the step. The arc blends between steps. |
ClockGaugeProps is the type of the props.