Text4 checks

FormUrl

Web address. Adds https:// when it is missing.

Example
Installation
bunx --bun shadcn@latest add @fieldkit/form-url

Needs the @fieldkit registry. Add it once

Usage
  1. 1

    Add the field to your schema

    schema.ts
    import { z } from "zod"import { urlField } from "@/lib/field-schemas"
    export const schema = z.object({  website: urlField({ httpsOnly: true }),})
  2. 2

    Render it inside a Form

    The name prop matches the schema key.

    example-form.tsx
    import { Form } from "@/components/form/form"import { FormUrl } from "@/components/form/form-url"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={{ website: "" }}      onSubmit={save}    >      <FieldGroup>        <FormUrl name="website" />        <FormSubmit>Save</FormSubmit>      </FieldGroup>    </Form>  )}
Checks
Valid URLdefaultEnter a full web address, like https://example.com
Adds https://defaultNone
HTTPS onlyhttpsOnlyUse an https:// address
Allowed domainsdomainsUse a link from github.com
Best practices
  • Accept addresses without the protocol
Try these values
Terminal
urlField({ httpsOnly: true })
InputResultOutput
"https://kijani.co.ke"Valid"https://kijani.co.ke"
"http://kijani.co.ke"Invalid
Use an https:// address
"kijani.co.ke"Invalid
Enter a full web address, like https://example.com
""Invalid
Enter a full web address, like https://example.com
API reference

FormUrl

...input propsReact.ComponentProps<"input">Any input prop except type, value and handlers.

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