React Hook Form
Use a Controller and call field.onChange with the new value. Same shape as a native radio group, none of the wiring.
SenRadio is a thin, accessible wrapper over a native radio input. It keeps keyboard semantics, focus rings, and form integration for free, and adds nothing else.
Stepping stones — only one foot down at a time.
Use a Controller and call field.onChange with the new value. Same shape as a native radio group, none of the wiring.
Show a locked option without removing it from the group.
Skip the label prop when a custom layout supplies its own.
Wrap groups in fieldset with a legend. Native arrow-key navigation comes for free.
More than five options? A select probably reads faster.
Use radios when the user must pick exactly one. For independent toggles reach for SenCheckbox.
Group radios with a shared name attribute. The browser handles exclusivity natively.
forwardRef makes integration with React Hook Form, Formik, or vanilla refs frictionless.
A controlled radio group — the most common shape for forms.
'use client'
import { useState } from 'react'
import SenRadio from 'sen-ui/SenRadio'
export function PlanPicker() {
const [plan, setPlan] = useState('free')
return (
<fieldset className="space-y-2">
<legend>Pick a plan</legend>
{['free', 'pro', 'team'].map((p) => (
<SenRadio
key={p}
id={`plan-${p}`}
name="plan"
value={p}
label={p}
checked={plan === p}
onChange={() => setPlan(p)}
/>
))}
</fieldset>
)
}'use client'
import React, { forwardRef } from 'react'
import type { ChangeEventHandler, InputHTMLAttributes } from 'react'
export interface SenRadioProps
extends Omit<InputHTMLAttributes<HTMLInputElement>, 'size' | 'onChange'> {
id: string
name: string
value: string
label?: string
checked?: boolean
disabled?: boolean
onChange?: ChangeEventHandler<HTMLInputElement>
className?: string
}
const SenRadio = forwardRef<HTMLInputElement, SenRadioProps>(
(
{ id, name, value, label, checked = false, disabled = false, onChange, className, ...props },
ref
) => {
return (
<div
className={[
'flex items-center',
disabled && 'opacity-50',
className,
]
.filter(Boolean)
.join(' ')}
>
<input
ref={ref}
type="radio"
id={id}
name={name}
value={value}
checked={checked}
disabled={disabled}
onChange={onChange}
className="h-4 w-4 border-gray-300 transition-colors duration-150 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2"
{...props}
/>
{label && (
<label htmlFor={id} className="ml-2 cursor-pointer select-none">
{label}
</label>
)}
</div>
)
}
)
SenRadio.displayName = 'SenRadio'
export default SenRadio