webf-native-ui-dev
Develop custom native UI libraries based on Flutter widgets for WebF. Create reusable component libraries that wrap Flutter widgets as web-accessible custom elements. Use when building UI libraries, wrapping Flutter packages, or creating native component systems.
Install
mkdir -p .claude/skills/webf-native-ui-dev && curl -L -o skill.zip "https://mcp.directory/api/skills/download/5286" && unzip -o skill.zip -d .claude/skills/webf-native-ui-dev && rm skill.zipInstalls to .claude/skills/webf-native-ui-dev
About this skill
WebF Native UI Development
Want to create your own native UI library for WebF by wrapping Flutter widgets? This skill guides you through the complete process of building custom native UI libraries that make Flutter widgets accessible from JavaScript/TypeScript with React and Vue support.
What is Native UI Development?
Native UI development in WebF means:
- Wrapping Flutter widgets as WebF custom elements
- Bridging native Flutter UI to web technologies (HTML/JavaScript)
- Creating reusable component libraries that work with React, Vue, and vanilla JavaScript
- Publishing npm packages with type-safe TypeScript definitions
When to Create a Native UI Library
Use Cases:
- ✅ You want to expose Flutter widgets to web developers
- ✅ You need to wrap a Flutter package for WebF use
- ✅ You're building a design system with native performance
- ✅ You want to create platform-specific components (iOS, Android, etc.)
- ✅ You need custom widgets beyond HTML/CSS capabilities
Don't Create a Native UI Library When:
- ❌ HTML/CSS can achieve the same result (use standard web)
- ❌ You just need to use existing UI libraries (see
webf-native-uiskill) - ❌ You're building a one-off component (use WebF widget element directly)
Architecture Overview
A native UI library consists of three layers:
┌─────────────────────────────────────────┐
│ JavaScript/TypeScript (React/Vue) │ ← Generated by CLI
│ @openwebf/my-component-lib │
├─────────────────────────────────────────┤
│ TypeScript Definitions (.d.ts) │ ← You write this
│ Component interfaces and events │
├─────────────────────────────────────────┤
│ Dart (Flutter) │ ← You write this
│ Flutter widget wrappers │
│ my_component_lib package │
└─────────────────────────────────────────┘
Development Workflow
Overview
# 1. Create Flutter package with Dart wrappers
# 2. Write TypeScript definition files
# 3. Generate React/Vue components with WebF CLI
# 4. Test and publish
webf codegen my-ui-lib --flutter-package-src=./flutter_package
Step-by-Step Guide
Step 1: Create Flutter Package Structure
Create a standard Flutter package:
# Create Flutter package
flutter create --template=package my_component_lib
cd my_component_lib
Directory structure:
my_component_lib/
├── lib/
│ ├── my_component_lib.dart # Main export file
│ └── src/
│ ├── button.dart # Dart widget wrapper
│ ├── button.d.ts # TypeScript definitions
│ ├── input.dart
│ └── input.d.ts
├── pubspec.yaml
└── README.md
pubspec.yaml dependencies:
dependencies:
flutter:
sdk: flutter
webf: ^0.24.0 # Latest WebF version
Step 2: Write Dart Widget Wrappers
Create a Dart class that wraps your Flutter widget:
Example: lib/src/button.dart
import 'package:flutter/widgets.dart';
import 'package:webf/webf.dart';
import 'button_bindings_generated.dart'; // Will be generated by CLI
/// Custom button component wrapping Flutter widgets
class MyCustomButton extends MyCustomButtonBindings {
MyCustomButton(super.context);
// Internal state
String _variant = 'filled';
bool _disabled = false;
// Property getters/setters (implement interface from bindings)
@override
String get variant => _variant;
@override
set variant(String value) {
_variant = value;
// Trigger rebuild when property changes
setState(() {});
}
@override
bool get disabled => _disabled;
@override
set disabled(bool value) {
_disabled = value;
setState(() {});
}
@override
WebFWidgetElementState createState() {
return MyCustomButtonState(this);
}
}
class MyCustomButtonState extends WebFWidgetElementState {
MyCustomButtonState(super.widgetElement);
@override
MyCustomButton get widgetElement => super.widgetElement as MyCustomButton;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: widgetElement.disabled ? null : () {
// Dispatch click event to JavaScript
widgetElement.dispatchEvent(Event('click'));
},
child: Container(
padding: EdgeInsets.all(12),
decoration: BoxDecoration(
color: _getBackgroundColor(),
borderRadius: BorderRadius.circular(8),
),
child: Text(
// Get text from child nodes
widgetElement.getTextContent() ?? 'Button',
style: TextStyle(
color: widgetElement.disabled ? Colors.grey : Colors.white,
),
),
),
);
}
Color _getBackgroundColor() {
if (widgetElement.disabled) return Colors.grey[400]!;
switch (widgetElement.variant) {
case 'filled':
return Colors.blue;
case 'outlined':
return Colors.transparent;
default:
return Colors.blue;
}
}
}
Step 3: Write TypeScript Definitions
Create a .d.ts file alongside your Dart file:
Example: lib/src/button.d.ts
/**
* Custom button component with multiple variants.
*/
/**
* Properties for <my-custom-button>.
*/
interface MyCustomButtonProperties {
/**
* Button variant style.
* Supported values: 'filled' | 'outlined' | 'text'
* @default 'filled'
*/
variant?: string;
/**
* Whether the button is disabled.
* @default false
*/
disabled?: boolean;
}
/**
* Events for <my-custom-button>.
*/
interface MyCustomButtonEvents {
/**
* Fired when the button is clicked.
*/
click: Event;
}
TypeScript Guidelines:
- Interface names must end with
PropertiesorEvents - Use
?for optional properties (except booleans, which are always non-nullable in Dart) - Use
CustomEvent<T>for events with data - Add JSDoc comments for documentation
- See the TypeScript Definition Guide for more details
Step 4: Create Main Export File
lib/my_component_lib.dart:
library my_component_lib;
import 'package:webf/webf.dart';
import 'src/button.dart';
export 'src/button.dart';
/// Install all components in this library
void installMyComponentLib() {
// Register custom elements
WebFController.defineCustomElement(
'my-custom-button',
(context) => MyCustomButton(context),
);
// Add more components here
// WebFController.defineCustomElement('my-custom-input', ...);
}
Step 5: Generate React/Vue Components
Use the WebF CLI to generate JavaScript/TypeScript components:
# Install WebF CLI globally (if not already installed)
npm install -g @openwebf/webf-cli
# Generate TypeScript bindings and React/Vue components
webf codegen my-ui-lib-react \
--flutter-package-src=./my_component_lib \
--framework=react
webf codegen my-ui-lib-vue \
--flutter-package-src=./my_component_lib \
--framework=vue
What the CLI does:
- ✅ Parses your
.d.tsfiles - ✅ Generates Dart binding classes (
*_bindings_generated.dart) - ✅ Creates React components with proper TypeScript types
- ✅ Creates Vue components with TypeScript support
- ✅ Copies
.d.tsfiles to output directory - ✅ Creates
package.jsonwith correct metadata - ✅ Runs
npm run buildif a build script exists
Generated output structure:
my-ui-lib-react/
├── src/
│ ├── MyCustomButton.tsx # React component
│ └── index.ts # Main export
├── dist/ # Built files (after npm run build)
├── package.json
├── tsconfig.json
└── README.md
Step 6: Test Your Components
Test in Flutter App
In your Flutter app's main.dart:
import 'package:my_component_lib/my_component_lib.dart';
void main() {
WebFControllerManager.instance.initialize(WebFControllerManagerConfig(
maxAliveInstances: 2,
maxAttachedInstances: 1,
));
// Install your component library
installMyComponentLib();
runApp(MyApp());
}
Test in JavaScript/TypeScript
React example:
import { MyCustomButton } from '@openwebf/my-ui-lib-react';
function App() {
return (
<div>
<MyCustomButton
variant="filled"
onClick={() => console.log('Clicked!')}
>
Click Me
</MyCustomButton>
</div>
);
}
Vue example:
<template>
<div>
<MyCustomButton
variant="filled"
@click="handleClick"
>
Click Me
</MyCustomButton>
</div>
</template>
<script setup>
import { MyCustomButton } from '@openwebf/my-ui-lib-vue';
const handleClick = () => {
console.log('Clicked!');
};
</script>
Step 7: Publish Your Library
Publish Flutter Package
# In Flutter package directory
flutter pub publish
# Or for private packages
flutter pub publish --server=https://your-private-registry.com
Publish npm Packages
# Automatic publishing with CLI
webf codegen my-ui-lib-react \
--flutter-package-src=./my_component_lib \
--framework=react \
--publish-to-npm
# Or manual publishing
cd my-ui-lib-react
npm publish
For custom npm registry:
webf codegen my-ui-lib-react \
--flutter-package-src=./my_component_lib \
--framework=react \
--publish-to-npm \
--npm-registry=https://registry.your-company.com/
Advanced Patterns
1. Handling Complex Properties
TypeScript:
interface MyComplexWidgetProperties {
// JSON string properties for complex data
items?: string; // Will be JSON.parse() in Dart
// Enum-like values
alignment?: 'left' | 'center' | 'right';
// Numeric properties
maxLength?: number;
opacity?: number;
}
Dart:
@override
set items(String? value) {
if (value != null) {
try {
final List<dynamic> parsed = jsonDecode(value);
_items = parsed.cast<Map<String, dynamic>>();
setState(() {});
} catch (e) {
print('Error parsing items: $e');
}
}
}
2.
Content truncated.
More by openwebf
View all skills by openwebf →You might also like
flutter-development
aj-geddes
Build beautiful cross-platform mobile apps with Flutter and Dart. Covers widgets, state management with Provider/BLoC, navigation, API integration, and material design.
drawio-diagrams-enhanced
jgtolentino
Create professional draw.io (diagrams.net) diagrams in XML format (.drawio files) with integrated PMP/PMBOK methodologies, extensive visual asset libraries, and industry-standard professional templates. Use this skill when users ask to create flowcharts, swimlane diagrams, cross-functional flowcharts, org charts, network diagrams, UML diagrams, BPMN, project management diagrams (WBS, Gantt, PERT, RACI), risk matrices, stakeholder maps, or any other visual diagram in draw.io format. This skill includes access to custom shape libraries for icons, clipart, and professional symbols.
ui-ux-pro-max
nextlevelbuilder
"UI/UX design intelligence. 50 styles, 21 palettes, 50 font pairings, 20 charts, 8 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, mobile app, .html, .tsx, .vue, .svelte. Elements: button, modal, navbar, sidebar, card, table, form, chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, flat design. Topics: color palette, accessibility, animation, layout, typography, font pairing, spacing, hover, shadow, gradient."
godot
bfollington
This skill should be used when working on Godot Engine projects. It provides specialized knowledge of Godot's file formats (.gd, .tscn, .tres), architecture patterns (component-based, signal-driven, resource-based), common pitfalls, validation tools, code templates, and CLI workflows. The `godot` command is available for running the game, validating scripts, importing resources, and exporting builds. Use this skill for tasks involving Godot game development, debugging scene/resource files, implementing game systems, or creating new Godot components.
nano-banana-pro
garg-aayush
Generate and edit images using Google's Nano Banana Pro (Gemini 3 Pro Image) API. Use when the user asks to generate, create, edit, modify, change, alter, or update images. Also use when user references an existing image file and asks to modify it in any way (e.g., "modify this image", "change the background", "replace X with Y"). Supports both text-to-image generation and image-to-image editing with configurable resolution (1K default, 2K, or 4K for high resolution). DO NOT read the image file first - use this skill directly with the --input-image parameter.
fastapi-templates
wshobson
Create production-ready FastAPI projects with async patterns, dependency injection, and comprehensive error handling. Use when building new FastAPI applications or setting up backend API projects.
Related MCP Servers
Browse all serversEffortlessly create 25+ chart types with MCP Server Chart. Visualize complex datasets using TypeScript and AntV for powe
Streamline billing with Paddle API tools. Manage products, prices, and subscriptions efficiently—an alternative to Strip
macOS Tools offers system monitoring and advanced file search with tagging on macOS, using SQLite for historical data an
Streamline Jira Cloud integration and workflows using a modular, TypeScript-based MCP server featuring key Jira API capa
Use Honeycomb to manage datasets and events with a TypeScript-based interface, offering an alternative to Datadog API an
TypeScript REST API ecommerce API, customer data API and orders API — retrieve customers, search by name, and lookup ord
Stay ahead of the MCP ecosystem
Get weekly updates on new skills and servers.