New Ory Agent Security is now live! Claim your complimentary test drive. Get Started!

Skip to main content

Order and render form fields

Ory Elements renders the fields that Ory Kratos Identities returns in a flow. Pass nodeSorter to change the order of these fields without rewriting the flow. It works on OryProvider and on the Login, Registration, and Settings components.

Order fields​

By default, Ory Elements orders fields with defaultNodeSorter. Pass nodeSorter to change the order. The function compares two nodes, like the callback of Array.prototype.sort. Call defaultNodeSorter for every pair that your rule doesn't cover.

registration.tsx
import { UiNode } from "@ory/client-fetch"
import { defaultNodeSorter } from "@ory/elements-react"
import { Registration } from "@ory/elements-react/theme"

const rank = (node: UiNode) => (node.attributes.node_type === "input" && node.attributes.name === "traits.phone" ? 0 : 1)

export function RegistrationPage({ flow, config }) {
return <Registration flow={flow} config={config} nodeSorter={(a, b) => rank(a) - rank(b) || defaultNodeSorter(a, b)} />
}

This example moves traits.phone before the other fields.

Date and time fields​

When an identity schema sets format: date-time on a trait, Ory Kratos Identities returns an input that Ory Elements renders as a native datetime-local input. The browser shows a date and time picker.

Ory Elements converts the value for you. The browser works with local values such as 2026-11-16T09:30, and Ory Kratos Identities expects RFC 3339 values such as 2026-11-16T09:30:00Z. Ory Elements converts the value in both directions.

To change how the input looks, override Node.Input. Spread inputProps onto your element to keep the conversion.

registration.tsx
import { OryNodeInputProps } from "@ory/elements-react"
import { getOryComponents, Registration } from "@ory/elements-react/theme"

const DefaultInput = getOryComponents().Node.Input

function Input(props: OryNodeInputProps) {
if (props.node.attributes.type !== "datetime-local") {
return <DefaultInput {...props} />
}
return <input {...props.inputProps} className="my-date-input" />
}

export function RegistrationPage({ flow, config }) {
return <Registration flow={flow} config={config} components={{ Node: { Input } }} />
}

A picker component that doesn't render an <input> element uses inputProps.value and inputProps.onChange. inputProps.value is the local value, such as 2026-11-16T09:30. Call inputProps.onChange with a local value in the same format, and Ory Elements stores the RFC 3339 value. The passkey and WebAuthn scripts submit the HTML form directly and read the values from the page, so also render a hidden input with name, ref, and disabled from inputProps. Pass id to the picker, so the field label points to it.

registration.tsx
import { OryNodeInputProps } from "@ory/elements-react"
import { getOryComponents } from "@ory/elements-react/theme"
import { MyDateTimePicker } from "./my-date-time-picker"

const DefaultInput = getOryComponents().Node.Input

function Input(props: OryNodeInputProps) {
if (props.node.attributes.type !== "datetime-local") {
return <DefaultInput {...props} />
}
const { id, name, ref, value, onChange, disabled } = props.inputProps
return (
<>
<input type="hidden" name={name} ref={ref} value={value} disabled={disabled} />
<MyDateTimePicker id={id} value={value} onChange={onChange} disabled={disabled} />
</>
)
}

Pass Input to components as in the previous example.