UX4G Logo
Components

Radio Button

Single-selection radio button and radio group supporting custom sizes, validation status variants, required indicators, and helper text

The UX4G Radio Button component allows users to select a single option from a set of mutually exclusive choices. It is designed specifically for citizen-facing forms, survey questionnaires, payment gateway options, and administrative workflows.

Key Capabilities

  • Generic & Boolean Overloads: Type-safe <T> selection with value / groupValue binding or direct selected / onClick state control.
  • Validation & Status Variants: Visual ring status and contextual description messaging (Helper, Error, Warning, Success) with automatic status icons.
  • Size Options: Preconfigured sizes: Small (16dp), Medium (20dp), and Large (24dp).
  • Form Controls: Support for required indicator asterisks (*), trailing icons, custom typography, disabled states, and centered touch ripples.

Import from com.ux4g.designsystemv1.components.radiobutton.*.


Interactive Previews

1. Default Radio Group

Standard radio button selection with multiple options where only one choice can be selected at a time.

Ux4gRadioButton (Default Selection)Jetpack Compose
UX4G Default Radio Button Preview

2. Status & Validation Variants

Radio button options configured with validation severities (Helper, Error, Warning, Success). Each state renders custom ring coloring and descriptive messages with contextual status icons.

Ux4gRadioButton (Status Variants)Jetpack Compose
UX4G Status Radio Button Preview

Kotlin Usage

1. Type-Safe Radio Selection Group

PaymentModeSelection.kt
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.radiobutton.*

enum class PaymentMode(val title: String) {
    UPI("UPI / Instant Transfer"),
    NetBanking("Internet Banking"),
    DebitCard("Debit / Credit Card")
}

@Composable
fun PaymentSelectionSection() {
    var selectedMode by remember { mutableStateOf(PaymentMode.UPI) }

    Column(
        modifier = Modifier.padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(8.dp)
    ) {
        PaymentMode.values().forEach { mode ->
            Ux4gRadioButton(
                value = mode,
                groupValue = selectedMode,
                onValueChange = { selectedMode = it },
                label = mode.title,
                size = Ux4gRadioButtonSize.Medium
            )
        }
    }
}

2. Form Field with Required Asterisk & Validation

DeclarationRadio.kt
import androidx.compose.foundation.layout.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.ux4g.designsystemv1.components.radiobutton.*

@Composable
fun CitizenshipDeclaration(
    isCitizen: Boolean?,
    onStatusChange: (Boolean) -> Unit,
    hasValidationError: Boolean
) {
    Column(
        modifier = Modifier.padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(10.dp)
    ) {
        Ux4gRadioButton(
            selected = isCitizen == true,
            onClick = { onStatusChange(true) },
            label = "I am an Indian Citizen",
            isRequired = true,
            size = Ux4gRadioButtonSize.Medium,
            description = if (hasValidationError && isCitizen == null) "Mandatory selection required" else null,
            descriptionVariant = if (hasValidationError && isCitizen == null) Ux4gRadioButtonDescriptionVariant.Error else Ux4gRadioButtonDescriptionVariant.Helper,
            status = if (hasValidationError && isCitizen == null) Ux4gRadioButtonStatus.Error else Ux4gRadioButtonStatus.DefaultStatus
        )

        Ux4gRadioButton(
            selected = isCitizen == false,
            onClick = { onStatusChange(false) },
            label = "I am a Foreign National / NRI",
            isRequired = true,
            size = Ux4gRadioButtonSize.Medium
        )
    }
}

Parameters

Ux4gRadioButton<T> (Generic Model)

PropTypeDescriptionDefault
value *TThe value represented by this individual radio button.—
groupValue *T?The currently active selected value for the radio group.—
onValueChange *(T) -> UnitCallback invoked when this radio option is selected.—
modifierModifierCompose layout modifier for outer container.Modifier
labelString?Primary label text displayed next to the radio button.null
descriptionString?Supporting helper message or validation error text.null
sizeUx4gRadioButtonSizeRadio button size variant (Small, Medium, Large).Ux4gRadioButtonSize.Medium
isRequiredBooleanAppends a red asterisk (*) next to the label when true.false
trailingIconUx4gIcon?Optional UX4G icon placed inline beside the label text.null
trailingImageVectorImageVector?Optional Compose ImageVector placed beside the label text.null
descriptionVariantUx4gRadioButtonDescriptionVariantContextual severity style (Helper, Error, Warning, Success).Ux4gRadioButtonDescriptionVariant.Helper
statusUx4gRadioButtonStatusOuter ring visual state coloring (DefaultStatus, Error, Warning, Success).Ux4gRadioButtonStatus.DefaultStatus
colorColor?Custom tint color for selected circle ring. Takes precedence over status.null
labelColorColor?Custom text color for the label.null
labelStyleTextStyle?Custom typography style override for the label text.null
descriptionStyleTextStyle?Custom typography style override for the description text.null
enabledBooleanControls interactive touch state and disabled opacity.true

Ux4gRadioButton (Boolean Overload)

PropTypeDescriptionDefault
selected *BooleanWhether this radio button is in a selected state.—
onClick *() -> UnitCallback invoked when the radio button is clicked.—
modifierModifierCompose layout modifier for outer container.Modifier
labelString?Primary label text displayed next to the radio button.null
descriptionString?Supporting helper message or validation error text.null
sizeUx4gRadioButtonSizeRadio button size variant (Small, Medium, Large).Ux4gRadioButtonSize.Medium
isRequiredBooleanAppends a red asterisk (*) next to the label when true.false
trailingIconUx4gIcon?Optional UX4G icon placed inline beside the label text.null
trailingImageVectorImageVector?Optional Compose ImageVector placed beside the label text.null
descriptionVariantUx4gRadioButtonDescriptionVariantContextual severity style (Helper, Error, Warning, Success).Ux4gRadioButtonDescriptionVariant.Helper
statusUx4gRadioButtonStatusOuter ring visual state coloring (DefaultStatus, Error, Warning, Success).Ux4gRadioButtonStatus.DefaultStatus
colorColor?Custom tint color for selected circle ring. Takes precedence over status.null
labelColorColor?Custom text color for the label.null
labelStyleTextStyle?Custom typography style override for the label text.null
descriptionStyleTextStyle?Custom typography style override for the description text.null
enabledBooleanControls interactive touch state and disabled opacity.true
interactionSourceMutableInteractionSourceCustom interaction stream for ripple feedback.remember { MutableInteractionSource() }

Ux4gRadioButtonSize Reference

SizeOuter Circle (sizeDp)Inner Dot (dotSizeDp)Typography Level
Small16.dp8.dplM_default (Label), lS_default (Desc)
Medium20.dp10.dplL_default (Label), lM_default (Desc)
Large24.dp12.dplXL_default (Label), lL_default (Desc)

Ux4gRadioButtonDescriptionVariant Reference

VariantIconText ColorUsage Context
HelperIcons.Outlined.InfoonSurface (70% alpha)Informational hints and general guidance
ErrorIcons.Outlined.ErrorOutlineUx4gTheme.colorScheme.errorForm validation failures and mandatory field alerts
WarningIcons.Outlined.WarningAmberUx4gColors.secondary600Cautionary warnings and soft prerequisite notices
SuccessIcons.Outlined.CheckCircleOutlineUx4gColors.green600Confirmation and successful condition validation

Ux4gRadioButtonStatus Reference

StatusRing ColorDescription
DefaultStatusUx4gTheme.colorScheme.primary (selected) / neutral300 (unselected)Standard neutral theme-aware radio ring
ErrorUx4gTheme.colorScheme.errorHighlighted error ring for invalid selection
WarningUx4gColors.secondary600Amber cautionary ring
SuccessUx4gColors.green600Green success ring

On this page