Component Library
The BookWish component library provides a comprehensive set of reusable UI components built with Flutter. These components follow our brand guidelines and are designed to create consistent, accessible, and delightful user experiences.
Overview
Our component library is organized into distinct categories based on functionality and usage patterns. Each component is designed with flexibility in mind while maintaining consistency across the application.
All components:
- Follow BookWish brand guidelines
- Support the Parchment background theme
- Use the dual typography system (Merriweather for book content, system fonts for UI)
- Include proper accessibility support
- Maintain consistent spacing and visual rhythm
Component Categories
Primitives
Core building blocks used throughout the application:
- Buttons - Primary, secondary, and text button variants
- Text Fields - Input fields with validation states
- Chips - Compact elements for tags, filters, and metadata
- Cards - Content containers with consistent styling
- Avatars - User profile images in various sizes
- Toggles - Switches and toggleable controls
- Loading Indicators - Progress feedback
- Rating - Star-based rating display and input
Book Components
Specialized components for book-related content:
- Book Card - Grid display of books with cover images
- Book List Tile - List view of books with metadata
- Book Mini Chip - Compact book reference with thumbnail
Social Components
Components for community and social features:
- Review Card - User reviews with ratings and interactions
- Line Card - Shared quotes and passages from books
- User Chip - User profile chips with avatars
- Like Button - Animated like/unlike interactions
- Follow Button - Follow/unfollow user controls
Store Components
Components for independent bookstore features:
- Store Chip - Store identification and branding
- Inventory Item Tile - Book inventory listings with pricing
- Wishlist Item Tile - User wishlist items with status
Reading Components
Components for reading tracking and book clubs:
- Club Card - Book club information and membership
- Challenge Card - Reading challenge progress and details
- Notification Tile - Activity notifications
Typography
Components use the dual typography system defined in the BookWish design system:
- Merriweather (serif) - Book titles, author names, quotes, literary content
- System fonts - UI elements, buttons, labels, navigation
Text Styles
| Style | Font | Size | Weight | Usage |
|---|---|---|---|---|
bookTitle | Merriweather | 17pt | 600 | Book titles |
author | Merriweather | 14pt | 400 | Author names |
heading | System | 20pt | 600 | Section headers |
label | System | 16pt | 500 | UI labels, buttons |
body | System | 16pt | 400 | Body text |
caption | System | 12pt | 400 | Metadata, timestamps |
See Design Tokens for full details.
Design Principles
Consistency
Components maintain visual consistency through:
- Unified Color Palette: All components use colors from the brand palette
- Standard Spacing: 4px base unit for spacing (4, 8, 12, 16, 24)
- Consistent Border Radius: 12px for cards and containers, 24px for buttons, 16px for chips
- Elevation System: 2-level shadow system for depth
- Typography System: Merriweather for book content, system fonts for UI
Accessibility
Every component is designed with accessibility in mind:
- Color Contrast: Minimum WCAG AA compliance (4.5:1 for text)
- Touch Targets: Minimum 44x44 points for interactive elements
- Semantic Structure: Proper use of Flutter semantics
- Keyboard Navigation: Support for non-touch interaction
- Screen Reader Support: Descriptive labels and hints
Responsiveness
Components adapt to different screen sizes:
- Flexible Layouts: Use of Expanded, Flexible widgets
- Adaptive Sizing: Text scales with system font settings
- Orientation Support: Components work in portrait and landscape
- Safe Areas: Respect device safe areas and notches
Component Structure
Each component follows a consistent structure:
class ComponentName extends StatelessWidget {
// Required properties
final RequiredType requiredProp;
// Optional properties with defaults
final OptionalType? optionalProp;
final VoidCallback? onTap;
const ComponentName({
super.key,
required this.requiredProp,
this.optionalProp,
this.onTap,
});
Widget build(BuildContext context) {
// Component implementation
}
}
Using Components
Import Pattern
import 'package:bookwish/ui/components/component_name.dart';
import 'package:bookwish/config/theme.dart';
Theme Integration
All components automatically use the app theme:
// Colors from theme
Theme.of(context).colorScheme.primary
Theme.of(context).colorScheme.surface
// Or direct from AppColors
AppColors.inkBlue
AppColors.parchment
AppColors.amberStar
Typography Integration
Use AppTypography for consistent text styling:
// For book content
Text(book.title, style: AppTypography.bookTitle)
Text(book.author, style: AppTypography.author)
// For UI elements
Text(label, style: AppTypography.label)
Text(description, style: AppTypography.body)