Skip to main content

SDK · React

Using TUX in React

Consume canonical TUX components, TypeScript definitions, and design tokens natively in React 18/19 and Next.js applications. Published to the Forgejo npm registry as @tti/tti-ux-react.
Standalone Zero-Vue Dependency Tree React 18 / 19

1. Installation

Configure your project .npmrc to resolve the @tti scope from the internal package registry:

.npmrc
@tti:registry=https://code.tti.tamu.edu/api/packages/tti/npm/

Install the package alongside React:

terminal
npm install @tti/tti-ux-react react react-dom

2. Quick Start Example

Import primitives, design token styles, and the useTuxTheme() hook directly into your components:

Dashboard.tsx
import React from "react";
import {
  TuxButton,
  TuxBadge,
  TuxAlert,
  TuxCard,
  TuxBigStat,
  useTuxTheme
} from "@tti/tti-ux-react";
import "@tti/tti-ux-react/styles.css"; // Canonical tokens + WCAG AAA reset

export default function Dashboard() {
  const { theme, toggleTheme } = useTuxTheme();

  return (
    <div className="p-8 space-y-6">
      <div className="flex justify-between items-center">
        <h1 className="text-2xl font-bold">Research Dashboard</h1>
        <TuxButton
          shape="sharp"
          intent="secondary"
          size="sm"
          onClick={toggleTheme}
        >
          Theme: {theme}
        </TuxButton>
      </div>

      <TuxAlert variant="info" title="System Status">
        All telemetry feeds are operating under WCAG 2.2 Level AAA compliance.
      </TuxAlert>

      <TuxCard padded>
        <div className="flex items-center justify-between">
          <TuxBigStat
            value="126"
            suffix="M"
            label="Annual research expenditure"
            tone="maroon"
          />
          <TuxBadge tier="restricted" variant="solid">Restricted</TuxBadge>
        </div>
      </TuxCard>
    </div>
  );
}

3. Theme Reactivity

TUX React components automatically respond to the data-theme attribute on <html> (tti, tti-dark, tti-hc).

The useTuxTheme() hook reads from and writes to localStorage with system-preference synchronization, ensuring persistent WCAG 2.2 Level AAA compliance across page reloads.

4. Ported Component Matrix

26 Native TSX Primitives with 100% Test Coverage

Click any component to open live playground