Skip to main content

RadioButton

A RadioButton widget is a user interface component that allows users to select one option from a set. Represented by a small circle, it can be checked or unchecked and generally has an associated text label.

src/main.tsx

import { WRadioButton } from "@cedro/ui/radiobutton.ui";
import { WContainer, WSpacer } from "@cedro/ui/container.ui";
import { createWidget } from "@cedro/ui/widget.builder";

export default (() => {
const handleRadio = (args: any) => {
console.log(args);
};

return createWidget(
<WContainer orientation="vertical">
<WSpacer />
<WContainer orientation="horizontal" fixedSize={45} padding={5}>
<WSpacer />
<WRadioButton id="r1" text="Switch One" checked onClick={handleRadio} />
<WRadioButton id="r2" text="Switch Two" onClick={handleRadio} />
<WRadioButton id="r3" text="Switch Three" onClick={handleRadio} />
<WSpacer />
</WContainer>
<WSpacer />
</WContainer>
);

})();

Properties

The RadioButton widget inherits from ToggleButton class → Has all ToggleButton properties.

Constructor

ParameterTypeRequiredDescription
idstringyesThe id of the widget
textstringyesThe label of the widget
parentWidgetnoThe parent of the widget. Default is null
src/main.ts
import { RadioButton } from "@cedro/ui";

const radio: RadioButton = new RadioButton("my-radio", "option 1");

radio.setState(true);