### Guide Path CSS Styling
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/paths.md
Provides CSS rules for styling the guide path overlay. This example sets the stroke color, width, dash array, and opacity for the guide path.
```css
.flow-guide-path {
stroke: var(--flow-accent);
stroke-width: 1;
stroke-dasharray: 4 4;
fill: none;
opacity: 0.4;
}
```
--------------------------------
### Install WireFlow
Source: https://github.com/getartisanflow/wireflow/blob/main/README.md
Install the WireFlow package and run the necessary artisan command to set up the components.
```bash
composer require getartisanflow/wireflow
php artisan wireflow:install
```
--------------------------------
### Build assets after installation
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/commands.md
After running the installation command, build your project's assets to reflect the changes.
```bash
npm run build
```
--------------------------------
### Install Dependencies and Build
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/addons/collab.md
Install the necessary peer dependencies and the AlpineFlow npm package, then rebuild the project.
```bash
npm install @getartisanflow/alpineflow yjs y-websocket y-protocols
npm run build
```
--------------------------------
### Full Example with Nodes and Edges
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/edges/styling.md
Defines nodes and edges with various status classes and marker ends, then renders them using a Blade component. This demonstrates a complete setup for a flow diagram.
```php
public array $nodes = [
['id' => 'a', 'position' => ['x' => 0, 'y' => 0], 'data' => ['label' => 'Success']],
['id' => 'b', 'position' => ['x' => 250, 'y' => 0], 'data' => ['label' => 'Warning']],
['id' => 'c', 'position' => ['x' => 500, 'y' => 0], 'data' => ['label' => 'Danger']],
['id' => 'd', 'position' => ['x' => 125, 'y' => 150], 'data' => ['label' => 'Info']],
['id' => 'e', 'position' => ['x' => 375, 'y' => 150], 'data' => ['label' => 'Primary']],
];
public array $edges = [
['id' => 'e1', 'source' => 'a', 'target' => 'd', 'class' => 'flow-edge-success', 'markerEnd' => 'arrowclosed'],
['id' => 'e2', 'source' => 'b', 'target' => 'd', 'class' => 'flow-edge-warning', 'markerEnd' => 'arrowclosed'],
['id' => 'e3', 'source' => 'b', 'target' => 'e', 'class' => 'flow-edge-danger', 'markerEnd' => 'arrowclosed'],
['id' => 'e4', 'source' => 'c', 'target' => 'e', 'class' => 'flow-edge-info', 'markerEnd' => 'arrowclosed'],
];
```
```blade
```
--------------------------------
### Quick Setup with Artisan Command
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/getting-started/installation.md
Run the Artisan command to automatically publish configuration, assets, and include necessary JS/CSS imports. This is the recommended setup method.
```bash
php artisan wireflow:install
npm run build
```
--------------------------------
### Interactive Demo Setup
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/server/patterns.md
This HTML and JavaScript setup demonstrates a simplified workflow canvas. It initializes nodes and edges, and includes basic controls for interacting with the workflow, such as an 'Approve Step' button.
```toolbar
Status: pending
```
```html
```
--------------------------------
### Install AlpineFlow and Layout Addons
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/addons/layouts.md
Install the core AlpineFlow package and any desired layout engine peer dependencies using npm.
```bash
npm install @getartisanflow/alpineflow
npm install @dagrejs/dagre # for dagre layout
npm install d3-force # for force-directed layout
npm install d3-hierarchy # for tree/cluster layout
npm install elkjs # for ELK layout engine
```
--------------------------------
### Install Whiteboard Addon
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/addons/whiteboard.md
Install the AlpineFlow npm package and register the whiteboard plugin. Rebuild your project after adding the import.
```bash
npm install @getartisanflow/alpineflow
```
```bash
npm run build
```
--------------------------------
### Install WireFlow with a Specific Theme
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/theming/themes.md
When installing WireFlow, you can specify a theme to be used. Remember to rebuild assets afterward.
```bash
php artisan wireflow:install --theme=flux
npm run build
```
--------------------------------
### Persistent Flow Component Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/server/events.md
A complete Livewire component example demonstrating how to persist node positions and handle connections, integrating with database models.
```php
nodes = FlowNode::all()->map(fn ($n) => [
'id' => (string) $n->id,
'position' => ['x' => $n->x, 'y' => $n->y],
'data' => ['label' => $n->label],
])->toArray();
$this->edges = FlowEdge::all()->map(fn ($e) => [
'id' => (string) $e->id,
'source' => (string) $e->source_id,
'target' => (string) $e->target_id,
])->toArray();
}
public function onNodeDragEnd(string $nodeId, array $position): void
{
FlowNode::where('id', $nodeId)->update([
'x' => $position['x'],
'y' => $position['y'],
]);
}
public function onConnect(string $source, string $target, ?string $sourceHandle, ?string $targetHandle): void
{
$edge = FlowEdge::create([
'source_id' => $source,
'target_id' => $target,
]);
$this->edges[] = [
'id' => (string) $edge->id,
'source' => $source,
'target' => $target,
];
}
public function onPaneClick(array $position): void
{
$this->flowDeselectAll();
}
public function render()
{
return view('livewire.persistent-flow');
}
}
```
```blade
{{-- resources/views/livewire/persistent-flow.blade.php --}}
```
--------------------------------
### Interactive Flow Canvas Demo
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/server/patterns.md
This example demonstrates sending particles along edges in a flow canvas upon a button click. It includes custom toolbar elements for interaction and a simplified flow setup.
```html
```
--------------------------------
### Follow Node with Options
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/camera.md
Starts following a node with customizable options for zoom level, camera smoothing speed, and padding around the node.
```php
$this->flowFollow('active-node', [
'zoom' => 1.5,
'speed' => 0.1,
'padding' => 80,
]);
```
--------------------------------
### Livewire Server Events for Node Resize
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/resizer.md
Provides examples of Livewire component methods that are triggered when a node resize operation starts (`onNodeResizeStart`) and ends (`onNodeResizeEnd`). These methods receive the node ID and its dimensions.
```php
public function onNodeResizeStart(string $nodeId, array $dimensions): void
{
// $dimensions = ['width' => float, 'height' => float]
}
public function onNodeResizeEnd(string $nodeId, array $dimensions): void
{
// Persist the new dimensions
}
```
--------------------------------
### Inspector Sidebar Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/canvas/panels.md
An example of an configured as a resizable inspector sidebar. It dynamically displays details of the currently selected node in the flow.
```blade
@if ($selectedNode)
@endif
```
--------------------------------
### Start Following a Node
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/camera.md
Initiates continuous camera tracking on a specified node. The camera will follow the node's position as it moves.
```php
$this->flowFollow('active-node');
```
--------------------------------
### Interactive Demo with Fit View Button
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/canvas/viewport.md
An interactive example demonstrating viewport control, including a button to fit the view with custom padding and duration.
```html
```
--------------------------------
### HTML Demo Canvas Setup
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/edges/animation.md
This HTML structure sets up a Wireflow canvas with nodes and edges, demonstrating different animation modes.
```html
```
--------------------------------
### Animated Path with Guide Overlay
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/paths.md
Displays a visible guide overlay for an SVG path during animation. The guide path can be styled and automatically removed upon animation completion.
```js
$flow.animate({
nodes: {
'n1': {
followPath: 'M 0 100 Q 200 0 400 100',
guidePath: {
visible: true,
class: 'my-guide',
autoRemove: true,
},
},
},
}, { duration: 2000 });
```
--------------------------------
### Basic Toolbar Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/toolbar.md
A basic implementation of the x-flow-toolbar within a flow canvas. It displays delete and edit buttons when a node is selected.
```html
```
--------------------------------
### Minimap Demo
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/canvas/minimap.md
A full example demonstrating the minimap functionality within a canvas component, including initial fit view and pannable/zoomable options.
```html
```
--------------------------------
### Import Core and Layout Addons in app.js
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/addons/layouts.md
Import the core AlpineFlow bundle and installed layout addons, then register them with Alpine.js.
```javascript
// resources/js/app.js
// Core from WireFlow vendor bundle
import AlpineFlow from '../../vendor/getartisanflow/wireflow/dist/alpineflow.bundle.esm.js';
// Layout addons from npm (only import what you installed)
import AlpineFlowDagre from '@getartisanflow/alpineflow/dagre';
import AlpineFlowForce from '@getartisanflow/alpineflow/force';
import AlpineFlowHierarchy from '@getartisanflow/alpineflow/hierarchy';
import AlpineFlowElk from '@getartisanflow/alpineflow/elk';
document.addEventListener('alpine:init', () => {
window.Alpine.plugin(AlpineFlow);
window.Alpine.plugin(AlpineFlowDagre);
window.Alpine.plugin(AlpineFlowForce);
window.Alpine.plugin(AlpineFlowHierarchy);
window.Alpine.plugin(AlpineFlowElk);
});
```
--------------------------------
### WireFlow Whiteboard Component Setup
Source: https://github.com/getartisanflow/wireflow/blob/main/resources/boost/skills/wireflow-development/SKILL.md
Configure the `` component with nodes, edges, and initial tool settings. Use `x-init` for scope injection and tool directives.
```blade
```
--------------------------------
### Context Menu Usage Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/context-menu.md
Shows how to implement context menus for nodes with options to delete or duplicate. Ensure the 'node' scope is used for node-specific actions.
```blade
```
--------------------------------
### Interactive Demo with x-flow-panel
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/canvas/panels.md
An interactive example showcasing an with custom styling and content within a dynamic flow canvas. This panel acts as an inspector.
```html
Inspector
Select a node to view details
```
--------------------------------
### Basic x-flow-handle Usage
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/handle.md
Illustrates the fundamental setup for a node with source and target handles using Blade syntax. Ensure the x-flow component is correctly configured.
```blade
```
--------------------------------
### Interactive Flow Canvas Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/connections/basics.md
Demonstrates an interactive WireFlow canvas with predefined nodes and an empty edge list. Configured for a static, non-interactive view.
```html
```
--------------------------------
### Toolbar Positioning and Alignment
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/toolbar.md
Demonstrates different positioning and alignment options for the toolbar. Includes examples for bottom-right alignment and left-side positioning with an offset.
```blade
{{-- Bottom-right aligned --}}
{{-- Left side with extra offset --}}
Settings
```
--------------------------------
### Interactive Demo with Resizable Nodes
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/nodes/resize.md
This is a full HTML example demonstrating resizable nodes within a flow canvas. It includes nodes with and without resizability enabled.
```html
```
--------------------------------
### Offset Positioning Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/context-menu.md
Shows how to apply custom offsets to the context menu's position relative to the cursor. This is useful for fine-tuning menu placement.
```blade
```
--------------------------------
### Install AlpineFlow npm Package
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/getting-started/installation.md
Install the AlpineFlow npm package to access addon sub-path imports. This is a prerequisite for installing specific addons.
```bash
npm install @getartisanflow/alpineflow
```
--------------------------------
### Combining Focus and Follow in Livewire
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/camera.md
This method demonstrates a common pattern where the camera is first focused on a node and then immediately starts following it, providing a smooth transition for tracking.
```php
flowFocusNode($id, duration: 400);
// Then start following
$this->flowFollow($id, [
'zoom' => 1.3,
'speed' => 0.1,
]);
}
```
--------------------------------
### Install Addon Peer Dependencies
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/getting-started/installation.md
Install the necessary peer dependencies for various WireFlow addons, such as layout engines or collaboration tools. Install only what you need.
```bash
npm install @dagrejs/dagre # for dagre layout
npm install d3-force # for force-directed layout
npm install d3-hierarchy # for tree/cluster layout
npm install elkjs # for ELK layout engine
npm install yjs y-websocket y-protocols # for real-time collaboration
# whiteboard has no peer deps
```
--------------------------------
### Install WireFlow via Composer
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/getting-started/installation.md
Use Composer to add the WireFlow package to your Laravel project. This is the primary installation method.
```bash
composer require getartisanflow/wireflow
```
--------------------------------
### Interactive Flow Canvas Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/getting-started/first-flow.md
An example of an interactive flow canvas using Alpine.js. It initializes with predefined nodes and edges, and enables zooming and panning.
```html
```
--------------------------------
### Legend Panel Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/canvas/panels.md
A static example used to display a legend for node types or statuses within the flow. It's positioned in the top-left corner.
```blade
Legend
Blue = Active
Gray = Inactive
```
--------------------------------
### Bidirectional Marker Configuration
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/edges/markers.md
Apply different markers to both the start and end of an edge. The end marker is configured with a specific color, while the start marker uses the default 'arrow' type.
```php
[
'id' => 'e1',
'source' => 'a',
'target' => 'b',
'markerStart' => 'arrow',
'markerEnd' => [
'type' => 'arrowclosed',
'color' => '#3b82f6',
],
]
```
--------------------------------
### Interactive Flow Canvas Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/nodes/basics.md
An example of an interactive WireFlow canvas using Alpine.js. It initializes with predefined nodes and edges, and configures canvas behavior like background, zooming, and panning.
```html
```
--------------------------------
### Interactive Demo: Update and Animate Nodes
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/basics.md
This example demonstrates instant updates with `flowUpdate()` and smooth animations with `flowAnimate()` using buttons to control node positions. It initializes two nodes and uses Alpine.js directives to manage click events and flow interactions.
```html
```
--------------------------------
### Interactive Flow Canvas Example
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/handles/positions.md
An interactive example showcasing a simple flow canvas with two nodes and an edge. It demonstrates the visual representation of nodes with default source and target handles.
```html
```
--------------------------------
### Interactive Camera Control Demo
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/animation/camera.md
This demo showcases various camera control functionalities including focusing on specific nodes, following a node, and fitting the entire view. It requires buttons to trigger these actions.
```html
```
--------------------------------
### Usage Example with Interactive Content
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/drag-handle.md
This example shows how to use x-flow-drag-handle within a node template to ensure that only the title area is draggable, while other interactive elements like buttons remain functional without initiating a drag.
```blade
```
--------------------------------
### Override Panel Z-Index
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/theming/css-variables.md
Example of how to override the default z-index for panels to place them above controls.
```css
.flow-panel {
z-index: 15; /* put panels above controls */
}
```
--------------------------------
### Use the x-flow component in Blade
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/commands.md
Example of how to integrate the WireFlow component into your Blade views to display nodes and edges.
```blade
```
--------------------------------
### Batch Collapse/Expand Operations
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/nodes/groups.md
These Blade examples demonstrate how to use the `` component with the `:all="true"` prop to trigger collapse or expand actions on all collapsible nodes within the flow. Options for instant expansion are also shown.
```blade
Collapse AllExpand AllExpand All (Instant)
```
--------------------------------
### Usage with Node Slot
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/toolbar.md
Integrating the x-flow-toolbar within the node slot of a component. This example shows delete and duplicate actions.
```blade
```
--------------------------------
### Interactive Demo with Markers
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/edges/markers.md
Demonstrates the use of 'arrow' for markerStart and 'arrowclosed' for markerEnd on an edge within an interactive Wireflow canvas.
```html
```
--------------------------------
### Server-Side Loading Control with Livewire
Source: https://github.com/getartisanflow/wireflow/blob/main/docs/components/loading.md
Illustrates how to control the loading overlay state from a Livewire component using the `WithWireFlow` trait's `flowSetLoading` method.
```php
$this->flowSetLoading(true); // Show loading overlay
$this->flowSetLoading(false); // Hide loading overlay
```