@ttoss/ui
React component library built on Theme UI for building consistent, accessible user interfaces with design token integration.
Installation
pnpm add @ttoss/ui @ttoss/react-icons @emotion/react
ESM Only: This package requires ES modules support.
Quick Start
1. Setup Theme Provider
import { ThemeProvider } from '@ttoss/ui';
import { BruttalTheme } from '@ttoss/theme/Bruttal';
export const App = () => (
<ThemeProvider theme={BruttalTheme}>
<YourAppContent />
</ThemeProvider>
);
2. Use Components
import { Flex, Text, Button, Box } from '@ttoss/ui';
export const Example = () => (
<Box sx={{ padding: 'lg' }}>
<Text variant="heading">Welcome</Text>
<Flex sx={{ gap: 'md', flexDirection: 'column' }}>
<Button variant="primary">Get Started</Button>
<Text>
Access [design
tokens](https://ttoss.dev/docs/design/design-system/design-tokens) via
the `sx` prop
</Text>
</Flex>
</Box>
);
3. Custom Themes (Optional)
import type { Theme } from '@ttoss/ui';
export const customTheme: Theme = {
colors: {
primary: '#007acc',
background: '#ffffff',
text: '#000000',
},
};
Note: No custom JSX pragma needed when using sx
prop directly on library components.
Available Components
Browse all components: Storybook Documentation
Layout & Structure
Box
- Basic container with styling capabilitiesFlex
- Flexbox container for flexible layoutsGrid
- CSS Grid container for complex layoutsContainer
- Centered container with max-widthStack
- Vertical/horizontal stack layoutsDivider
- Visual content separatorsCard
- Content containers with styling
Typography
Text
- Text display with variantsHeading
- Heading elements (h1-h6)Paragraph
- Paragraph text blocksLink
- Styled anchor elementsLabel
- Form labels
Form Controls
Button
- Interactive buttons with variantsActionButton
- Action-specific buttonsIconButton
- Icon-only buttonsCloseButton
- Close/dismiss buttonsInput
- Text input fieldsInputNumber
- Numeric input fieldsInputPassword
- Password input with revealTextarea
- Multi-line text inputSelect
- Dropdown selectionCheckbox
- Checkbox controlsRadio
- Radio button controlsSwitch
- Toggle switchesSlider
- Range slider controlsSegmentedControl
- Multi-option selector
Feedback & Status
Badge
- Status indicators and labelsTag
- Tagging and categorizationSpinner
- Loading indicatorsLinearProgress
- Progress barsInfiniteLinearProgress
- Indeterminate progressTooltip
- Contextual help textHelpText
- Form help and validation text
Media
Image
- Responsive image component
Advanced Features
Global Styles
Theme-aware global CSS using Emotion:
import { Global } from '@ttoss/ui';
export const AppStyles = () => (
<Global
styles={{
body: {
margin: 0,
fontFamily: 'body',
backgroundColor: 'background',
},
}}
/>
);
Animations
import { Box, keyframes } from '@ttoss/ui';
const fadeIn = keyframes({
from: { opacity: 0 },
to: { opacity: 1 },
});
export const AnimatedBox = () => (
<Box sx={{ animation: `${fadeIn} 1s ease-in` }}>Animated content</Box>
);
Theme Access
import { useTheme } from '@ttoss/ui';
export const CustomComponent = () => {
const { theme } = useTheme();
const primaryColor = theme.colors.primary;
return <div style={{ color: primaryColor }}>Themed content</div>;
};
Integration
- Design System: Part of the ttoss Design System
- Theme Integration: Uses semantic tokens
- Accessibility: Built-in WCAG compliance
- TypeScript: Full type safety with Theme UI integration
Related Packages
- @ttoss/theme: Pre-built themes (Bruttal, Oca)
- @ttoss/components: Higher-level composed components
- @ttoss/react-icons: Icon library integration