"use client"
import { useState } from "react"
import { REGEXP_ONLY_DIGITS } from "input-otp"
import {
Example,
ExampleWrapper,
} from "@/registry/bases/base/components/example"
import { Badge } from "@/registry/bases/base/ui/badge"
import { Checkbox } from "@/registry/bases/base/ui/checkbox"
import {
Field,
FieldContent,
FieldDescription,
FieldGroup,
FieldLabel,
FieldLegend,
FieldSet,
FieldTitle,
} from "@/registry/bases/base/ui/field"
import { Input } from "@/registry/bases/base/ui/input"
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/registry/bases/base/ui/input-otp"
import {
NativeSelect,
NativeSelectOptGroup,
NativeSelectOption,
} from "@/registry/bases/base/ui/native-select"
import {
RadioGroup,
RadioGroupItem,
} from "@/registry/bases/base/ui/radio-group"
import {
Select,
SelectContent,
SelectGroup,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/registry/bases/base/ui/select"
import { Slider } from "@/registry/bases/base/ui/slider"
import { Switch } from "@/registry/bases/base/ui/switch"
import { Textarea } from "@/registry/bases/base/ui/textarea"
export default function FieldExample() {
return (
)
}
function InputFields() {
return (
Basic Input
Input with Description
Choose a unique username for your account.
Email Address
We'll never share your email with anyone.
Required Field *This field must be filled out.Disabled InputThis field is currently disabled.
Input with Badge{" "}
Recommended
Invalid Input
This field contains validation errors.
Disabled FieldThis field is currently disabled.
)
}
function TextareaFields() {
return (
Basic TextareaCommentsMaximum 500 characters allowed.Bio
Tell us about yourself in a few sentences.
Message
Enter your message so it is long enough to test the layout.
Invalid Textarea
This field contains validation errors.
Disabled Field
This field is currently disabled.
)
}
function SelectFields() {
const basicItems = [
{ label: "Choose an option", value: null },
{ label: "Option 1", value: "option1" },
{ label: "Option 2", value: "option2" },
{ label: "Option 3", value: "option3" },
]
const countryItems = [
{ label: "Select your country", value: null },
{ label: "United States", value: "us" },
{ label: "United Kingdom", value: "uk" },
{ label: "Canada", value: "ca" },
]
const timezoneItems = [
{ label: "Select timezone", value: null },
{ label: "UTC", value: "utc" },
{ label: "Eastern Time", value: "est" },
{ label: "Pacific Time", value: "pst" },
]
const invalidItems = [
{ label: "This field has an error", value: null },
{ label: "Option 1", value: "option1" },
{ label: "Option 2", value: "option2" },
{ label: "Option 3", value: "option3" },
]
const disabledItems = [
{ label: "Cannot select", value: null },
{ label: "Option 1", value: "option1" },
{ label: "Option 2", value: "option2" },
{ label: "Option 3", value: "option3" },
]
return (
Basic SelectCountry
Select the country where you currently reside.
Timezone
Choose your local timezone for accurate scheduling.
Invalid Select
This field contains validation errors.
Disabled Field
This field is currently disabled.
)
}
function NativeSelectFields() {
return (
Basic Native Select
Choose an optionOption 1Option 2Option 3Country
Select your country
United StatesUnited KingdomCanada
Select the country where you currently reside.
Timezone
Choose your local timezone for accurate scheduling.
Select timezoneUTCEastern TimePacific Time
Grouped Options
Select a regionUnited StatesCanadaMexicoUnited KingdomFranceGermany
Native select with grouped options using optgroup.
Invalid Native Select
This field has an error
Option 1Option 2Option 3
This field contains validation errors.
Disabled Field
Cannot selectOption 1Option 2Option 3This field is currently disabled.
)
}
function CheckboxFields() {
return (
I agree to the terms and conditions
Accept terms and conditions
Subscribe to newsletter
Receive weekly updates about new features and promotions.
Enable Touch ID
Enable Touch ID to quickly unlock your device.
Invalid checkbox
Disabled checkbox
)
}
function RadioFields() {
return (
Enable Touch ID
Enable Touch ID to quickly unlock your device.
Enable Touch ID
Enable Touch ID to quickly unlock your device.
)
}
function SwitchFields() {
return (
Airplane Mode
Turn on airplane mode to disable all connections.
Dark ModeMarketing Emails
Receive emails about new products, features, and more.
Privacy SettingsManage your privacy preferences.
Make profile visible to others
Show email on profile
Invalid Switch
This switch has validation errors.
Disabled Switch
This switch is currently disabled.
)
}
function SliderFields() {
const [volume, setVolume] = useState([50])
const [brightness, setBrightness] = useState([75])
const [temperature, setTemperature] = useState([0.3, 0.7])
const [priceRange, setPriceRange] = useState([25, 75])
const [colorBalance, setColorBalance] = useState([10, 20, 70])
return (
Volume setVolume(value as number[])}
max={100}
step={1}
/>
Screen Brightness setBrightness(value as number[])}
max={100}
step={5}
/>
Current brightness: {brightness[0]}%
Video Quality
Higher quality uses more bandwidth.
Temperature Range
setTemperature(value as number[])}
min={0}
max={1}
step={0.1}
/>
Range: {temperature[0].toFixed(1)} - {temperature[1].toFixed(1)}
Price Range setPriceRange(value as number[])}
max={100}
step={5}
/>
${priceRange[0]} - ${priceRange[1]}
Color Balance setColorBalance(value as number[])}
max={100}
step={10}
/>
Red: {colorBalance[0]}%, Green: {colorBalance[1]}%, Blue:{" "}
{colorBalance[2]}%
Invalid Slider
This slider has validation errors.
Disabled Slider
This slider is currently disabled.
)
}
function InputOTPFields() {
const [value, setValue] = useState("")
const [pinValue, setPinValue] = useState("")
return (
Verification CodeEnter OTP
Enter the 6-digit code sent to your email.
Two-Factor Authentication
Enter the code from your authenticator app.
PIN Code
Enter your 4-digit PIN (numbers only).
Invalid OTP
This OTP field contains validation errors.
Disabled OTP
This OTP field is currently disabled.
)
}
function HorizontalFields() {
const basicItems = [
{ label: "Select a fruit", value: null },
{ label: "Apple", value: "apple" },
{ label: "Banana", value: "banana" },
{ label: "Orange", value: "orange" },
]
return (
UsernameEnter your preferred username.Bio
Write a short description about yourself.
Email Notifications
Receive email updates about your account.
Favorite FruitChoose your favorite fruit.CountrySelect your country.Select a countryUnited StatesUnited KingdomCanadaVolumeAdjust the volume level.
)
}