Radio
Install: npm install @mantine/core@9.7.1 @mantine/hooks@9.7.1
Version and compatibility
Pinned Mantine Core 9.7.1 requires React and React DOM ^19.2.0 and matching @mantine/hooks@9.7.1, from the installed npm package's peerDependencies. Do not force it into React 18 or another incompatible version. Explain upgrade impact and agree on a plan with the project owner; do not hide conflicts with --force/--legacy-peer-deps. The native Provider enables theme.respectReducedMotion and uses forceColorScheme for light/dark.
Use case
Choose one value from a mutually exclusive group.
Native props used by this example
These props are extracted from the local typechecked JSX and grouped by their owning native component. This is not an exhaustive prop list; see pinned source signatures and inheritance below.
| Component prop | Explanation |
|---|---|
Radio.Group.defaultValue | Initial uncontrolled value, not a live controlled update. |
Radio.disabled | Disable user input/action; not equivalent to readOnly. |
Radio.value | Controlled value; the native type defines its shape. |
Radio.label | Visible label or component-specific label content. |
Interaction and state checks
Current scenarios: Default, Disabled. Check actual behavior after selecting supported disabled/error/read-only scenarios; components without those native states do not receive invented universal props. Verify keyboard focus and exits, then connect changed values through the native callback signature.
Business integration boundary
Radio.Group owns selection value/onChange; a child Radio needs a unique value. Do not pass a boolean as the group value.
Host setup
Install pinned @mantine/core and @mantine/hooks, import @mantine/core/styles.css at the entry and use MantineProvider. The example's theme/variant are JGuang-authored host props, not universal native component APIs; forceColorScheme synchronizes the app theme. Native implementation source is a reading reference: use npm exports rather than copying internal engines. This batch covers Core, not dates/charts/forms extension packages. Detailed upstream prose remains English.
Runnable usage
import { useState } from 'react';
import * as M from '@mantine/core';
import '@mantine/core/styles.css';
function ComponentPreview({ variant = 'Default' }: { variant?: string }) {
const [value, setValue] = useState(35);
const disabled = variant === "Disabled";
return <M.Radio.Group defaultValue="react"><M.Group><M.Radio disabled={disabled} value="react" label="React" /><M.Radio disabled={disabled} value="vue" label="Vue" /></M.Group></M.Radio.Group>;
}
export default function Example({ variant = 'Default', theme = 'light' }: { variant?: string; theme?: 'light' | 'dark' }) {
return <M.MantineProvider forceColorScheme={theme} theme={{ respectReducedMotion: true }}><ComponentPreview variant={variant} /></M.MantineProvider>;
}
Preview states
Default, Disabled
The example uses the native Mantine API. For supported input demos, change the local variant to Disabled, Invalid or Read only; these are example labels, not new component props. Keep the documented data, controlled values, stores and compound children when adapting the example.
Usage
Controlled
import { useState } from 'react';
import { Radio } from '@mantine/core';
function Demo() {
const [checked, setChecked] = useState(false);
return (
<Radio
checked={checked}
onChange={(event) => setChecked(event.currentTarget.checked)}
/>
);
}
Uncontrolled
Radio can be used with uncontrolled forms the same way as a native input[type="radio"].
Set the name and value attributes to include radio value in FormData object on form submission.
To control the initial checked state in uncontrolled forms, use defaultChecked prop.
Example usage of uncontrolled Radio with FormData:
import { Radio } from '@mantine/core';
function Demo() {
return (
<form
onSubmit={(event) => {
event.preventDefault();
const formData = new FormData(event.currentTarget);
console.log('Radio value:', formData.get('option'));
}}
>
<Radio name="option" value="option1" label="Option 1" />
<Radio name="option" value="option2" label="Option 2" defaultChecked />
<button type="submit">Submit</button>
</form>
);
}
States
Light variant
Radio supports filled (default), outline and light variants. With variant="light", the checked state has a light background and a contrasting icon. Colors of the light variant are resolved with theme.variantColorResolver, the same way as in Button – color can be a key of theme.colors or any valid CSS color:
Change icon
Change icon color
Disabled state
Pointer cursor
By default, the radio input and label have cursor: default (same as native input[type="radio"]).
To change the cursor to pointer, set cursorType on the theme:
import { createTheme, MantineProvider, Radio } from '@mantine/core';
const theme = createTheme({
cursorType: 'pointer',
});
function Demo() {
return (
<MantineProvider theme={theme}>
<Radio label="Pointer cursor" />
</MantineProvider>
);
}
Radio with tooltip
You can change the target element to which the tooltip is attached with refProp:
- If
refPropis not set, the tooltip is attached to the radio input - If
refProp="rootRef"is set, the tooltip is attached to the root element (contains label, input, and other elements)
Radio.Group component
Radio.Group disabled state
Controlled Radio.Group
import { useState } from 'react';
import { Radio } from '@mantine/core';
function Demo() {
const [value, setValue] = useState('react');
return (
<Radio.Group
value={value}
onChange={setValue}
name="favoriteFramework"
label="Select your favorite framework/library"
description="This is anonymous"
withAsterisk
>
<Radio value="react" label="React" />
<Radio value="svelte" label="Svelte" />
<Radio value="ng" label="Angular" />
<Radio value="vue" label="Vue" />
</Radio.Group>
);
}
Radio.Indicator
Radio.Indicator looks exactly the same as the Radio component, but it does not
have any semantic meaning; it's just a visual representation of the radio state. You
can use it in any place where you need to display the radio state without any interaction
related to the indicator. For example, it is useful in cards based on buttons, trees, etc.
Note that Radio.Indicator cannot be focused or selected with the keyboard. It is not
accessible and should not be used as a replacement for the Radio component.
Radio.Indicator supports the same variant values as Radio: filled, outline and light.
Radio.Card component
Radio.Card component can be used as a replacement for Radio to build custom
cards/buttons/other things that work as radios. The root element of the component
has the role="radio" attribute; it is accessible by default and supports the same
keyboard interactions as input[type="radio"].
You can use Radio.Card with Radio.Group the same way as the Radio component:
Accessibility
Set the aria-label or label prop to make the radio accessible:
import { Radio } from '@mantine/core';
// Not ok, input is not labeled
function Bad() {
return <Radio />;
}
// Ok, input is labeled by aria-label
function GoodAriaLabel() {
return <Radio aria-label="My radio" />;
}
// Ok, input is labeled by label element
function GoodLabel() {
return <Radio label="My radio" />;
}
Source-backed parameter reference
Implementation signatures and types are generated from the pinned local source. Optional props, native inherited types, union branches and never exclusions are preserved. A forwardRef implementation's ref is a React reference, not an additional business prop.
Radio(_props)
export type RadioVariant = 'filled' | 'outline' | 'light';
export type RadioStylesNames = InlineInputStylesNames | 'inner' | 'radio' | 'icon';
export type RadioCssVariables = {
root:
| '--radio-size'
| '--radio-radius'
| '--radio-color'
| '--radio-icon-color'
| '--radio-icon-size'
| '--radio-bg';
};
export interface RadioProps
extends BoxProps, StylesApiProps<RadioFactory>, ElementProps<'input', 'size' | 'children'> {
/** Content of the `label` associated with the radio */
label?: React.ReactNode;
/** Key of theme.colors or any valid CSS color to set radio background color in checked state @default theme.primaryColor */
color?: MantineColor;
/** Controls size of the component @default 'sm' */
size?: MantineSize | (string & {});
/** A component that replaces the default radio icon (centered dot) */
icon?: React.FC<RadioIconProps>;
/** Props passed down to the root element */
wrapperProps?: React.ComponentProps<'div'> & DataAttributes;
/** Position of the label relative to the input @default 'right' */
labelPosition?: 'left' | 'right';
/** Description displayed below the label */
description?: React.ReactNode;
/** Error displayed below the label */
error?: React.ReactNode;
/** Key of `theme.radius` or any valid CSS value to set `border-radius` @default 'xl' */
radius?: MantineRadius;
/** Assigns ref of the root element */
rootRef?: React.Ref<HTMLDivElement>;
/** Key of theme.colors or any valid CSS color to set icon color. When not set, icon color is determined automatically based on theme.autoContrast setting */
iconColor?: MantineColor;
/** If set, adjusts text color based on background color for `filled` variant */
autoContrast?: boolean;
/** If set, applies error styles to the radio when `error` prop is set @default true */
withErrorStyles?: boolean;
}
export type RadioFactory = Factory<{
props: RadioProps;
ref: HTMLInputElement;
stylesNames: RadioStylesNames;
vars: RadioCssVariables;
variant: RadioVariant;
staticComponents: {
Group: typeof RadioGroup;
Card: typeof RadioCard;
Indicator: typeof RadioIndicator;
};
}>;
export type Mod = Record<string, any> | string;
export type BoxMod = Mod | Mod[] | BoxMod[];
export interface BoxProps extends MantineStyleProps {
/** Class added to the root element, if applicable */
className?: string | undefined;
/** Inline style added to root component element, can subscribe to theme defined on MantineProvider */
style?: MantineStyleProp;
/** CSS variables defined on root component element */
__vars?: CssVarsProp;
/** `size` property passed down the HTML element */
__size?: string;
/** Breakpoint above which the component is hidden with `display: none` */
hiddenFrom?: MantineBreakpoint;
/** Breakpoint below which the component is hidden with `display: none` */
visibleFrom?: MantineBreakpoint;
/** Determines whether component should be hidden in light color scheme with `display: none` */
lightHidden?: boolean;
/** Determines whether component should be hidden in dark color scheme with `display: none` */
darkHidden?: boolean;
/** Element modifiers transformed into `data-` attributes, for example, `{ 'data-size': 'xl' }`, falsy values are removed */
mod?: BoxMod;
}
export type ElementProps<
ElementType extends React.ElementType,
PropsToOmit extends string = never,
> = Omit<React.ComponentProps<ElementType>, 'style' | PropsToOmit>;
export interface CSSProperties extends React.CSSProperties {
[key: string]: any;
}
type MantineStyle = CSSProperties | ((theme: MantineTheme) => CSSProperties);
export type MantineStyleProp = MantineStyle | MantineStyle[] | MantineStyleProp[] | undefined;
export type CssVariable = `--${string}`;
export type CssVariables<Variable extends string = CssVariable> = Partial<Record<Variable, string>>;
export type CssVars<Variable extends string = CssVariable> =
| CssVariables<Variable>
| ((theme: MantineTheme) => CssVariables<Variable>)
| CssVars<Variable>[];
export type CssVarsProp<Variable extends string = CssVariable> =
| CssVars<Variable>
| CssVars<Variable>[];
Native and external types
External types remain defined by React or native dependencies, not manually expanded into guessed props. The installed version's TypeScript definitions are authoritative.
Factory<{
props: RadioProps;
ref: HTMLInputElement;
stylesNames: RadioStylesNames;
vars: RadioCssVariables;
variant: RadioVariant;
staticComponents: {
Group: typeof RadioGroup;
Card: typeof RadioCard;
Indicator: typeof RadioIndicator;
};
}>
MantineStyleProps
React.CSSProperties
MantineTheme
Partial<Record<Variable, string>>
Record<Variable, string>
Variable
MantineBreakpoint
Record<string, any>
StylesApiProps<RadioFactory>
React.ElementType
Omit<React.ComponentProps<ElementType>, 'style' | PropsToOmit>
React.ComponentProps<ElementType>
ElementType
PropsToOmit
React.ReactNode
MantineColor
MantineSize
React.FC<RadioIconProps>
RadioIconProps
React.ComponentProps<'div'>
DataAttributes
MantineRadius
React.Ref<HTMLDivElement>
HTMLDivElement
HTMLInputElement
InlineInputStylesNames