fast-radio
An implementation of a radio as a form-connected web-component.
Setup
Basic Setup
import {
provideFASTDesignSystem,
fastRadio
} from "@microsoft/fast-components";
provideFASTDesignSystem()
.register(
fastRadio()
);
Customizing the indicator
import {
provideFASTDesignSystem,
fastRadio
} from "@microsoft/fast-components";
provideFASTDesignSystem()
.register(
fastRadio({
checkedIndicator: `...your checked indicator...`
})
);
Usage
Live Editor
<div role="radiogroup" aria-labelledby="fruit" name="favorite-fruit"> <h3 id="fruit">Favorite fruit:</h3> <fast-radio value="apple">Apple</fast-radio> <fast-radio value="mango">Mango</fast-radio> <fast-radio value="orange">Orange</fast-radio> </div>
Result
Loading...
note
For a more ergonomic usage of radios in groups, see the fast-radio-group
documentation.
Create your own design
import {
Radio,
RadioOptions,
radioTemplate as template,
} from "@microsoft/fast-foundation";
import { radioStyles as styles } from "./my-radio.styles";
export const myRadio = Radio.compose<RadioOptions>({
baseName: "radio",
template,
styles,
checkedIndicator: `...default checked indicator...`,
});
API
class: Radio
Superclass
Name | Module | Package |
---|---|---|
FormAssociatedRadio | /src/radio/radio.form-associated.js |
Fields
Name | Privacy | Type | Default | Description | Inherited From |
---|---|---|---|---|---|
readOnly | public | boolean | When true, the control will be immutable by user interaction. See readonly HTML attribute for more information. | ||
name | public | string | The name of the radio. See name attribute for more info. | ||
proxy | FormAssociatedRadio | ||||
$presentation | public | ComponentPresentation or null | A property which resolves the ComponentPresentation instance for the current component. | FoundationElement | |
template | public | ElementViewTemplate or void or null | Sets the template of the element instance. When undefined, the element will attempt to resolve the template from the associated presentation or custom element definition. | FoundationElement | |
styles | public | ElementStyles or void or null | Sets the default styles for the element instance. When undefined, the element will attempt to resolve default styles from the associated presentation or custom element definition. | FoundationElement |
Methods
Name | Privacy | Description | Parameters | Return | Inherited From |
---|---|---|---|---|---|
templateChanged | protected | void | FoundationElement | ||
stylesChanged | protected | void | FoundationElement |
Events
Name | Type | Description | Inherited From |
---|---|---|---|
change | Emits a custom change event when the checked state changes |
Attributes
Name | Field | Inherited From |
---|---|---|
readonly | readOnly |
CSS Parts
Name | Description |
---|---|
control | The element representing the visual radio control |
label | The label |
Slots
Name | Description |
---|---|
checked-indicator | The checked indicator |
The default slot for the label |