Search results

Accessibility in Angular RadioButton component

18 May 2022 / 2 minutes to read

The web accessibility makes web content and web applications more accessible for people with disabilities. It especially helps in dynamic content change and development of advanced user interface controls with AJAX, HTML, JavaScript, and related technologies. RadioButton provides built-in compliance with WAI-ARIA specifications. WAI-ARIA support is achieved through the attributes like aria-checked and aria-disabled. It helps the people with disabilities by providing information about the widget for assistive technology in the screen readers. RadioButton component contains the radiobutton role.

Properties Functionality
role Indicates the type of input element.
aria-checked Indicates whether the input is checked, unchecked, or represents mixture of checked and unchecked values.
aria-disabled Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.

Keyboard interaction

Keyboard shortcuts Actions
Up/Left arrow Move and select the previous options.
Down/Right arrow Move and select the next options.
Source
Preview
app.component.ts
app.module.ts
main.ts
Copied to clipboard
import { Component } from '@angular/core';

@Component({
    selector: 'app-root',
    template: `<ul>
               <!-- checked state. -->
               <li><ejs-radiobutton label="Option 1" name="state" checked="true"></ejs-radiobutton></li>

               <!-- unchecked state. -->
               <li><ejs-radiobutton label="Option 2" name="state"></ejs-radiobutton></li>

               <!-- unchecked state. -->
               <li>
                   <ejs-radiobutton label="Option 3" name="state"></ejs-radiobutton>
                   <ejs-radiobutton label="Option 4" name="state"></ejs-radiobutton>
               </li>
               </ul>`
})

export class AppComponent { }
Copied to clipboard
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RadioButtonModule } from '@syncfusion/ej2-angular-buttons';
import { AppComponent } from './app.component';
import { enableRipple } from '@syncfusion/ej2-base';

enableRipple(true);

/**
 * Module
 */
@NgModule({
    imports: [
        BrowserModule,
        RadioButtonModule
    ],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }
Copied to clipboard
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { AppModule } from './app.module';

enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);