Anchor Design System
Form

Radio3.0

Radio allow users to select a single option from a list of mutually exclusive options.

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
<script type="module">
  import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-radio';
  defineCustomElement();
</script>
<anchor-radio>Hello</anchor-radio>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
<script type="module">
  import { defineCustomElements } from '@tryg/ui-library/dist/loader';
  defineCustomElements();
</script>
<anchor-radio>Hello</anchor-radio>

Disabled

Webcomponent
<anchor-radio disabled>Hello</anchor-radio>

Checked

Webcomponent
<anchor-radio checked>Hello</anchor-radio>

Accessibility

  • Radio groups are exposed to assistive technology via ARIA.
  • Each radio is built with a native HTML <input> element, which can be optionally visually hidden to allow custom styling.
  • Full support for browser features like form autofill.
  • Keyboard event support for arrows keys.
  • Keyboard focus management and cross browser normalization.
  • Group and radio labeling support for assistive technology.

API

anchor-radio

Properties

PropertyAttributeDescriptionTypeDefault
backgroundbackgroundSet a white background for the radio button. Use this when the radio button is placed on a non-white backgroundbooleanfalse
checkedcheckedThe radio button is checkedbooleanfalse
descriptiondescriptionOptional descriptive or assistive text displayed below the main labelstringundefined
disableddisabledDisable the radio buttonbooleanfalse
inputIdinput-idThis is name that the label refers tostringundefined
namenameThis is the name for the entire radio button groupstringundefined
requiredrequiredMark the field as requiredbooleanfalse
validityMissingValueTextvalidity-missing-value-textText to be displayed if when value is missing an native form validation is usedstringundefined
valuevalueThis is the string that is returned as a value, when the form is submittedstring''

Events

EventDescriptionType
toggledCustomEvent<any>

Methods

toggleRadio(e?: any) => Promise<void>

Parameters

NameTypeDescription
eany

Returns

Type: Promise<void>

Slots

SlotDescription
"default"Slot for label content

CSS Custom Properties

NameDescription
--radio-aura-color-hoverSets the color of the outline aura when hovered.
--radio-aura-color-pressedSets the color of the outline aura when clicked/active.
--radio-aura-widthSets the thickness of the outline aura on hover and active states.
--radio-backgroundSets the default background color of the radio input.
--radio-background-disabledSets the background color of the radio input when disabled.
--radio-border-colorSets the default border color of the unselected radio input.
--radio-border-color-disabledSets the border color of the radio input when disabled.
--radio-border-color-hoverSets the border color of the radio input when hovered or active.
--radio-border-defaultSets the default border thickness of the unselected radio input.
--radio-border-widthSets the border thickness when checked (creates the inner dot effect).
--radio-description-font-weightSets the font weight for the description text.
--radio-focus-ring-colorSets the color of the focus ring when keyboard navigating.
--radio-focus-ring-sizeSets the overall width and height of the focus ring.
--radio-label-font-weightSets the font weight for the main label text.
--radio-sizeSets the overall width and height of the radio input.
--radio-text-colorSets the color for the main label and description text.
--radio-text-color-disabledSets the text color for the label and description when disabled.
--radio-text-line-heightSets the line height for the main label and description text.
--radio-text-sizeSets the font size for the main label and description text.

Dependencies

Depends on

Graph

graph TD;
  anchor-radio --> anchor-label
  style anchor-radio fill:#f9f,stroke:#333,stroke-width:4px

Built with StencilJS

On this page