Skip to content
Page

Time Input

Time field with hour and minute segments.

Selected: 09:30
import { TimeInput } from "@pelagornis/page/components";

The preview above renders this file. Copy it into src/components/ to start from it.

src/components/TimeInputExample.tsx
import { useState } from "react";
import { Stack, Text, TimeInput } from "@pelagornis/page/components";
export default function TimeInputDemo() {
const [value, setValue] = useState("09:30");
return (
<Stack gap="sizeSmall" className="w-full">
<TimeInput value={value} onValueChange={setValue} hourCycle="12h" fullWidth />
<Text variant="captionMd" className="m-0 text-refineui-alias-foreground-secondary">
Selected: {value}
</Text>
</Stack>
);
}

Time Input is composed from parts that share React state. Children written in MDX are rendered as separate islands, so the parts can’t reach each other. Put the composition in a .tsx file, like the example above, and import that file instead.

src/content/docs/example.mdx
---
title: Example
---
import TimeInputExample from "../../components/TimeInputExample";
<TimeInputExample client:load />

client:load hydrates the island on page load. Use client:visible for content far down the page.

Markdoc tags render Astro components, and this one needs client state. Wrap the example in an .astro file that hydrates it, then register that file as a tag.

src/components/markdoc/TimeInputExample.astro
---
import TimeInputExample from "../TimeInputExample";
---
<TimeInputExample client:load />
markdoc.config.mjs
import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";
import starlightMarkdoc from "@astrojs/starlight-markdoc";
import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({
extends: [starlightMarkdoc(), pageMarkdoc()],
tags: {
"time-input-example": {
render: component("./src/components/markdoc/TimeInputExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% time-input-example /%}

Values the component accepts for each variant prop.

Parts of the component and the data-refineui role each one renders.

PartRole
roottime-input

States the component styles. Component states are exposed as data attributes.

KindStates
Pseudofocus-visible
Availabilitydisabled
selectionplaceholder value
validationerror success

Keys the component handles when it has focus.

KeyAction
Enteractivate
Spaceactivate