Skip to content

Commit 1bacc92

Browse files
committed
docs: update getting-started page
1 parent 202d767 commit 1bacc92

File tree

1 file changed

+124
-67
lines changed

1 file changed

+124
-67
lines changed

docs/src/guide/getting-started.md

Lines changed: 124 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ import LogosJavascript from '~icons/logos/javascript';
77
import LogosTypescript from '~icons/logos/typescript-icon';
88
</script>
99

10-
# Kickstart Your Journey with Vue Flow!
10+
# Getting Started
1111

12-
This guide covers the basics of setting up and using Vue Flow. You'll learn how to install Vue Flow, configure it, and
13-
utilize it within your own projects.
12+
This guide covers the basics of setting up and using Vue Flow.
13+
You'll learn how to install Vue Flow, configure it, and create your first flowchart.
1414

1515
## Prerequisites
1616

@@ -45,86 +45,118 @@ $ yarn add @vue-flow/core
4545

4646
## Usage
4747

48-
In Vue Flow, an application structure consists of [**nodes**](/typedocs/interfaces/Node)
49-
and [**edges**](/typedocs/types/Edge), all of which are categorised as [**elements**](/typedocs/types/Elements).
48+
In Vue Flow, a graph consists of [**nodes**](/typedocs/interfaces/Node)and [**edges**](/typedocs/types/Edge), all of which are categorised as [**elements**](/typedocs/types/Elements).
5049

51-
**Each element requires a unique id.**
50+
**Each node and edge requires a unique id.**
5251

53-
Nodes additionally need an [XY-position](/typedocs/interfaces/XYPosition), while edges require a source and a
54-
target, both represented by node ids.
52+
Nodes also need an [XY-position](/typedocs/interfaces/XYPosition), while edges require a `source` and a
53+
`target`, both represented by node ids.
5554

5655
::: warning NOTE!
5756
To ensure Vue Flow's is correctly displayed, make sure you include the necessary styles.
5857

58+
```css
59+
/* these are necessary styles for vue flow */
60+
@import '@vue-flow/core/dist/style.css';
61+
62+
/* this contains the default theme, these are optional styles */
63+
@import '@vue-flow/core/dist/theme-default.css';
64+
```
65+
5966
Refer to the [Theming](/guide/theming) section for additional information.
6067
:::
6168

62-
Here's a simple Vue Flow example to get you started:
69+
Here's a simple example to get you started:
6370

6471
::: code-group
6572

6673
```vue [<LogosJavascript />]
6774
<script setup>
75+
import { ref } from 'vue'
6876
import { VueFlow } from '@vue-flow/core'
6977
78+
// these components are only shown as examples of how to use a custom node or edge
79+
// you can find many examples of how to create these custom components in the examples page of the docs
7080
import SpecialNode from './components/SpecialNode.vue'
7181
import SpecialEdge from './components/SpecialEdge.vue'
7282
73-
const elements = ref([
74-
// nodes
75-
83+
// these are our nodes
84+
const nodes = ref([
7685
// an input node, specified by using `type: 'input'`
77-
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
86+
{
87+
id: '1',
88+
type: 'input',
89+
position: { x: 250, y: 5 },
90+
// all nodes can have a data object containing any data you want to pass to the node
91+
// a label can property can be used for default nodes
92+
data: { label: 'Node 1' },
93+
},
7894
7995
// default node, you can omit `type: 'default'` as it's the fallback type
80-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
96+
{
97+
id: '2',
98+
position: { x: 100, y: 100 },
99+
data: { label: 'Node 2' },
100+
},
81101
82102
// An output node, specified by using `type: 'output'`
83-
{ id: '3', type: 'output', label: 'Node 3', position: { x: 400, y: 200 } },
103+
{
104+
id: '3',
105+
type: 'output',
106+
position: { x: 400, y: 200 },
107+
data: { label: 'Node 3' },
108+
},
84109
85-
// A custom node, specified by using a custom type name
86-
// we choose `type: 'special'` for this example
110+
// this is a custom node
111+
// we set it by using a custom type name we choose, in this example `special`
112+
// the name can be freely chosen, there are no restrictions as long as it's a string
87113
{
88114
id: '4',
89-
type: 'special',
90-
label: 'Node 4',
115+
type: 'special', // <-- this is the custom node type name
91116
position: { x: 400, y: 200 },
92-
93-
// pass custom data to the node
94117
data: {
95-
// you can pass any data you want to the node
118+
label: 'Node 4',
96119
hello: 'world',
97120
},
98121
},
122+
])
99123
100-
// edges
101-
102-
// simple default bezier edge
103-
// consists of an id, source-id and target-id
104-
{ id: 'e1-3', source: '1', target: '3' },
124+
// these are our edges
125+
const edges = ref([
126+
// default bezier edge
127+
// consists of an edge id, source node id and target node id
128+
{
129+
id: 'e1->2',
130+
source: '1',
131+
target: '2',
132+
},
105133
106-
// an animated edge, specified by using `animated: true`
107-
{ id: 'e1-2', source: '1', target: '2', animated: true },
134+
// set `animated: true` to create an animated edge path
135+
{
136+
id: 'e2->3',
137+
source: '2',
138+
target: '3',
139+
animated: true,
140+
},
108141
109142
// a custom edge, specified by using a custom type name
110143
// we choose `type: 'special'` for this example
111144
{
112-
id: 'e1-4',
145+
id: 'e3->4',
113146
type: 'special',
114-
source: '1',
147+
source: '3',
115148
target: '4',
116149
117-
// pass custom data to the edge
150+
// all edges can have a data object containing any data you want to pass to the edge
118151
data: {
119-
// You can pass any data you want to the edge
120152
hello: 'world',
121153
}
122154
},
123155
])
124156
</script>
125157
126158
<template>
127-
<VueFlow v-model="elements">
159+
<VueFlow :nodes="nodes" :edges="edges">
128160
<!-- bind your custom node type to a component by using slots, slot names are always `node-<type>` -->
129161
<template #node-special="specialNodeProps">
130162
<SpecialNode v-bind="specialNodeProps" />
@@ -148,67 +180,92 @@ const elements = ref([
148180

149181
```vue [<LogosTypescript />]
150182
<script setup lang="ts">
151-
import type { Elements } from '@vue-flow/core'
183+
import { ref } from 'vue'
184+
import type { Node, Edge } from '@vue-flow/core'
152185
import { VueFlow } from '@vue-flow/core'
153186
187+
// these components are only shown as examples of how to use a custom node or edge
188+
// you can find many examples of how to create these custom components in the examples page of the docs
154189
import SpecialNode from './components/SpecialNode.vue'
155190
import SpecialEdge from './components/SpecialEdge.vue'
156191
157-
const elements = ref<Elements>([
158-
// nodes
159-
192+
// these are our nodes
193+
const nodes = ref<Node[]>([
160194
// an input node, specified by using `type: 'input'`
161-
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 5 } },
195+
{
196+
id: '1',
197+
type: 'input',
198+
position: { x: 250, y: 5 },
199+
// all nodes can have a data object containing any data you want to pass to the node
200+
// a label can property can be used for default nodes
201+
data: { label: 'Node 1' },
202+
},
162203
163204
// default node, you can omit `type: 'default'` as it's the fallback type
164-
{ id: '2', label: 'Node 2', position: { x: 100, y: 100 }, },
205+
{
206+
id: '2',
207+
position: { x: 100, y: 100 },
208+
data: { label: 'Node 2' },
209+
},
165210
166211
// An output node, specified by using `type: 'output'`
167-
{ id: '3', type: 'output', label: 'Node 3', position: { x: 400, y: 200 } },
168-
169-
// A custom node, specified by using a custom type name
170-
// we choose `type: 'special'` for this example
171-
{
172-
id: '4',
173-
type: 'special',
174-
label: 'Node 4',
212+
{
213+
id: '3',
214+
type: 'output',
175215
position: { x: 400, y: 200 },
216+
data: { label: 'Node 3' },
217+
},
176218
177-
// pass custom data to the node
219+
// this is a custom node
220+
// we set it by using a custom type name we choose, in this example `special`
221+
// the name can be freely chosen, there are no restrictions as long as it's a string
222+
{
223+
id: '4',
224+
type: 'special', // <-- this is the custom node type name
225+
position: { x: 400, y: 200 },
178226
data: {
179-
// you can pass any data you want to the node
227+
label: 'Node 4',
180228
hello: 'world',
181229
},
182-
},
230+
},
231+
])
232+
233+
// these are our edges
234+
const edges = ref<Edge[]>([
235+
// default bezier edge
236+
// consists of an edge id, source node id and target node id
237+
{
238+
id: 'e1->2',
239+
source: '1',
240+
target: '2',
241+
},
183242
184-
// edges
185-
186-
// simple default bezier edge
187-
// consists of an id, source-id and target-id
188-
{ id: 'e1-3', source: '1', target: '3' },
243+
// set `animated: true` to create an animated edge path
244+
{
245+
id: 'e2->3',
246+
source: '2',
247+
target: '3',
248+
animated: true,
249+
},
189250
190-
// an animated edge, specified by using `animated: true`
191-
{ id: 'e1-2', source: '1', target: '2', animated: true },
192-
193251
// a custom edge, specified by using a custom type name
194252
// we choose `type: 'special'` for this example
195-
{
196-
id: 'e1-4',
197-
type: 'special',
198-
source: '1',
253+
{
254+
id: 'e3->4',
255+
type: 'special',
256+
source: '3',
199257
target: '4',
200-
201-
// pass custom data to the edge
258+
259+
// all edges can have a data object containing any data you want to pass to the edge
202260
data: {
203-
// You can pass any data you want to the edge
204261
hello: 'world',
205262
}
206263
},
207264
])
208265
</script>
209266
210267
<template>
211-
<VueFlow v-model="elements">
268+
<VueFlow :nodes="nodes" :edges="edges">
212269
<!-- bind your custom node type to a component by using slots, slot names are always `node-<type>` -->
213270
<template #node-special="specialNodeProps">
214271
<SpecialNode v-bind="specialNodeProps" />

0 commit comments

Comments
 (0)