Light themes
Dark themes

Make your own

React

The same 108 components as typed React components, over the same stylesheet and the same behaviours.

Where it is

The package is called trayui-react, and it is on npm. It needs react and react-dom; the charts also need recharts.

Terminal
npm install trayui-react

Its source is the system/react folder of the repository.

Use it

React
import { Button, Card, Field, Input } from 'trayui-react';
import 'trayui-react/styles.css';

export function OrderForm() {
  return (
    <Card title="Order a jar">
      <Field label="Delivery address">
        <Input autoComplete="street-address" />
      </Field>
      <Button type="submit">Order a jar</Button>
    </Card>
  );
}
  • styles.css carries the tokens, every component style and the font. No provider or wrapper is needed.
  • Each component renders the markup and the classes of its plain-HTML original, so a page built in React and a page built by hand look the same.
  • Props are typed and documented; variants are named after the modifiers of the classes (variant="quiet", size="sm").
  • Components wire their own behaviour. Never write data-tray attributes by hand in React: use the component.
  • Icons are Lucide's. The 118 built into the system go by name, typed: <Icon name="truck" />, <Button icon="truck">. Any other one comes from react-icons/lu as an element, wherever a component takes an icon: <Button icon={<LuRocket />}>. See Icons.

Charts

Charts in React are drawn by Recharts and come from an entry of their own, trayui-react/charts, so the rest of the package does not depend on a chart library. Install recharts next to the package and import from there:

React
import { Chart, ChartContainer, ChartTooltip } from 'trayui-react/charts';

Chart is the ready-made component for the six usual forms; ChartContainer and the parts around it are for a Recharts chart you compose yourself. Charts has 58 examples to copy, and Using the charts explains the parts.

What it does not have yet

The page layouts added for the blocks (the shell and sidebar variants, the screen frame) are in the stylesheet, so their classes work in React, but the components have no props for them yet, and the blocks exist as plain HTML only.

↑↓ to moveEnter to openEsc to close