Components

FormFieldSet

A unified form field component that renders any of 17 field types (text, select, datepicker, etc.) with built-in labels, validation, and error handling. Use inside a <Form> for context-driven validation.

import{ FormFieldSet }from"oks-ui"
17 field typesBuilt-in validationError statesForm context integrationFloating labelsStart/end content

Complete Form

Build a working form with <Form> wrapping multiple <FormFieldSet> components. The Form component provides validation context and collects all field values on submit.

Validation & Error States

Each field supports validation rules with custom error messages. Errors display below the field when touched. The Form component manages state across all fields.

Field Types Gallery

FormFieldSet renders any of 17 field types via the <code>type</code> prop. Below is every supported type in action.

Radio
Checkbox
0

Interactive Playground

Controls

Preview

Generated Code

<FormFieldSet />

Props

type"text"

FormFieldType

The field type to render. One of: text, number, url, search, color, password, email, textarea, select, radio, checkbox, switch, datepicker, phone, range, otp, file.

name

string

Field name — used as the key in form data and for validation context.

label

ReactNode

Label text or element displayed above or floating over the input.

description

ReactNode

Helper text displayed below the field.

size"md"

"xs" | "xs-sm" | "sm" | "md" | "lg" | "xl"

Control size.

variant"default"

"default" | "soft" | "underline"

Visual style variant.

color"default"

"default" | "primary" | "info" | "success" | "warning" | "danger" | "secondary"

Color accent for the field.

colorDepth500

number

Color intensity (50–950).

labelPlacement"top"

"top" | "floating"

Where the label renders. Switch also supports 'left' and 'right'.

validation

FieldValidation

Validation rules and error messages. e.g. { rules: { required: true, email: true }, message: { email: 'Invalid email' } }.

error

ReactNode

Error message to display. When set, field is visually errored.

touchedfalse

boolean

Whether the field has been interacted with. Shows error only when touched + error is set.

disabledfalse

boolean

Disable the input element.

id

string

HTML id attribute. Auto-generated if omitted.

placeholder

string

Placeholder text (text-like types only).

requiredfalse

boolean

HTML required attribute (use validation.rules.required for validation).

options

SelectOption[]

Array of { label, value } options for select, radio, and checkbox types.

nativefalse

boolean

Use native <select> instead of custom dropdown (select only).

strongPassword

object

Strong password config: { minLength, minUpper, minLower, minNumber, minSpecial }.

revealToggletrue

boolean

Show/hide password visibility toggle button.

rows3

number

Number of visible text rows (textarea only).

showLengthCounterfalse

boolean

Show character count below the textarea.

rangefalse

boolean

Enable range selection (start/end dates).

withTimefalse

boolean

Include time picker in the date selection.

showPresetstrue

boolean

Show preset date ranges (Today, This Week, etc.).

displayFormat"pretty"

"pretty" | "iso"

Date display format.

clearabletrue

boolean

Show a clear button to reset the date.

minDate

Date | string

Minimum selectable date.

maxDate

Date | string

Maximum selectable date.

blockedDates

Array<Date | string>

Dates that cannot be selected.

monthsToShow1

1 | 2

Number of calendar months to display.

length4

number

Number of OTP digit inputs.

format"digits"

"digits" | "alphanumeric"

Allowed character format.

ui"segmented"

"segmented" | "single"

OTP UI style — separate boxes or single input.

accept

string

Accepted file MIME types, e.g. 'image/*'.

multiplefalse

boolean

Allow multiple file selection.

maxFiles

number

Maximum number of files.

maxFileSize

number

Maximum file size in bytes.

ui"inline"

"inline" | "dropzone"

File field UI variant.

preview"thumbnails"

"none" | "thumbnails"

File preview mode.

dropLabel"Drag & drop files here"

string

Text shown in dropzone area.

browseLabel"Browse files"

string

Button label for file browser.

defaultCountryCode"us"

string

Default country code (ISO 3166-1 alpha-2).

countryCodeMode"select"

"select" | "hidden"

Show country code selector or auto-detect.

numbersOnlyfalse

boolean

Only allow numeric characters.

phonePlaceholder

string

Placeholder for the phone number input.

min0

number

Minimum value.

max100

number

Maximum value.

step1

number

Step increment.

showValuetrue

boolean

Display the current value as a label.

marks

number[]

Array of tick mark values along the slider.

selection"single"

"single" | "range"

Single value or range selection.

checked

boolean

Controlled checked state.

defaultCheckedfalse

boolean

Default checked state (uncontrolled).

showStateTextfalse

boolean

Show on/off text labels next to the switch.

checkedText"On"

ReactNode

Text shown when switch is on.

uncheckedText"Off"

ReactNode

Text shown when switch is off.

stateTextPlacement"after"

"before" | "after" | "both"

Where state labels render relative to the switch.

labelPlacement"top"

"top" | "left" | "right" | "floating"

Label position (switch supports left/right in addition to top/floating).

radius"md"

"none" | "xs" | "xs-sm" | "sm" | "md" | "lg" | "full"

Border radius of the input.

rounded

"none" | "xs" | "xs-sm" | "sm" | "md" | "lg" | "full"

Alternative radius alias.

startIcon

ReactNode

Icon/element at the start of the input.

endIcon

ReactNode

Icon/element at the end of the input.

prefix

ReactNode

Text prefix inside the input before the value.

suffix

ReactNode

Text suffix inside the input after the value.

min

number

Minimum allowed value.

max

number

Maximum allowed value.

step1

number

Step increment for the control.