Usage
Learn how to use ReacUI components effectively in your React projects
Basic Usage
After installing ReacUI, you can start importing and using components in your React application. All components are exported from the main package entry point.
Hello World
This is a simple card component with custom content.
Tip
All ReacUI components are built to be fully compatible with React Server Components in Next.js. For client-side interactivity, some components will need to be used within client components.
Component Props
ReacUI components accept standardized props for consistency. Most components share common props like className, disabled, and variant.
Button Component
Button Variants
Button Sizes
Button States
Input Component
Basic Inputs
Password is required
Input with Icon
Form Group
Each component's documentation page provides a complete list of available props. In general, ReacUI components are designed to feel familiar if you've used other React component libraries.
Styling Components
ReacUI is built with Tailwind CSS, making it easy to customize components using Tailwind classes. You can pass Tailwind classes via the className prop to override default styles.
Theme Customization
For global styling changes, you can customize your Tailwind config to match your brand colors. ReacUI will automatically use these colors:
Common Patterns
Here are some common patterns and component combinations that you'll find useful:
Layout Containers
Data Display
Notifications and Alerts
Conditional Rendering
Conditional Rendering Preview
Loading State
isLoading === trueEmpty State
No profile found
user === nullUser Profile
Jane Doe
jane@example.com
user providedWorking with Forms
ReacUI provides form components that work well together and are easy to integrate with form libraries like React Hook Form or Formik.
React Hook Form Integration
ReacUI components work seamlessly with React Hook Form. Here's how to use them together:
Advanced Usage
Composition Patterns
ReacUI components are designed to be composable. You can combine them in various ways to create complex UIs:
Component Composition Preview
Navigation
Dashboard Overview
Total Users
8,249
Revenue
$23,432
Conversion
3.6%
Recent Users
| Name | Status | |
|---|---|---|
| John Smith | john@example.com | Active |
| Alice Johnson | alice@example.com | Active |
| Robert Brown | robert@example.com | Inactive |
Best Practices
Use Consistent Patterns
Maintain consistency in your UI by using the same component variants and sizes for similar actions throughout your application.
Follow Accessibility Guidelines
Always include proper labels, aria attributes, and ensure keyboard navigation works correctly. ReacUI handles most of this for you, but always test your implementation.
Create Component Compositions
Instead of building complex components from scratch, compose existing components together to create new UIs. This maintains consistency and reduces code duplication.
Optimize for Performance
For large lists or complex UIs, use virtualization, pagination, and other performance optimization techniques. Consider code-splitting to reduce initial bundle size.
Common Pitfalls to Avoid
- Overriding Too Many Styles
Instead of heavily customizing components with inline styles or className overrides, consider creating your own component wrappers or extending the theme.
- Ignoring Mobile Responsiveness
Always test your UI on different screen sizes and ensure it's fully responsive. Use responsive utilities provided by Tailwind for adaptable layouts.
- Missing Feedback States
Always provide appropriate feedback for user actions. Use loading states, success/error messages, and transitions to create a polished user experience.