<cs-known-date>
ExperimentalFormsSince 0.1

Known dates let users enter dates they already know - birthdays, expirations, document dates - through three separate day, month, and year fields shown in the locale's natural order.

Known Date collects a date the user already knows — a birthday, a passport issue date, an expiration — through three separate fields for day, month, and year. It follows the UK Government Design System date input pattern: a labeled <fieldset> wraps three plain <input> elements, the user types each part themselves, and the host submits a single canonical ISO date.

Need a calendar, ranges, or browsing?
Known Date is intentionally simple: no popup calendar, no auto-advance between fields, and no clever parsing. For anything richer, pair a native <input type="date"> with the field or reach for a dedicated date picker.

Form Submission

The hidden form value is canonical ISO 8601 (YYYY-MM-DD), regardless of the locale used to render the fields:

EntryForm value
Complete, valid dateYYYY-MM-DD (e.g. 2007-03-27)
Partial (one or two fields)(empty) — omitted from form data
Invalid date (e.g. 30 February)(empty)

Submit




Examples

Initial Value

Set the value attribute to an ISO date to pre-fill the three fields.

Hint

Use the hint attribute (or slot) to show an example value. The hint is associated with each field via aria-describedby, so screen readers announce it when any field receives focus.

Locale-Aware Field Order

The three fields render in the natural order for the inherited lang (or the explicit locale attribute). The labels stay the same; only the position changes.

Min & Max

Constrain the accepted range with min and max. Values outside the range are reported as invalid.

Required

Set required to make the date input required for form submission. Like other form controls, validation surfaces through the browser’s native constraint validation flow: submitting a form with an empty or partially filled date input prevents submission and shows the browser’s validation message. No error appears while the user is simply filling in or tabbing between the fields.


Submit

Disabled

Use the disabled attribute to disable a date field.

Readonly

Use the readonly attribute to keep a value visible but uneditable. Unlike disabled, a readonly date field stays focusable and its value is still submitted with the form.

Autocomplete

Set autocomplete="bday" to enable browser autofill for birthdays. The host expands the family into per-field tokens (bday-day, bday-month, bday-year).

Size

Appearance

Pill

Use the pill attribute to give each field rounded edges.

API

Importing

If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick this component, use one of the following snippets.

npm Self-Hosted React
import '@cruglobal/cornerstone-components/components/known-date/known-date.js';
import './cornerstone/components/known-date/known-date.js';
import CsKnownDate from '@cruglobal/cornerstone-components/react/known-date/index.js';

Slots

Learn more about using slots.

NameDescription
hintText that describes how to use the known date. Alternatively, use the hint attribute.
labelThe known date's group label. Alternatively, use the label attribute.

Attributes & Properties

Learn more about attributes and properties.

PropertyAttributeDescriptionTypeDefaultReflects
appearanceappearanceThe known date's visual appearance.CsKnownDateAppearance'outlined'Yes
autocompleteautocompleteBrowser autofill family. When set to bday, the three fields receive bday-day, bday-month, and bday-year respectively. The field-agnostic directives off and on are applied to all three fields. Any other value is forwarded only to the year field.string''
defaultValuevalueThe default value used for form reset.stringYes
disableddisabledDisables the known date.booleanfalse
formBy default, form controls are associated with the nearest containing <form> element. This attribute allows you to place the form control outside of a form and associate it with the form that has this id. The form must be in the same document or shadow root for this to work.HTMLFormElement | null
hinthintThe known date's hint. If you need to display HTML, use the hint slot instead.string''
labellabelThe known date's label. If you need to display HTML, use the label slot instead.string''
localelocaleBCP-47 locale override. When empty, the inherited lang attribute is used.string''Yes
maxmaxLatest selectable date as YYYY-MM-DD.string''Yes
minminEarliest selectable date as YYYY-MM-DD.string''Yes
namenameThe name submitted with form data.string | null''Yes
partsThe three field strings. Stored verbatim so user-typed digits round-trip faithfully.DateParts{ ...EMPTY_PARTS }
pillpillDraws pill-style fields with rounded edges.booleanfalseYes
readonlyreadonlyMakes the fields non-editable.booleanfalseYes
requiredrequiredMakes the known date required for form submission.booleanfalseYes
sizesizeThe known date's size.CsKnownDateSize'm'Yes
ssrHintssr-hintOnly required for SSR. Set to true if you're slotting in a hint element.booleanfalse
ssrLabelssr-labelOnly required for SSR. Set to true if you're slotting in a label element.booleanfalse
validationTargetAnchor native validation popups on a real visible input. The hidden mirror handles form data, but anchoring a popup on display: none content would render it at offset (0, 0).undefined | HTMLElement
validatorsValidators are static because they have observedAttributes, essentially attributes to "watch" for changes. Whenever these attributes change, we want to be notified and update the validator.Validator[][]
valueThe committed value as an ISO YYYY-MM-DD string. The setter also accepts a Date or null. Reading returns an empty string when the value is blank or any field is only partially filled.string
valueAsDateThe committed value as a Date, or null when the value is empty/invalid.Date | null
valueInputHidden mirror used for native constraint validation (min/max/required + valid-date roundtrip).HTMLInputElement

Methods

Learn more about methods.

NameDescriptionArguments
blur()Removes focus from the known date.
focus()Focuses the first empty field, or the first field when all are filled.options: FocusOptions
formStateRestoreCallback()Called when the browser is trying to restore element’s state to state in which case reason is "restore", or when the browser is trying to fulfill autofill on behalf of user in which case reason is "autocomplete". In the case of "restore", state is a string, File, or FormData object previously set as the second argument to setFormValue.state: string | File | FormData | null
resetValidity()Reset validity is a way of removing manual custom errors and native validation.
setCustomValidity()Do not use this when creating a "Validator". This is intended for end users of components. We track manually defined custom errors so we don't clear them on accident in our validators.message: string

Events

Learn more about events.

NameDescription
blurEmitted when the control loses focus.
changeEmitted when the committed value transitions to a new ISO date.
cs-invalidEmitted when the form control has been checked for validity and its constraints aren't satisfied.
focusEmitted when the control gains focus.
inputEmitted as the user types in any field.

Custom States

Learn more about custom states.

NameDescriptionCSS selector
blankThe known date has no committed value.:state(blank)
disabledThe known date is disabled.:state(disabled)

CSS Parts

Learn more about CSS parts.

NameDescriptionCSS selector
fieldEach field block (label + input).::part(field)
field-dayAdded to the day field block.::part(field-day)
field-inputThe native <input> inside a field.::part(field-input)
field-labelThe text label above each field's input.::part(field-label)
field-monthAdded to the month field block.::part(field-month)
field-yearAdded to the year field block.::part(field-year)
fieldsThe flex row holding the three field blocks.::part(fields)
fieldsetThe <fieldset> element grouping the three fields (or a role="group" div).::part(fieldset)
form-controlThe form control's outer wrapper.::part(form-control)
form-control-inputAlias on the fields row matching other form controls.::part(form-control-input)
form-control-labelThe wrapper inside the legend that styles the visible label text.::part(form-control-label)
hintThe hint's wrapper.::part(hint)
known-dateThe component's outer wrapper.::part(known-date)
legendThe <legend> element (when a label is present).::part(legend)