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: