Number and date2 checks

FormSlider

A value, or two, inside a range.

Example
25 people
Installation
bunx --bun shadcn@latest add @fieldkit/form-slider

Needs the @fieldkit registry. Add it once

Usage
  1. 1

    Add the field to your schema

    schema.ts
    import { z } from "zod"import { numberField } from "@/lib/field-schemas"
    export const schema = z.object({  teamSize: numberField({ min: 1, max: 100 }),})
  2. 2

    Render it inside a Form

    The name prop matches the schema key.

    example-form.tsx
    import { Form } from "@/components/form/form"import { FormSlider } from "@/components/form/form-slider"import { FormSubmit } from "@/components/form/form-submit"import { FieldGroup } from "@/components/ui/field"import { schema } from "./schema"
    export function ExampleForm() {  return (    <Form      schema={schema}      defaultValues={{ teamSize: 25 }}      onSubmit={save}    >      <FieldGroup>        <FormSlider name="teamSize" />        <FormSubmit>Save</FormSubmit>      </FieldGroup>    </Form>  )}
Checks
Rangemin, maxNone
StepstepNone
Best practices
  • Show the value next to the control
  • Pair with FormNumber for exact values
Try these values
Terminal
numberField({ min: 1, max: 100 })
InputResultOutput
25Valid25
0Invalid
Enter a number of at least 1
101Invalid
Enter a number of at most 100
API reference

FormSlider

min, max, stepnumberDefault to the schema rules, then 0 to 100.
formatValue(value: number) => stringText shown beside the slider.

Field frame

namestringKey in the schema. Also picks the preset label and autocomplete.
labelReact.ReactNodeOverrides the preset label. Pass null to hide it.
descriptionReact.ReactNodeHint under the control.
requiredbooleanOverrides the asterisk read from the schema.
fieldPropsFormFieldPropsProps for the wrapping Field, such as className.

Search docs

Find a component, input or example