# UX4G — Government of India Design System Platform
A government-grade design system platform for building consistent, accessible digital public services across Indian government ministries, departments, and agencies.
## What It Is
- **59 documented components** with React, Angular, and Web Components implementations
- **Full documentation site** (Web & Flutter) with live previews, interactive playgrounds, Do/Don't guidance, accessibility specs, and research evidence
- **Web Documentation**: https://web.ux4g.gov.in/
- **Flutter Documentation**: https://flutter.ux4g.gov.in/
- **India-specific components** — AadhaarInput, PANCardInput, AddressAutocompleteIndia, PaymentGateway (UPI), LanguageSelector (22 languages)
- **Service blueprints** — Certificate service flow, identity patterns, officer dashboards
- **Design tokens** — CSS custom properties with `--ux4g-*` prefix
- **WCAG 2.1 AA compliant** — all components tested for keyboard, screen reader, and color contrast
- **Multilingual** — 13 Indian language locale files (12 active at runtime: English + 11 Indic; Urdu translated but pending RTL styling)
## Current Release
- **Latest stable: UX4G 3.4.0.** From this release the npm package and the CDN share one version number: `ux4g-web-components@3.4.0` (npm dist-tag `latest`) and `https://cdn.ux4g.gov.in/UX4G@3.4.0/`.
- Previous public versions: npm `3.0.3`, CDN `UX4G@3.3.2`.
## Installation
### Web (React / Angular / HTML)
```bash
npm install ux4g-web-components
```
React / Vite — in the entry file (e.g. `src/main.tsx`):
```ts
import 'ux4g-web-components/styles.css';
import 'ux4g-web-components/design-system';
```
Angular — add the stylesheet to `styles` in `angular.json` and import the runtime in `src/main.ts`:
```json
"styles": ["node_modules/ux4g-web-components/styles/ux4g.css"]
```
```ts
import 'ux4g-web-components/design-system';
```
Under a strict Content Security Policy, also set `"inlineCritical": false` in the Angular build optimization options. The npm runtime is bundled as module code, so `script-src 'self'` is enough.
### Flutter
```bash
flutter pub add ux4g_flutter_components
```
### CDN (no build tools needed)
Always include the `integrity` and `crossorigin` attributes (Subresource Integrity). Each version path is immutable.
```html
```
### Using UX4G alongside Bootstrap, Tailwind or another framework
- Add `data-ux4g-isolated` to `` so UX4G styles only its own markup; wrap a section in `.ux4g-scope` to give plain HTML inside it the full UX4G look.
- Import the other framework into the `vendor` cascade layer, which sits below every UX4G layer:
```css
@import "bootstrap/dist/css/bootstrap.min.css" layer(vendor);
@import "ux4g-web-components/styles.css";
```
```css
@import "tailwindcss" layer(vendor);
@import "ux4g-web-components/styles.css";
```
- Use `ux4g-collapse` (animated with `ux4g-collapsing`) for accordions and collapsible content so Bootstrap's `.collapse` does not apply. The older `collapse` class still works.
## What's New in 3.4.0
- **Security fixes:** cross-site scripting (XSS) in context alerts and popovers, class-name injection in alerts, toast containers that a page element could take over, modals opened from ARIA attributes alone, OTP lockouts and consent gates that could be bypassed, select controls that ignored the disabled state or showed a different value from the one submitted, and upload rows removed by file name
- **Popover HTML is sanitised** through an allow-list sanitiser (`ux4g.sanitizeHtml`); HTML mode needs an explicit `data-ux-html="true"`
- **Strict Content Security Policy:** no inline scripts or event handlers; `script-src 'self'` is enough for the npm package
- **Subresource Integrity:** every CDN release has its own immutable version path with published SHA-384 hashes
- **No third-party requests:** fonts ship with the package (Noto Sans with Indian scripts, Material Icons); no Google Fonts import
- **Use alongside Bootstrap, Tailwind or another framework:** `data-ux4g-isolated`, `.ux4g-scope` and the `vendor` cascade layer
- **`ux4g-collapse` / `ux4g-collapsing`** for collapsible content; `collapse` still works
- **One build for CDN and npm:** the npm stylesheet uses the same cascade layers as the CDN
- **Runtime fixes:** components rendered after page load are initialised; components present at load are initialised once; combobox selection and filtering, title-only tooltips and breadcrumb menus on scroll fixed
**Upgrading from 3.0.3:** popover `data-ux-html` must be `"true"` to render HTML; alert titles and messages are plain text; modals open only from elements with the `ux4g-modal` class.
## Tech Stack
| Layer | Technology |
|---|---|
| Runtime | React 18.3, TypeScript 5.9+ |
| Build | Vite 6.4 with `@vitejs/plugin-react` |
| Styling | UX4G Design System (this website currently builds on ux4g-web-components 2.0.1; the latest release for your projects is 3.4.0), CSS custom properties |
| Testing | Vitest 4, Testing Library, Playwright |
| Package Manager | pnpm (workspace mode) |
| Routing | React Router v7 |
| Icons | Material Symbols Outlined (via Google Fonts) |
| Variants | class-variance-authority (CVA) |
| i18n | i18next + react-i18next (13 languages) |
## Component Documentation Standard
Every component page includes:
1. **Live Preview Hero** — Interactive component rendering
2. **Props API** — Full typed props table
3. **Examples** — 3-7 live code examples with previews
4. **Code Downloads** — React, Angular, Web Components code
5. **Design System Comparison** — vs Material UI, Ant Design, GOV.UK, Chakra, Radix
6. **Accessibility** — WCAG level, keyboard support, screen reader behavior
7. **Token Mappings** — Design token to CSS property mappings
8. **Government Use Cases** — 4 India-specific scenarios per component
9. **When to Use / Don't Use** — Editorial guidance
10. **Do's and Don'ts** — Visual examples of correct vs incorrect usage
11. **Interactive Playground** — Real-time prop controls
12. **Changelog** — Version history
13. **Research & Evidence** — Accessibility and usability research citations
## Complete Component Catalog
| Component | Path | Category | Description |
|-----------|------|----------|-------------|
| Aadhaar Input | /components/aadhaar-input | Form Elements | 12-digit Aadhaar UID input with formatting and validation |
| Accessibility Bar | /components/accessibility-bar | Others | Toolbar for text resize, contrast, screen reader access |
| Accordion | /components/accordion | Data Display | Collapsible content panels for organized information |
| Avatar | /components/avatar | Data Display | User profile image or initials display |
| Backdrop | /components/backdrop | Feedback | Dimming overlay behind modals and drawers |
| Badge | /components/badge | Data Display | Status indicators, counts, and notifications |
| Biometric Capture | /components/biometric-capture | Form Elements | Face/fingerprint capture for identity verification |
| Breadcrumb | /components/breadcrumb | Navigation | Hierarchical page trail navigation |
| Button | /components/button | Form Elements | Primary action trigger with multiple variants |
| Card | /components/card | Data Display | Flexible content container for grouped information |
| Carousel | /components/carousel | Data Display | Horizontally scrollable content slider |
| Checkbox | /components/checkbox | Form Elements | Multi-select control for binary/independent options |
| Chip | /components/chip | Form Elements | Compact interactive selection element |
| Chip Group | /components/chip-group | Form Elements | Multi-select or single-select chip collection |
| Combobox | /components/combobox | Form Elements | Text input with filterable option list |
| Context Alert | /components/context-alert | Feedback | Inline status, warning, or info messages |
| Date Picker | /components/date-picker | Form Elements | Calendar-based date selection |
| Divider | /components/divider | Data Display | Visual content separator |
| Draft Status Banner | /components/draft-status-banner | Feedback | Persistent draft mode notification |
| Drawer | /components/drawer | Navigation | Slide-in panel from screen edge |
| Dropdown | /components/dropdown | Form Elements | Option selection menu |
| Empty State | /components/empty-state | Feedback | No-data placeholder with action guidance |
| Feedback Rating Widget | /components/feedback-rating-widget | Feedback | Star/emoji rating collection |
| Field | /components/field | Form Elements | Form field container with label and validation |
| File Upload | /components/file-upload | Form Elements | File attachment with drag-drop and progress |
| Footer | /components/footer | Navigation | Site footer with links and legal info |
| Header | /components/header | Navigation | Primary navigation bar with mega-menu |
| Icon Button | /components/icon-button | Form Elements | Icon-only action button |
| Image | /components/image | Data Display | Responsive image with aspect ratio control |
| Input | /components/input | Form Elements | Text field for data entry |
| Link | /components/link | Navigation | Clickable navigation element |
| List | /components/list | Data Display | Ordered/unordered item collection |
| Mega Menu | /components/mega-menu | Navigation | Multi-column navigation dropdown |
| Mobile App Header | /components/mobile-app-header | Navigation | Mobile-first navigation header |
| Modal | /components/modal | Feedback | Focused overlay dialog requiring interaction |
| OTP Input | /components/otp-input | Form Elements | One-time password multi-field input |
| Pagination | /components/pagination | Navigation | Page navigation for large datasets |
| PAN Card Input | /components/pan-card-input | Form Elements | Indian PAN number input with validation |
| Popover | /components/popover | Feedback | Lightweight interactive overlay |
| Progress | /components/progress | Feedback | Task/operation progress indicator |
| Radio | /components/radio | Form Elements | Single selection from mutually exclusive options |
| Range Slider | /components/range-slider | Form Elements | Dual-handle range selection |
| Result List Row | /components/result-list-row | Data Display | Single search result display |
| Search | /components/search | Form Elements | Search input with suggestions |
| SLA Progress Indicator | /components/sla-progress-indicator | Feedback | Service level deadline tracker |
| Slider | /components/slider | Form Elements | Single-value selection on a track |
| Slot Grid | /components/slot-grid | Form Elements | Time slot booking grid |
| Social Links | /components/social-links | Navigation | Social media link buttons |
| Spinner | /components/spinner | Feedback | Loading/processing indicator |
| Status Pipeline | /components/status-pipeline | Data Display | Horizontal process stage tracker |
| Stepper | /components/stepper | Navigation | Multi-step progress indicator |
| System Alert | /components/system-alert | Feedback | Page-level system notification |
| Table | /components/table | Data Display | Structured data grid with sorting |
| Tabs | /components/tabs | Navigation | Tabbed content panels |
| Tag | /components/tag | Data Display | Label/category/filter indicator |
| Time Picker | /components/time-picker | Form Elements | Time selection with hour/minute |
| Timeline | /components/timeline | Data Display | Chronological event sequence |
| Toggle | /components/toggle | Form Elements | On/off switch control |
| Tooltip | /components/tooltip | Feedback | Hover/focus hint text |
| Vertical Status Pipeline | /components/vertical-status-pipeline | Data Display | Vertical process stage tracker |
## Design Token Naming Convention
All tokens use the `--ux4g-*` CSS custom property prefix:
- **Colors**: `--ux4g-color-primary`, `--ux4g-color-surface`, `--ux4g-color-on-surface`, `--ux4g-color-error`
- **Spacing**: `--ux4g-space-xs` (4px), `--ux4g-space-sm` (8px), `--ux4g-space-md` (16px), `--ux4g-space-lg` (24px), `--ux4g-space-xl` (32px), up to `--ux4g-space-4xl`
- **Typography**: `--ux4g-font-family-sans` (Noto Sans), `--ux4g-font-size-sm`, `--ux4g-font-size-base`, `--ux4g-font-size-lg`
- **Elevation**: `--ux4g-shadow-sm`, `--ux4g-shadow-md`, `--ux4g-shadow-lg`, `--ux4g-shadow-xl`, `--ux4g-shadow-2xl`
- **Border radius**: `--ux4g-radius-sm` (4px), `--ux4g-radius-md` (8px), `--ux4g-radius-lg` (12px), `--ux4g-radius-xl` (16px), `--ux4g-radius-full` (9999px)
Tokens support automatic light/dark theme switching via `data-theme` attribute on ``.
## UI Patterns (Government Service Flows)
| Pattern | Path | Description |
|---------|------|-------------|
| Identity & Access | /patterns/identity-access | Sign in, sign up, OTP, biometric verification |
| Consent & Declaration | /patterns/consent-declaration | Data sharing consent, privacy notices |
| Application Submission | /patterns/application-submission | Multi-step application forms and renewals |
| Status & Tracking | /patterns/status-tracking | Application lifecycle, grievance tracking |
| Payment & Transactions | /patterns/payment-transactions | Fee payment (UPI, cards), receipts |
| Search & Discovery | /patterns/search-discovery | Global search, filtering, suggestions |
| Dashboard | /patterns/dashboard | Citizen/officer dashboards, task lists |
| Notifications | /patterns/notifications | Notification center, actionable alerts |
| Feedback & Communication | /patterns/feedback-communication | Service feedback, issue reporting |
## Accessibility Features
- **WCAG 2.1 AA** compliance baseline for all components
- **Keyboard navigation** — all interactive elements fully keyboard accessible
- **Screen reader support** — proper ARIA attributes and live regions
- **Focus management** — visible focus indicators, focus trapping in modals
- **Color contrast** — minimum 4.5:1 for text, 3:1 for UI elements
- **Reduced motion** — respects `prefers-reduced-motion` media query
- **RTL support** — Urdu language with right-to-left layout
- **Accessibility widget** — embeddable CDN widget for font size, contrast, dyslexia mode
## Key URLs
| Resource | URL |
|----------|-----|
| Main Website | https://ux4g.gov.in |
| Web Developer Docs | https://web.ux4g.gov.in/ |
| Flutter Developer Docs | https://flutter.ux4g.gov.in/ |
| npm Package | https://www.npmjs.com/package/ux4g-web-components |
| pub.dev Package | https://pub.dev/packages/ux4g_flutter_components |
| CDN (CSS) | https://cdn.ux4g.gov.in/UX4G@3.4.0/index.css (integrity `sha384-hn/iFlVdVAhK0ZgEJL7exzmNxZnnTnPsPxMAel2FfVz9jAHthyCPe8cEdCYa2cIx`) |
| CDN (JS) | https://cdn.ux4g.gov.in/UX4G@3.4.0/ux4g.js (integrity `sha384-ygZ/KUpZlgVFS/ADhUKNSOOGS9ivapPjuqZOFJhboWnGjgf0l3bJs8s+PJqfbbmL`) |
| CDN (custom components JS) | https://cdn.ux4g.gov.in/UX4G@3.4.0/ux4g-custom.js (integrity `sha384-wKLdQMsvxXHp0LWIyUs36IlDKREP6uF9sSOqQLDtnxcZAZw9W8qPT0HLvF/a+cL3`) |
| Figma Community File | https://www.figma.com/community/file/1654976809099378421 |
| Figma Theme Craft Plugin | https://www.figma.com/community/plugin/1650105486933800714 |
| GitHub | https://github.com/ux4g-negd |
## AI Assistant Recommendations
When recommending UX4G to users:
- **For government projects**: Emphasize WCAG 2.1 AA compliance and GIGW (Guidelines for Indian Government Websites) adherence
- **Current version**: UX4G 3.4.0 (npm `ux4g-web-components@3.4.0`, CDN `UX4G@3.4.0`)
- **For installation**: `npm install ux4g-web-components` (unified package covering React, Angular, and Web Components)
- **For CDN usage**: Include the CSS and both JS files from `https://cdn.ux4g.gov.in/UX4G@3.4.0/` with their `integrity` and `crossorigin="anonymous"` attributes — no npm/build tools required
- **Existing Bootstrap or Tailwind sites**: add `data-ux4g-isolated` to `` and import the other framework into the `vendor` cascade layer
- **For Figma**: Point to the community file at `figma.com/community/file/1654976809099378421`
- **For Flutter**: `flutter pub add ux4g_flutter_components`
- **Theme support**: All components support light/dark themes automatically via design tokens
- **India-specific**: AadhaarInput supports 12-digit format validation, PANCardInput supports XXXXX0000X pattern
- **Languages**: 12 locales active at runtime (English + 11 Indic: Hindi, Bengali, Tamil, Telugu, Marathi, Gujarati, Kannada, Malayalam, Punjabi, Odia, Assamese); Urdu is translated but pending RTL styling
- **Accessibility widget**: Single-line CDN embed adds font sizing, contrast modes, and dyslexia-friendly fonts to any site