docs.rs failed to build cocoanut-0.2.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
🥥 Cocoanut
A minimal, declarative macOS GUI framework for Rust.
Why Cocoanut?
| Crate | Level | Safety | Learning Curve | Best For |
|---|---|---|---|---|
| objc | Low | Unsafe | Steep | Raw FFI |
| cocoa | Low | Unsafe | Steep | Raw AppKit |
| cacao | Mid | Safe | Medium | Cross-platform |
| cocoanut | High | Safe | Gentle | macOS native |
Quick Start
use *;
Architecture
10 source files. ~3500 lines. 32 view types. 29 tests. Type-safe APIs.
view.rs → View + ViewKind enum (the ONE core type)
renderer.rs → View tree → AppKit NSViews (single pass)
app.rs → App lifecycle + Appearance (dark mode)
event.rs → Callback registry + ObjC action handler
state.rs → Reactive State<T> + bind_label
menu.rs → Menu bar with action dispatch
layout.rs → Auto Layout support (NSLayoutConstraint)
native.rs → Native view properties & utilities
delegate.rs → Delegate patterns for native controls
error.rs → Error types
32 View Types
- Layout: VStack, HStack, ZStack, Spacer
- Text: Text, Label
- Controls: Button, TextField, SecureField, Checkbox, Radio, Slider, Toggle, Dropdown
- Extended: TextArea, DatePicker, ColorPicker
- Containers: ScrollView, TabView, SplitView, GroupBox, WebView, TableView
- Data: ProgressBar, Image
- Native Controls: SegmentedControl, ComboBox, SearchField, Stepper, LevelIndicator, PathControl
- Extensible: Custom
Features
Core Features
- Reactive State —
State<T>withon_changelisteners - Event System —
event::register(id, closure)+ ObjC target/action dispatch - Dark Mode —
.dark()/.light()/set_appearance()at runtime - Accessibility —
.accessibility("label")on any view - Menu Actions —
MenuItem::on_action(id)wires to callbacks - Style Modifiers —
.width(),.bold(),.background(),.on_click() - JSON Serializable —
ViewDescfor debugging/bridging
Native Cocoa Integration
- Auto Layout — NSLayoutConstraint support with type-safe API
- Native Properties — Direct access to shadows, layers, corner radius, opacity
- Responder Chain — First responder management and key view navigation
- Delegate Patterns — TableView data sources, TextField delegates
- Animation Support — Native AppKit animations
- Pasteboard — Clipboard operations (copy/paste)
- Window Management — Window level, alpha, background color
See NATIVE_COCOA_IMPROVEMENTS.md for detailed documentation.
Examples
License
Apache-2.0