WPDS - Radio Group | Components

Posted by Fernande Dalal on Wednesday, July 31, 2024

Anatomy

Image is not to scale for informative purposes only

  • Radio container
  • Border
  • Filled container
  • Options

    Variants

    There are three variants primary secondary and cta

    Options

    isOutline

    Default value

    Radio buttons can be preselected or not depending on the situation.

    Orientation

    Radio groups can be either horizontal or vertical. By default, radio groups are vertical.

    Behaviors

    Disabled

    Focus

    Error

    Text Overflow

    Guidance

    When error should be shown

    Error should only occur if the options were not pre-selected and user tries to continue without selecting an option. Required radio groups should be indicated in the label with a * in the error token color. Suplementary error message should be shown below the group.

    Required

    When radio button selection is required it should be reflected in the fieldset label.

    Avoid using radio buttons for a binary choice

    The toggle or checkbox is most often used for settings and allows the user to choose between yes/no options or on/off.

    API Reference

    RadioGroup

    PropDescriptionTypeDefaultRequired
    buttonsWrapperCssCSS passed to RadioButtons parent element----False
    defaultValuestring & (string | number | readonly string[])----False
    dir"ltr" | "rtl"----False
    loop----False
    nameShared name of group radios----
    onValueChange(value: string) => void----False
    orientation"horizontal" | "vertical"----False
    required----False
    value----False
    legendLegend text labelling entire group----
    disabledInputs are disabled, changing appearance and preventing input----False
    errorIf there is an error with the fields----False
    cssWPDS provides a css prop for overriding styles easily. It’s like the style attribute, but it supports tokens, media queries, nesting and token-aware values. All WPDS Components include a css prop. Use it to pass in overrides.----False
    errorMessageDescription of error----False
    isOutlineOnly the radio button's outline is displayedfalseFalse
    variantColor variants"cta" | "secondary" | "primary"primaryFalse

    RadioButton

    PropDescriptionTypeDefaultRequired
    required----False
    valueunderlying value for input----
    labellabel text displayed next to button----
    idid of input----
    asChild----False
    errordisplays error state with colored border----False
    cssWPDS provides a css prop for overriding styles easily. It’s like the style attribute, but it supports tokens, media queries, nesting and token-aware values. All WPDS Components include a css prop. Use it to pass in overrides.----False
    isOutlineboolean | "true" | ({ "@reducedMotion"?: boolean | "true"; "@sm"?: boolean | "true"; "@md"?: boolean | "true"; "@lg"?: boolean | "true"; "@xl"?: boolean | "true"; "@xxl"?: boolean | "true"; "@notSm"?: boolean | "true"; ... 17 more ...; "@initial"?: boolean | "true"; } & { ...; })----False
    checked----False
    variant"cta" | "secondary" | "primary" | ({ "@reducedMotion"?: "cta" | "secondary" | "primary"; "@sm"?: "cta" | "secondary" | "primary"; "@md"?: "cta" | "secondary" | "primary"; "@lg"?: "cta" | "secondary" | "primary"; ... 20 more ...; "@initial"?: "cta" | ... 1 more ... | "primary"; } & { ...; })primaryFalse
    isInvalidboolean | "true" | ({ "@reducedMotion"?: boolean | "true"; "@sm"?: boolean | "true"; "@md"?: boolean | "true"; "@lg"?: boolean | "true"; "@xl"?: boolean | "true"; "@xxl"?: boolean | "true"; "@notSm"?: boolean | "true"; ... 17 more ...; "@initial"?: boolean | "true"; } & { ...; })----False

    ncG1vNJzZmiapZ65pXrWmqqhoZ6cwbC6z6iqrWaTpLpwr86mp6imlaPBtHvRmpuip12cv7DBzw%3D%3D