Composables System
Composables are the heart of Vuetify Zero. They provide reusable, composable logic that can be used directly or through wrapper components. Understanding the composable system is key to mastering v0.What Are Composables?
In Vue 3, composables are functions that use Vue’s Composition API to encapsulate and reuse stateful logic:Composable Categories
Vuetify Zero’s composables are organized into categories by function:Foundation
Core factories that create other composables:Registration
Collection management primitives:Selection
State management for selection patterns:Forms
Form state and validation:Reactivity
Reactive proxy utilities:Plugins
App-level features installable viaapp.use():
Data
Data manipulation utilities:System
Browser APIs and observers:Transformers
Data transformation utilities:Usage Patterns
Direct Factory Call
For standalone instances in a single component:Context Injection
For sharing state across component trees:Plugin Installation
For app-wide singletons:Trinity Pattern
Most complex composables export a trinity:Composing Composables
Composables are designed to work together:Advanced Patterns
Custom Composable with Registry
Extend the registry system:Adapter Pattern
Many plugin composables use adapters for flexibility:Batch Operations
Optimize bulk operations with batching:Conditional Reactivity
UseuseToggleScope for conditional effects:
TypeScript Integration
All composables are fully typed with generic support:Performance Considerations
Minimal Reactivity
v0 uses minimal reactivity by default:Selection State is Always Reactive
Common Use Cases
- Tab Title
- Tab Title
- Tab Title
- Tab Title
Best Practices
Choose the right composable
Choose the right composable
Match the composable to your use case:
- Single selection →
createSingle - Multi-selection →
createSelectionorcreateGroup - Navigation →
createStep - Form validation →
createForm - Design tokens →
createTokens
Use context for shared state
Use context for shared state
Prefer composition over extension
Prefer composition over extension
Combine composables instead of extending them:
Clean up when needed
Clean up when needed
Most composables clean up automatically, but be explicit when necessary:
Summary
Vuetify Zero’s composable system provides:- Foundation - Core factories for building composables
- Registry - Enhanced Map for collection management
- Selection - Specialized selection patterns
- Plugins - App-wide features
- Utilities - Data manipulation and browser APIs
- Composition - Combine composables for complex behavior
- Type Safety - Full TypeScript support
- Performance - Minimal reactivity and lazy evaluation