Node

A composable node component for Vue Flow-based canvases with Card-based styling.

The Node component provides a composable, Card-based node for Vue Flow canvases. It includes support for connection handles, structured layouts, and consistent styling using shadcn/vue components.

Install using CLI

AI Elements Vue
shadcn-vue CLI
npx ai-elements-vue@latest add node

Install Manually

Copy and paste the following code in the same folder.

Node.vue
NodeHeader.vue
NodeTitle.vue
NodeDescription.vue
NodeAction.vue
NodeContent.vue
NodeFooter.vue
index.ts
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import Card from '@repo/shadcn-vue/components/ui/card/Card.vue'
import { cn } from '@repo/shadcn-vue/lib/utils'
import { Handle, Position } from '@vue-flow/core'
import { reactiveOmit } from '@vueuse/core'

interface NodeHandles {
  target?: boolean
  source?: boolean
}

interface NodeProps {
  class?: HTMLAttributes['class']
  handles?: NodeHandles
}

const props = defineProps<NodeProps>()
const delegatedProps = reactiveOmit(props, 'class')
</script>

<template>
  <Card
    v-bind="delegatedProps"
    :class="cn('node-container relative size-full h-auto w-sm gap-0 rounded-md p-0', props.class)"
  >
    <Handle v-if="props.handles?.target" :position="Position.Left" type="target" />
    <Handle v-if="props.handles?.source" :position="Position.Right" type="source" />
    <slot />
  </Card>
</template>

Features

  • Built on shadcn/vue Card components for consistent styling
  • Automatic handle placement (left for target, right for source)
  • Composable sub-components (Header, Title, Description, Action, Content, Footer)
  • Semantic structure for organizing node information
  • Pre-styled sections with borders and backgrounds
  • Responsive sizing with fixed small width
  • Full TypeScript support with proper type definitions
  • Compatible with Vue Flow's node system

Props

<Node />

classstring
''
Additional CSS classes to apply to the node.
handles{ target: boolean; source: boolean; }
Configuration for connection handles. Target renders on the left, source on the right.

<NodeHeader />

classstring
''
Additional CSS classes to apply to the header.

<NodeTitle />

This component does not accept any props.

<NodeDescription />

This component does not accept any props.

<NodeAction />

This component does not accept any props.

<NodeContent />

classstring
''
Additional CSS classes to apply to the content.

<NodeFooter />

classstring
''
Additional CSS classes to apply to the footer.