Docs
Radio Input
Radio Input

A flexible radio group component with labels, descriptions, validation, and Zod integration for single-choice selections.

How would you like to receive notifications?

Get updates via email

Get updates via text message

Get updates via push notifications

Overview

The Radio Input component provides an accessible and flexible solution for single-choice selections, essential for forms requiring mutually exclusive options. It supports both vertical and horizontal layouts with rich option descriptions, individual option disabling, and comprehensive validation. Perfect for preference settings, plan selections, and any scenario requiring clear single-choice decisions with optimal user experience.

Installation

pnpm dlx shadcn@latest add https://deltacomponents.dev/r/radio-input.json

Usage

"use client"
 
import { Building, Globe, Users } from "lucide-react"
 
import { RadioInput } from "@/registry/inputs/radio-input"
 
export function Component() {
  const options = [
    {
      value: "small",
      label: "Small",
      description: "Perfect for individuals",
      icon: <Users className="w-4 h-4" />,
    },
    {
      value: "medium",
      label: "Medium",
      description: "Great for small teams",
      icon: <Building className="w-4 h-4" />,
    },
    {
      value: "large",
      label: "Large",
      description: "Ideal for organizations",
      icon: <Globe className="w-4 h-4" />,
    },
  ]
 
  return (
    <RadioInput
      label="Plan Size"
      name="planSize"
      options={options}
      required
      onValueChange={(value) => console.log("Selected:", value)}
    />
  )
}

API Reference

Props

PropTypeDefaultDescription
labelstring-Label for the radio group (required)
namestring-Name of the radio group for form submission (required)
optionsRadioOption[]-Array of radio options (required)
descriptionstringundefinedDescription text below the label
errorstringundefinedError message to display
requiredbooleanfalseWhether the field is required
pendingbooleanfalseWhether the field is in a loading state
defaultValuestringundefinedDefault selected value
valuestringundefinedControlled selected value
disabledbooleanfalseWhether the radio group is disabled
idstringnameID for the radio group
orientation"vertical" | "horizontal""vertical"Layout orientation
variant"default" | "pill""default"Radio input styling variant
labelVariant"default" | "muted""default"Label text styling variant
containerClassNamestring""CSS classes for the container
radioGroupClassNamestring""CSS classes for the radio group
radioItemClassNamestring""CSS classes for radio items
labelClassNamestring""CSS classes for the label
schemaZodType<string>undefinedZod schema for validation
onValidate(isValid: boolean, value: string, error?: string) => voidundefinedValidation callback
onValueChange(value: string) => voidundefinedCallback when selection changes
allowNoSelectionbooleanfalseWhether to allow no selection (no default value)

RadioOption Interface

interface RadioOption {
  value: string
  label: string
  description?: string
  disabled?: boolean
  icon?: React.ReactNode
}

Examples

Pill Variant

Modern pill-style radio input with colored border and enhanced visual design for plan selection.

Select the plan that best fits your needs

Perfect for individuals just getting started

Best for growing teams and businesses

Custom solutions for large organizations

With Icons

Radio input options enhanced with SVG icons or images positioned on the right side, perfect for payment methods, features, or visual categorization.

Choose your preferred language model

Advanced reasoning and analysis capabilities

Multimodal AI with integrated Google services

Versatile language model for various tasks

No Default Selection

Radio input that allows no initial selection by setting allowNoSelection={true}, useful for optional choices where users should actively make a decision rather than having a pre-selected option.

Select the plan that best fits your needs

Perfect for personal projects

Great for small teams

Ideal for enterprise use