Customization

Vue Finder provides some options to customize its look.

CSS classes

You can pass CSS classes to each item component by setting cssClass:

<Finder :tree="tree" />
const tree = {
  id: "root",
  children: [
    {
      id: "fruits",
      label: "Fruits",
      cssClass: "my-item fruits",
      children: [
        { id: "apple", label: "Apple" },
        // ...
      ],
    },
    {
      id: "vegetables",
      label: "Vegetables",
      cssClass: "my-item vegetables",
      children: [
        { id: "bean", label: "Beans" },
        // ...
      ],
    },
  ],
};

Theming

The Finder component accepts a theme prop that allows to customize some CSS properties:

<Finder :tree="tree" :theme="theme" />
// ...
data() {
  return {
    theme: {
      primaryColor: "#0b79d0",
      arrowColor: "black",
      separatorColor: "#ccc",
      separatorWidth: "1px",
      dropZoneBgColor: "rgba(33, 150, 243, 0.2)",
      draggedItemBgColor: "rgba(33, 150, 243, 0.5)"
    }
  }
}

Here are the available properties:

NameDescription
primaryColorPrimary color used for expanded items, dropzone borders...
arrowColorColor of arrows in expandable items
separatorColorBorder color of separators between lists
separatorWidthWidth value of separators between lists
dropZoneBgColorBackground color of drop zones (visible when Drag & Drop)
draggedItemBgColorBackground color of dragged items (visible when Drag & Drop)

Custom slots

You can pass scoped slots in order to customize some parts of the UI.

Item

You can use the item scoped slot to render items. This slot accepts the following props:

  • item: the data of the item
  • expanded: the expanded state of the item
  • dragged: whether the item is currently dragged
<Finder :tree="tree">
  <template #item="{ item }">
    <div style="color: blue">
      <em>Name:</em> <strong>{{ item.label }}</strong>
    </div>
  </template>
</Finder>

Arrow

You can use the arrow scoped slot to render custom arrows. This slot accepts the following props:

  • expanded: the expanded state of the item
  • item: the data of the item
  • theme: the theme applied on the Finder
<Finder :tree="tree">
  <template #arrow="{ expanded }">
    <div>{{ expanded ? '↪' : '→' }}</div>
  </template>
</Finder>
Last Updated: 7/5/2024, 4:49:06 PM
Contributors: Jérémie Ledentu