@tachui/mobile
v0.11.7
Published
Mobile UI components for TachUI - Modal components (ActionSheet, Alert) and enhanced scrolling (ScrollView) with mobile optimizations
Downloads
912
Maintainers
Readme
@tachui/mobile
Mobile UI components for tachUI framework
Overview
The tachUI mobile package provides essential mobile UI components and interaction patterns. Currently focused on core modal components with plans for expanded mobile functionality in future releases.
Current Features (v0.8.8-alpha)
- 📱 Core Modal Components - ActionSheet and Alert with full modal system
- 🎨 Native Feel - iOS and Android design system compatibility
- 🔄 Smooth Animations - 60fps transitions and micro-interactions
- 📐 Responsive Design - Adapts to different screen sizes and orientations
- 🔧 TypeScript-first - Complete type safety for mobile patterns
- ♿ Accessibility - Full ARIA support and keyboard navigation
Roadmap (Future Releases)
- 👆 Touch Interactions - Swipe actions, pull-to-refresh, and gesture handling
- 📱 Advanced Components - Modal presentations, SafeArea support
- 🎯 Platform Adaptations - iOS/Android specific variants
- 📳 Haptic Feedback - Native-like touch feedback
- 🎭 Gesture System - Advanced gesture recognition
Installation
npm install @tachui/core @tachui/mobile
# or
pnpm add @tachui/core @tachui/mobileQuick Start
ActionSheet
ActionSheet is a component driven by an isPresented signal — there is no
useActionSheet hook. ActionSheetUtils builds the common shapes for you.
import { createSignal } from '@tachui/core'
import { Button, VStack } from '@tachui/primitives'
import { ActionSheet, ActionSheetUtils } from '@tachui/mobile'
const MyComponent = () => {
const [isPresented, setPresented] = createSignal(false)
return VStack({
children: [
Button('Show Options', () => setPresented(true)).padding(16),
ActionSheet({
isPresented,
title: 'Choose an action',
message: 'What would you like to do?',
// `buttons`, and each one needs a `label` and an `onPress`.
buttons: [
{ label: 'Share', onPress: () => share() },
{ label: 'Edit', onPress: () => edit() },
{ label: 'Delete', role: 'destructive', onPress: () => remove() },
{ label: 'Cancel', role: 'cancel', onPress: () => {} },
],
}),
],
})
}Alert
Same shape — a component, not a hook. AlertUtils covers confirmation and
destructive patterns.
import { createSignal } from '@tachui/core'
import { Button, VStack } from '@tachui/primitives'
import { Alert, AlertUtils } from '@tachui/mobile'
const MyComponent = () => {
const [isPresented, setPresented] = createSignal(false)
return VStack({
children: [
Button('Delete Item', () => setPresented(true))
.backgroundColor('#ff3b30')
.foregroundColor('white'),
Alert({
isPresented,
title: 'Confirm Action',
message: 'Are you sure you want to delete this item?',
// Alert buttons differ from ActionSheet's: `title`, and the callback
// is `action`.
buttons: [
{ title: 'Cancel', role: 'cancel' },
{ title: 'Delete', role: 'destructive', action: () => remove() },
],
}),
],
})
}Implemented Components
✅ ActionSheet
Bottom sheet with multiple action options:
import { ActionSheet } from '@tachui/mobile'
ActionSheet({
title: 'Photo Options',
message: 'Choose how to add a photo',
actions: [
{ title: 'Camera', role: 'default', onPress: () => openCamera() },
{ title: 'Photo Library', role: 'default', onPress: () => openLibrary() },
{ title: 'Cancel', role: 'cancel' },
],
presentationStyle: 'sheet', // 'sheet' | 'popover' | 'adaptive'
})✅ Alert
Modal alerts with customizable buttons:
import { Alert } from '@tachui/mobile'
Alert({
title: 'Network Error',
message: 'Unable to connect to the server. Please check your connection.',
buttons: [
{ title: 'Retry', role: 'default', action: () => retryConnection() },
{ title: 'Cancel', role: 'cancel' },
],
isPresented: createSignal(true),
})Planned Components (Future Releases)
🚧 SwipeActions
Swipe-to-reveal action buttons:
// Planned for v0.2.0
import { SwipeActions, SwipeAction } from '@tachui/mobile'
SwipeActions({
content: ListRow({ title: 'John Doe', subtitle: '[email protected]' }),
leadingActions: [
SwipeAction({
title: 'Mark Read',
backgroundColor: '#007AFF',
icon: 'envelope.open.fill',
action: () => markAsRead(),
}),
],
trailingActions: [
SwipeAction({
title: 'Archive',
backgroundColor: '#FF9500',
icon: 'archivebox.fill',
action: () => archive(),
}),
SwipeAction({
title: 'Delete',
backgroundColor: '#FF3B30',
icon: 'trash.fill',
action: () => deleteItem(),
}),
],
})🚧 PullToRefresh
Pull-down-to-refresh functionality:
// Planned for v0.2.0
import { PullToRefresh } from '@tachui/mobile'
import { ScrollView } from '@tachui/primitives'
PullToRefresh({
onRefresh: async () => {
await loadNewData()
},
content: ScrollView({
children: [
// Your content here
],
}),
})Advanced Patterns (Implemented)
✅ Modal System
Both ActionSheet and Alert provide full modal systems with:
- Backdrop dismissal
- Keyboard navigation
- Focus management
- Animation coordination
- Accessibility support
✅ Utility Functions
import { ActionSheetUtils, AlertUtils } from '@tachui/mobile'
// Pre-configured action sheets
const deleteConfirmation = ActionSheetUtils.deleteConfirmation(
'Delete Item',
() => deleteItem(),
() => console.log('Cancelled')
)
// Pre-configured alerts
const confirmAlert = AlertUtils.confirm(
'Confirm Action',
'Are you sure?',
() => performAction(),
() => console.log('Cancelled')
)Advanced Patterns (Planned for Future Releases)
🚧 Modal Presentation System
// Planned for v0.2.0
import { presentModal, dismissModal } from '@tachui/mobile'
const presentSettings = () => {
presentModal({
content: SettingsView(),
presentationStyle: 'sheet', // 'sheet' | 'fullscreen' | 'popover'
detents: [.medium(), .large()], // iOS-style sheet sizing
dismissible: true,
onDismiss: () => console.log('Modal dismissed')
})
}🚧 Haptic Feedback
// Planned for v0.2.0
import { hapticFeedback } from '@tachui/mobile'
Button('Success Action', () => {
// Perform action
hapticFeedback('success') // 'success' | 'error' | 'warning' | 'light' | 'medium' | 'heavy'
})🚧 SafeArea Support
// Planned for v0.2.0
import { SafeAreaView } from '@tachui/mobile'
const app = SafeAreaView({
children: [
// Your app content
],
})
.backgroundColor('#ffffff')
🚧 Gesture Handling
// Planned for v0.2.0
import { GestureRecognizer } from '@tachui/mobile'
GestureRecognizer({
content: MyView(),
gestures: {
tap: {
action: () => console.log('Tapped'),
numberOfTapsRequired: 1,
},
longPress: {
action: () => console.log('Long pressed'),
minimumPressDuration: 0.5,
},
swipe: {
direction: 'left',
action: () => console.log('Swiped left'),
},
},
})Platform Adaptations (Planned for Future Releases)
🚧 iOS-style Components
// Planned for v0.3.0
import { IOSActionSheet, IOSAlert } from '@tachui/mobile'
// iOS-specific styling and behavior
IOSActionSheet({
title: 'Options',
actions: actions,
})
.iosStyle(true)
🚧 Android-style Components
// Planned for v0.3.0
import { MaterialActionSheet, MaterialAlert } from '@tachui/mobile'
// Material Design styling
MaterialActionSheet({
title: 'Choose action',
actions: actions,
})
.materialStyle(true)
🚧 Animation and Transitions (planned)
createMobileTransition is not implemented; this is the intended shape.
import { createMobileTransition } from '@tachui/mobile'
const slideUpTransition = createMobileTransition({
type: 'slide',
direction: 'up',
duration: 0.3,
easing: 'ease-out',
})
ActionSheet({ actions })
.presentationTransition(slideUpTransition)
Touch and Gesture Optimization
Built-in mobile optimizations:
- Touch targets - Minimum 44pt touch areas
- Scroll momentum - Native-like scrolling behavior
- Bounce effects - Elastic scrolling boundaries
- Gesture conflicts - Automatic gesture precedence handling
- Performance - 60fps animations on mobile devices
Accessibility
Mobile accessibility features:
- VoiceOver/TalkBack support
- Dynamic Type scaling for text
- Reduce Motion preference handling
- High Contrast mode support
- Voice Control compatibility
Examples
Check out complete examples:
API Reference
Current Status
Version 0.8.8-alpha - Core modal components (ActionSheet, Alert)
- ✅ ActionSheet: Full implementation with animations, accessibility, responsive design
- ✅ Alert: Complete modal system with reactive support and keyboard navigation
- 🚧 Future Releases: SwipeActions, PullToRefresh, Modal system, Haptic feedback, Gesture handling
Requirements
- @tachui/core ^0.8.8-alpha or later
- TypeScript 5.0+ (recommended)
Contributing
See the main Contributing Guide for information on contributing to tachUI mobile patterns.
License
Mozilla Public License 2.0 - see LICENSE for details.
