blinc_layout
Part of the Blinc UI Framework
This crate is a component of Blinc, a GPU-accelerated UI framework for Rust. For full documentation and guides, visit the Blinc documentation.
Flexbox layout engine for Blinc UI, powered by Taffy.
Overview
blinc_layout provides a declarative, builder-style API for constructing UI layouts. It combines Taffy's flexbox implementation with a rich set of interactive elements and rendering capabilities.
Features
- Flexbox Layout: Full CSS Flexbox support via Taffy
- Builder API: Chainable, GPUI-style element construction
- Rich Text: Markdown rendering, syntax highlighting, text selection
- Interactive Elements: Buttons, checkboxes, text inputs, scroll containers
- Media: Images, SVGs with lazy loading support
- Materials: Glass, blur, and other visual effects
- Animations: Entry/exit motion animations
- Overlays: Modals, dialogs, tooltips, toasts
Quick Start
use *;
Elements
Container Elements
// Div - basic container
div.w.h.bg
// Stack - overlay children on top of each other
stack
.child
.child
// Scroll - scrollable container
scroll
.h
.child
Text Elements
// Basic text
text.size.color
// Rich text with markdown
rich_text
// Code with syntax highlighting
code.language
Media Elements
// Image with object-fit
img
.size
.cover
.rounded
.border
// SVG icon
svg
.size
.color
// Lazy-loaded image
img
.lazy
.placeholder_color
Interactive Elements
// Button
button
.on_click
// Text input
text_input
.placeholder
.on_change
// Checkbox
checkbox
.checked
.on_change
// Text area
text_area
.rows
.placeholder
Layout Properties
div
// Size
.w.h // Fixed size
.w_full.h_full // 100% of parent
.min_w.max_w // Constraints
// Flexbox
.flex_row // Row direction
.flex_col // Column direction
.flex_wrap // Allow wrapping
.gap // Gap between children
.justify_center // Main axis alignment
.items_center // Cross axis alignment
// Spacing
.p // Padding all sides
.px.py // Horizontal/vertical
.m // Margin all sides
// Positioning
.relative // Position relative
.absolute // Position absolute
.top.left // Offsets
Styling
div
// Background
.bg
.bg_gradient
// Border
.border
.border_radius
.rounded // Shorthand
// Shadow
.shadow
// Materials
.glass
// Opacity
.opacity
Event Handling
div
.on_click
.on_hover
.on_mouse_down
.on_key_down
Animations
// Entry animation
div
.motion
// Exit animation
div
.motion
// Spring physics
div
.motion
Architecture
blinc_layout
├── div.rs # Div element and ElementBuilder trait
├── text.rs # Text elements
├── image.rs # Image elements
├── svg.rs # SVG elements
├── canvas.rs # Custom canvas drawing
├── scroll.rs # Scroll containers
├── button.rs # Button widget
├── input.rs # Text input widgets
├── checkbox.rs # Checkbox widget
├── renderer.rs # Layout tree rendering
├── tree.rs # Layout tree structure
├── events.rs # Event routing
└── motion.rs # Animation system
License
MIT OR Apache-2.0