Available Components
Yazi’s UI consists of these overrideable components:Component Structure
UI components follow this pattern:Required Methods
new(area, ...)- Constructor, receives area and contextredraw()- Returns UI elements to renderreflow()- Returns list of components for layout (optional)
Optional Methods
click(event, up)- Handle mouse clicksscroll(event, step)- Handle mouse scrolltouch(event, step)- Handle touch events
Creating a Custom Status Bar
Let’s create a custom status bar with a different layout.1
Create the component file
Create
~/.config/yazi/plugins/components/my-status.lua:2
Add content methods
Define what to show:
3
Implement redraw
Combine elements:
4
Load the component
In
~/.config/yazi/init.lua:Customizing the Status Component
You can add custom elements to existing components:Real Example: Enhanced Status Bar
Here’s a complete example from Yazi’s preset:Customizing Entity (File) Rendering
TheEntity component controls how individual files are displayed:
UI Elements
Line
Container for inline content:Span
Styled text segment:Text
Multi-line text:List
Vertical list of lines:Table
Tabular data:Styling
Colors
Attributes
Using Theme Styles
Mouse Events
Best Practices
Cache computed values
Cache computed values
Don’t recalculate on every redraw:
Check for nil safely
Check for nil safely
Always validate before accessing:
Use theme colors
Use theme colors
Reference theme instead of hardcoding:
Next Steps
Functional Plugins
Add new commands and behaviors
Previewers
Create custom file previewers