Giter VIP home page Giter VIP logo

vue-tree-view's Introduction

Vue tree view

A tree view component for Vue 3.

๐Ÿš€ Installation

Install using your package manager of choice:

yarn add vue-tree-view

๐Ÿ“บ Demo

https://matija-components.vercel.app/tree-view

โš™๏ธ Usage

Import the component locally or define it globally and include the css file:

<template>
  <div style="display: flex">
    <tree-view
      color="blue"
      :items="treeViewItems"
      v-model="treeViewSelection"
      dense
      open-all
    />
    {{ treeViewSelection.sort() }}
  </div>
</template>

<script lang="ts" setup>
import { ref } from "vue";
import { TreeView } from "vue-tree-view";
import "vue-tree-view/dist/style.css";

const treeViewItems = [
  {
    id: 1,
    name: "ID 1",
    children: [
      { id: 2, name: "ID 2" },
      { id: 3, name: "ID 3" },
      { id: 4, name: "ID 4" }
    ]
  },
  {
    id: 5,
    name: "ID 5",
    children: [
      {
        id: 6,
        name: "ID 6",
        children: [
          {
            id: 7,
            name: "ID 7",
            children: [
              { id: 8, name: "ID 8" },
              { id: 9, name: "ID 9" }
            ]
          }
        ]
      },
      {
        id: 10,
        name: "ID 10",
        children: [
          {
            id: 11,
            name: "ID 11",
            children: [
              { id: 12, name: "ID 12" },
              { id: 13, name: "ID 13" },
              { id: 14, name: "ID 14" }
            ]
          }
        ]
      }
    ]
  }
];

const treeViewSelection = ref([]);
</script>

๐Ÿ“ƒ Props

Name Type Default Description
v-model number[] Standard two way input
dense boolean false Changes the style of the component to a more compact design
open-all boolean false All nodes will be opened on component load
disabled boolean false Makes the component uninteractable
selectable boolean true Allows the user to select nodes
unopenable boolean false Prevents the user from opening and closing the nodes
selection-mode independent or leaf leaf Changes the way selection is handled, leaf selects all of the children if clicking on a parent, independent selects a node without triggering any others
color string #7e7ec2 Color of the active checkboxes
items NodeItem [] Items used by the tree view, every item must be defined with an id for a value and name for a label, the children property is optional

vue-tree-view's People

Contributors

dependabot[bot] avatar matijanovosel avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

vue-tree-view's Issues

Multiple tree views don't work

I have 3 treeviews on the same page with 3 arrays for each of the results and all 3 arrays are being populated whenever I select an option on any of the tree views. It would be much easier to work with if only the array set as the v-model on a particular tree view component was updated when the user selected an option.

Changes in v-model values are not reflected

when the model value is changed in javascript, the tree will not change and is still original status.


<script setup> let treeViewSelection = ref([]); function test() { treeViewSelection.value = [] }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.