Shared UI component library for Teja applications
npm install @teja-app/uiShared UI component library for Teja applications.
``bash`
bun add @teja-app/ui
`ts
// tailwind.config.js
import tejaPreset from '@teja-app/ui/tailwind';
export default {
presets: [tejaPreset],
content: [
"./src/*/.{js,ts,jsx,tsx}",
"./node_modules/@teja-app/ui/dist/*/.{js,mjs}",
],
theme: {
extend: {
// App-specific overrides
},
},
};
`
`tsx
import { Button, Input, Modal } from '@teja-app/ui';
import { cn } from '@teja-app/ui/utils';
function App() {
return (
);
}
`
All components follow these principles:
Each component is self-contained with its own styles, types, and logic. No hidden dependencies between components. Import individually or as a bundle.
`tsx
// Individual import
import { Button } from '@teja-app/ui';
// Bundle import
import { Button, Input, Modal } from '@teja-app/ui';
`
All components accept standard HTML attributes via spread props, support className for style overrides, and use forwardRef for DOM access.
`tsx`
className="my-custom-class"
data-testid="submit-btn"
aria-label="Submit form"
{...otherProps}
>
Submit
Components use composition over inheritance. No hard-coded values - everything is configurable via props or Tailwind classes.
`tsx
// Compose with children
// Override with className
`
`tsx
// Slot pattern for complex components
// Polymorphic components
`
Each app can extend the preset and override specific tokens:
`ts
// tailwind.config.js
import tejaPreset from '@teja-app/ui/tailwind';
export default {
presets: [tejaPreset],
theme: {
extend: {
colors: {
brand: {
primary: '#0ea5e9', // Override for portal
},
},
},
},
};
`
Access individual tokens for custom configurations:
`ts`
import { colors, fontFamily, spacing } from '@teja-app/ui/tailwind';
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| variant | 'primary' \| 'secondary' \| 'ghost' \| 'danger' | 'primary' | Visual style |size
| | 'sm' \| 'md' \| 'lg' | 'md' | Button size |loading
| | boolean | false | Show loading spinner |disabled
| | boolean | false | Disable button |className
| | string | - | Additional CSS classes |
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| error | string | - | Error message |label
| | string | - | Input label |className
| | string` | - | Additional CSS classes |
See CONTRIBUTING.md for guidelines on adding new components.