Skip to content

Age ​

Someone's age, "13", with their date of birth and any birthday this week in a tooltip.

Open in Storybook to try every prop.

When to use ​

  • Showing a person's age, e.g. in a student list or record. The tooltip saves looking up their date of birth.

When not to use ​

  • When the date of birth itself matters more than the age: show the date with formatDate.
  • How long ago something happened: use RelativeTime.

Anatomy ​

PartRequiredNotes
numberYesThe age, in the surrounding text style, with an optional suffix ("13 years").
tooltipYes"Born 14 March 2013", plus "Birthday today" or "Birthday in 3 days" within a week.

Properties ​

PropertyTypeDefaultDescription
birthDateDate | string | number—Date of birth: a Date, an ISO string ("2013-03-14") or a timestamp.
suffixstring—Text after the number, e.g. "years". Leave out in an "Age" column.
nowDatetodayWhat "today" is, e.g. for tests.

Behaviour ​

  • The age goes up on the birthday itself; people born on 29 February turn a year older on 1 March in other years.
  • The tooltip shows on hover and on keyboard focus.

Accessibility ​

  • Focusable, so keyboard users can reach the tooltip.

Platform adaptation ​

PlatformImplementationDifferences
Web / desktop (Vue)Age.vueage() and daysToBirthday() in src/lib/dates.ts.
iOS (SwiftUI)—Calendar.dateComponents([.year], …); date of birth in a context menu.
Android (Compose)—Period.between(…).years.

Tokens used ​

None of its own: it uses the surrounding text style, and Tooltip's.

Released under the PolyForm Noncommercial License 1.0.0.