Integrations / Solid
Solid
@litopis/solid provides the LitopisDatePicker component.
Quick start
npm install @litopis/solid @litopis/dom solid-js
Add this component to src/App.tsx. It imports the picker and its base
stylesheet.
import { LitopisDatePicker } from "@litopis/solid";
import "@litopis/dom/styles/base.css";
export default function App() {
return (
<main>
<LitopisDatePicker mode="popover" label="Appointment date" />
</main>
);
}
Interactive example
Value: current date
Value
Store the selected date in a signal to keep it in sync with your app.
import { createSignal } from "solid-js";
import { LitopisDatePicker, type LitopisDateValue } from "@litopis/solid";
import "@litopis/dom/styles/base.css";
function App() {
const [date, setDate] = createSignal<LitopisDateValue | null>(null);
return (
<LitopisDatePicker
mode="popover"
label="Start date"
value={date()}
onValueChange={setDate}
/>
);
}
Controller callback
controllerRef receives the mounted DatePickerController and
null during cleanup.
import { createSignal } from "solid-js";
import type { DatePickerController } from "@litopis/dom";
const [controller, setController] = createSignal<DatePickerController | null>(null);
<LitopisDatePicker controllerRef={setController} />
<button onClick={() => controller()?.open()}>Open calendar</button>
Range
Use selection="range" on the same component. Endpoint names remain native
form fields.
const [stay, setStay] = createSignal({ start: null, end: null });
<LitopisDatePicker
selection="range"
name={{ start: "from", end: "to" }}
range={stay()}
onRangeChange={setStay}
/>
Custom input
Pass an input child with slot="input". Litopis keeps its classes and
placeholder while supplying the picker behavior and accessibility attributes.
<LitopisDatePicker value={date()} onValueChange={setDate}>
<input slot="input" class="my-input" placeholder="Choose a date" />
</LitopisDatePicker>
Styling
Pass class to the component root. Import one Litopis stylesheet in your
application entry.