Skip to main content

UI Components

Shared React component library used across all frontend applications.

๐Ÿ“ฆ Package: @bitrate/ui-reactโ€‹

Reusable UI components built with React 19, TypeScript, Base UI, Tailwind v4, and shadcn-style owned source.

๐Ÿš€ Installationโ€‹

# In your app
pnpm add @bitrate/ui-react

# Development
cd packages/ui-react
pnpm install

๐Ÿ—๏ธ Architectureโ€‹

packages/ui-react/
โ”œโ”€โ”€ assets/ # Raw source art โ€” not shipped, consumed at build time
โ”‚ โ”œโ”€โ”€ icons/ # SVG sources the svgr plugin compiles
โ”‚ โ””โ”€โ”€ images/ # Raster assets used by stories (@assets/images/...)
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ components/ui/ # React components
โ”‚ โ”‚ โ”œโ”€โ”€ button/
โ”‚ โ”‚ โ”œโ”€โ”€ input/
โ”‚ โ”‚ โ”œโ”€โ”€ form/
โ”‚ โ”‚ โ””โ”€โ”€ ...
โ”‚ โ”œโ”€โ”€ icons/ # Icon components
โ”‚ โ”‚ โ””โ”€โ”€ svgr/ # Generated from assets/icons/
โ”‚ โ”œโ”€โ”€ lib/ # Utilities
โ”‚ โ”œโ”€โ”€ styles/ # Hand-written Tailwind @theme layers โ€” the token source
โ”‚ โ”‚ โ”œโ”€โ”€ palette.css
โ”‚ โ”‚ โ”œโ”€โ”€ layout.css
โ”‚ โ”‚ โ”œโ”€โ”€ typography.css
โ”‚ โ”‚ โ”œโ”€โ”€ themes.css # Barrel โ€” imports only, no colours of its own
โ”‚ โ”‚ โ”œโ”€โ”€ themes/ # base.css, global/*.css, one components/*.css per component
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ base.css
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ global/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ components/
โ”‚ โ”‚ โ””โ”€โ”€ index.css
โ”‚ โ””โ”€โ”€ index.ts # Public API
โ”œโ”€โ”€ vitest.config.ts # Unit, integration, snapshot, screenshot projects
โ”œโ”€โ”€ components.json # shadcn CLI configuration
โ”œโ”€โ”€ dist/ # ESM, CJS, and declarations
โ””โ”€โ”€ package.json

๐ŸŽจ Componentsโ€‹

Buttonโ€‹

import { Button } from '@bitrate/ui-react'

<Button variant="primary" size="lg" onClick={handleClick}>
Click me
</Button>

// Variants include default, primary, secondary, outline, ghost, destructive
// Sizes: default, sm, lg, icon

Inputโ€‹

import { Input } from '@bitrate/ui-react'

<Input
type="text"
placeholder="Enter text..."
value={value}
onChange={(event) => setValue(event.target.value)}
/>

Form primitivesโ€‹

import { Form, Input, Label } from '@bitrate/ui-react'

<Form {...form}>
<Label htmlFor="email">Email</Label>
<Input id="email" {...form.register('email')} />
</Form>

Iconsโ€‹

import { MusicIcon, PlayIcon } from '@bitrate/ui-react'

<MusicIcon className="size-6" />
<PlayIcon className="size-8" />

๐Ÿ› ๏ธ Developmentโ€‹

Buildโ€‹

# Build all formats
pnpm build

# Watch mode
pnpm dev

Generate Iconsโ€‹

# SVG generation also runs during the package build
pnpm build

๐Ÿ“ Usage in Appsโ€‹

Next.js (Web)โ€‹

// app/layout.tsx
import '@bitrate/ui-react/themes.css'

// components/MyComponent.tsx
import { Button } from '@bitrate/ui-react'

Tauri (Desktop)โ€‹

import { Button } from '@bitrate/ui-react'

๐ŸŽจ Themingโ€‹

Design tokens are hand-written Tailwind v4 @theme layers under src/styles/: palette.css for raw colours, layout.css and typography.css for the scales, and the themes.css barrel importing one part-file per semantic role group โ€” base.css, global/*.css, and one components/*.css per component (or per component family). Each part carries both the default dark declarations and its :root.light overrides. There is no generator: the CSS is the source. Components consume the resulting Tailwind utilities instead of hardcoded colours.

The design/Palette and design/Theme Storybook pages parse those stylesheets at build time through src/styles/token-docs.ts, so they list exactly what the CSS declares โ€” a role added to a part-file shows up without anyone editing a story. Use the theme toggle in the Storybook toolbar to view any story against :root.light.

๐Ÿงช Testingโ€‹

pnpm test
pnpm test:unit
pnpm test:int
pnpm test:snapshot
pnpm test:screenshot
pnpm test:cov

Screenshot tests run in Chromium through Vitest Browser Mode and Playwright.

๐Ÿ“š Storybookโ€‹

# Start Storybook
pnpm storybook

# Build static
pnpm storybook:build

Related: