Skip to main content

Radio

Import

To add the Radio component to your project you can import it as follows:

import { Radio } from '@amalgamaco/embassy-ui'; 

Standalone

Example

import { Radio } from '@amalgamaco/embassy-ui';
import React, { useState } from 'react';

const ExampleRadio = () => {
const [ isSelected, setSelected ] = useState( false );

return (
<Radio
selected={ isSelected }
onPress={ () => { setSelected( prev => !prev ); } }
/>
);
};

Props

selected

If the Radio is selected or not.

TYPEREQUIREDDEFAULT
booleanNofalse
<Radio />
<Radio selected />

disabled

If the Radio is disabled or not.

TYPEREQUIREDDEFAULT
booleanNofalse
<Radio disabled />
<Radio disabled selected />

onPress

Invoked when the Radio is pressed.

TYPEREQUIRED
(): voidNo
<Radio onPress={ () => { window.alert( 'The Radio was pressed!' ) } }/>

label

Shows a label text next to the radio button icon.

TYPEREQUIRED
stringNo
<Radio label="Radio" />

value

If the radio is inside a Radio.Group this prop indicates the value for it.

TYPEREQUIRED
stringNo
caution

If the Radio is inside a Radio.Group this prop is required and will throw an Exception if not set.

selectedIcon

An icon component to show when the radio is selected. The default value is the circle-filled icon from the UIKitIcon icons package.

import Feather from 'react-native-vector-icons/Feather';

<Radio
selected
selectedIcon={<Icon as={Feather} name="check-circle" />}
/>

unselectedIcon

An icon component to show when the radio is unselected. The default value is the circle icon from the UIKitIcon icons package.

import Feather from 'react-native-vector-icons/Feather';

<Radio
unselectedIcon={<Icon as={Feather} name="circle" />}
/>

RadioGroup

Example

What is your favorite coding language?
import React, { useState } from 'react';
import { Radio, Text, VStack } from '@amalgamaco/embassy-ui';

const ExampleRadioGroup = () => {
const [ value, setValue ] = useState();

return (
<VStack>
<Text variant="sh1">What is your favorite coding language?</Text>
<Radio.Group value={value} onChange={setValue}>
<Radio value="js" label="Javascript" />
<Radio value="ts" label="Typescript" />
<Radio value="rb" label="Ruby" />
<Radio value="python" label="Python" />
<Radio value="c" label="C" />
<Radio value="cpp" label="C++" />
</Radio.Group>
</VStack>
);
};

Props

value

The selected radio value.

TYPEREQUIREDDEFAULT
stringNoundefined

onChange

Invoked when the group selection changes (because a new option was selected) with the new selected option value.

TYPEREQUIRED
( selected: string ): voidNo

disabled

If the radio group is disabled or not. When it's set to true it disables all the radios inside the group.

TYPEREQUIREDDEFAULT
booleanNofalse
What is your favorite coding language?
import React, { useState } from 'react';
import { Radio, Text, VStack } from '@amalgamaco/embassy-ui';

const ExampleRadioGroup = () => {
const [ value, setValue ] = useState();

return (
<VStack>
<Text variant="sh1">What is your favorite coding language?</Text>
<Radio.Group disabled value={value} onChange={setValue}>
<Radio value="js" label="Javascript" />
<Radio value="ts" label="Typescript" />
<Radio value="rb" label="Ruby" />
<Radio value="python" label="Python" />
<Radio value="c" label="C" />
<Radio value="cpp" label="C++" />
</Radio.Group>
</VStack>
);
};

Pseudo Props

__icon

Props to be applied to the internal Icon component showing the right icon.

TYPEREQUIRED
IIconPropsNo

__iconContainer

Props to be applied to the internal Box component which contains the label and the icons.

TYPEREQUIRED
IBoxPropsNo

__label

Props to be applied to the internal Text component showing the label text.

TYPEREQUIRED
ITextPropsNo