Clean β’ Professional
Modern web applications must be accessible to everyone and usable in any language. Accessibility ensures inclusivity for users with disabilities, while internationalization (i18n) enables global reach.
In React, both are vital for building scalable, user-friendly, and globally adaptable applications.
This module covers:

Semantic HTML and ARIA roles form the foundation of accessibility in React apps.
Semantic HTML elements like <header>, <main>, <button>, and <form> carry meaning that screen readers and search engines can interpret.
Example:
<header>Welcome to My React App</header>
<nav>
<a href="#home">Home</a>
<a href="#about">About</a>
</nav>
If youβre using non-semantic elements (like <div> for a button), add ARIA roles to describe their behavior:
<div role="button" tabIndex="0" aria-label="Submit Form">Submit</div>
Accessibility isnβt just about visuals β itβs about interaction.
Many users navigate your site using only a keyboard (Tab, Shift+Tab, Enter, Space, and Arrow keys).
React apps must manage focus and keyboard events correctly for full accessibility.
tabIndex={0}):focus CSS state)onKeyDown, onKeyUp)Example:
function AccessibleButton({ label, onClick }) {
return (
<divrole="button"
tabIndex="0"
onClick={onClick}
onKeyDown={(e) => e.key === "Enter" && onClick()}
style={{
padding: "10px 20px",
borderRadius: "5px",
cursor: "pointer",
backgroundColor: "#007bff",
color: "#fff",
}}
>
{label}
</div>
);
}
Screen readers convert on-screen content into speech or Braille output, enabling visually impaired users to navigate your app.
To ensure compatibility, developers must use proper semantics, labels, and ARIA attributes.
aria-label or <label for="">display: none or visibility: hiddenaria-live regions for dynamically updated content (like notifications)Example:
<img src="profile.jpg" alt="User profile picture" />
<div aria-live="polite">Message sent successfully!</div>
<button aria-label="Open Settings Menu">βοΈ</button>
If your app targets a global audience, it should adapt to different languages, date formats, and regions.
React provides flexibility through internationalization (i18n) and localization (l10n) libraries.
| Term | Meaning |
|---|---|
| Internationalization (i18n) | Designing the app to support multiple languages and regions. |
| Localization (l10n) | Implementing specific translations and cultural adaptations for each region. |
Example using react-i18next
Install:
npm install react-i18next i18next
Setup:
import React from "react";
import { useTranslation } from "react-i18next";
function Welcome() {
const { t } = useTranslation();
return <h1>{t("welcome_message")}</h1>;
}
export default Welcome;
Translation file (en.json):
{
"welcome_message": "Welcome to our website!"
}
Now you can easily switch languages dynamically, and the app will render the correct translations.