![]() |
VOOZH | about |
dotnet add package Miko.Razor.Compiler --version 0.0.13
NuGet\Install-Package Miko.Razor.Compiler -Version 0.0.13
<PackageReference Include="Miko.Razor.Compiler" Version="0.0.13">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageVersion Include="Miko.Razor.Compiler" Version="0.0.13" />Directory.Packages.props
<PackageReference Include="Miko.Razor.Compiler"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>Project file
paket add Miko.Razor.Compiler --version 0.0.13
#r "nuget: Miko.Razor.Compiler, 0.0.13"
#:package Miko.Razor.Compiler@0.0.13
#addin nuget:?package=Miko.Razor.Compiler&version=0.0.13Install as a Cake Addin
#tool nuget:?package=Miko.Razor.Compiler&version=0.0.13Install as a Cake Tool
Miko is a native, cross-platform UI rendering engine for .NET that uses Razor as its layout DSL. It draws every pixel itself with SkiaSharp â no browser, no WebView, no HTML/CSS runtime â running a browser-like pipeline of style cascade, layout, and incremental painting directly onto a GPU-accelerated canvas.
You write your UI in Razor components â the same .razor syntax you already know from
Blazor â and Miko's source generator compiles them into native draw calls. If you know
HTML and Razor, you already know how to build a Miko app; there is no XAML to learn.
Razor components ââš Miko source generator ââš native SkiaSharp rendering
.razor component and see the change without restarting.â ïļ Miko is an experimental project under active development. APIs may change between versions.
vs. Electron / WebView-based UIs
vs. .NET MAUI
.razor components with routing,
layouts, data binding, and hot reload; a source generator compiles them ahead of
time into native draw calls.div, span, p, h1âh6, button, input, select,
img, lists, and tables.| Package | Description |
|---|---|
Miko |
Core rendering engine: DOM, styling, layout, and painting. |
Miko.Bootstrap |
Bootstrap-style Razor component library and styles. |
Miko.DevTools |
Runtime debugging tools for the DOM and layout tree. |
Miko.Razor.Compiler |
Source generator that compiles .razor components and routes. |
Miko.Templates |
dotnet new templates for scaffolding Miko apps. |
The fastest way to start is the Razor app template:
# Install the templates
dotnet new install Miko.Templates
# Scaffold and run a new app
dotnet new miko-razor -o MyApp
cd MyApp
dotnet run
A window opens showing the home page (Pages/Home.razor). Add a page by dropping a new
.razor file with a @page directive into Pages/ â routes are discovered automatically.
Both templates accept a --layout option to scaffold a starting UI. The default is blank;
tabs and sidemenu scaffold Ionic-based layouts (and add the Miko.Ionic package):
dotnet new miko-razor --layout blank -o MyApp # empty page (default)
dotnet new miko-razor --layout tabs -o MyApp # Ionic bottom tab bar, 3 routed tabs
dotnet new miko-razor --layout sidemenu -o MyApp # Ionic side-menu drawer over a page
For a cross-platform app (Desktop + Android + iOS), use the multiplatform template instead:
# Scaffold a shared app plus Desktop / Android / iOS startup projects
dotnet new miko-multiplatform -o MyApp
cd MyApp
# Run on the desktop
dotnet run --project MyApp.Desktop
@page "/about"
@namespace MyApp.Pages
<h1>About</h1>
<p>Hello from Miko!</p>
The app is configured with a fluent builder:
using Miko.Hosting;
var builder = MikoAppBuilder.CreateDefault();
builder.UseTitle("My App");
builder.UseSize(1024, 768);
builder.UseGeneratedRoutes(); // routes from .razor @page directives
builder.UseDefaultLayout<MainLayout>();
builder.EnableHotReload();
var app = builder.Build();
app.Run();
You don't need Razor â you can build the DOM and render a frame by hand. The example below renders a small tree to a PNG:
using Miko.Core;
using Miko.Core.DomElements;
using Miko.Styling;
using Miko.Styling.Selectors;
using Miko.Common;
using SkiaSharp;
// 1. Define a stylesheet
var styleSheet = new StyleSheet();
styleSheet.AddRule(new ClassSelector("container"), new Style
{
Display = Display.Flex,
FlexDirection = FlexDirection.Column,
Padding = new Padding(Length.Px(20)),
BackgroundColor = new Color(245, 245, 245)
});
// 2. Build the DOM tree
var root = new DivElement { Class = "container" };
root.AddChild(new H1Element { TextContent = "Hello Miko" });
root.AddChild(new ParagraphElement { TextContent = "A lightweight rendering engine." });
// 3. Render to a Skia canvas
using var surface = SKSurface.Create(new SKImageInfo(800, 600));
var canvas = surface.Canvas;
canvas.Clear(SKColors.White);
var engine = new MikoEngine();
engine.Initialize(root, new List<StyleSheet> { styleSheet }, canvas, 800, 600);
// 4. Export the frame
using var image = surface.Snapshot();
using var data = image.Encode(SKEncodedImageFormat.Png, 100);
using var stream = File.OpenWrite("output.png");
data.SaveTo(stream);
For interactive scenes, mutate the DOM and repaint only what changed:
element.TextContent = "Updated text";
engine.InvalidateElement(element);
engine.Update(canvas); // incremental render of dirty regions only
Miko mirrors a browser's rendering pipeline:
1. DOM construction â build an Element tree in code
2. Style computation â StyleResolver matches selectors and cascades styles
3. Layout tree build â filter elements by their display property
4. Layout â constraints flow down, sizes flow up
5. Paint â RenderEngine draws to an SKCanvas (dirty-region optimized)
| Layer | Responsibility |
|---|---|
| Core | Element tree and MikoEngine, which coordinates layout and rendering. |
| Styling | Stylesheets, selectors, the cascade, and computed styles. |
| Layout | The box model plus block, inline, and flex layout algorithms. |
| Rendering | RenderEngine, the SkiaSharp Painter, and the dirty-region manager. |
| Fonts | Font registration, fallback resolution, and text measurement. |
| Events | DOM-style event dispatch with capture and bubbling. |
Style cascade order (lowest to highest precedence): Tag â Class â ID â inline.
See for the full design and for a developer-oriented walkthrough.
# Clone
git clone https://github.com/chaldea/miko.git
cd miko
# Build the solution
dotnet build miko.slnx
# Run the tests
dotnet test
The repository also contains runnable samples under , including Console, WinUI, and Android launchers.
Contributions are welcome! Please open an issue to discuss substantial changes before sending a pull request. When contributing:
.editorconfig is enforced).dotnet build and dotnet test pass.Miko is released under the .
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.