Warp Tree demo — trees of departments and categories for Filament: choose, filter, edit by dragging. Change or delete anything; the data is reset every hour. warpui.com About Warp Tree Docs Ask a question Support
Skip to content

Choosing from a tree

SelectTree picks one item, or several, from a tree: here the departments of Harbor Supply Co. and its product categories. Each section shows one setting. Nothing on this page is saved.

Only the branches you open are read

The list starts with the top-level departments. Opening a department reads only what is directly under it, and the number next to it tells how many items are there.

Note: Try it

Click the field, then click the arrow next to Sales and next to East. Choose Boston: the field shows the whole path, Sales › East › Boston.

Search with the path

Typing searches the whole tree on the server and shows each match inside the departments it belongs to. The words may be spread over the path.

Note: Try it

Click the field and type “inside bos”. “Inside sales” under Boston is found, shown under Sales › East › Boston. Press Enter to choose it.

Only the lowest level can be chosen

->leavesOnly(): a group of categories can’t be chosen, only the categories at the bottom. Clicking a group opens it.

Note: Try it

Click Fasteners: it opens instead of being chosen. Open Bolts and choose Hex bolts.

Choosing a department chooses everything under it

->multiple()->selectDescendants(): ticking a department also ticks every department under it. One badge stands for all of them.

Note: Try it

Open Sales and tick East. Only one badge, East, appears. Press “Show what would be saved”: East and the 20 departments under it are saved. Click × on the badge to remove them all.

Icons for groups and for the last level

->icon() puts an icon before every item, and ->leafIcon() another one before the items with nothing under them: here a folder for the groups and a tag for the last level.

Note: Try it

Open Fasteners and Bolts: the groups have a folder, Hex bolts a tag. Choose Hex bolts: the field shows the tag too.

An icon per item

->icon(fn (Department $record) => …) decides the icon from the record. Here each top-level department has its own icon, and the departments under them have none (the closure returns null).

Note: Try it

Click the field: Finance has banknotes, Operations a truck, Sales a megaphone. Open Finance: Accounting, Tax and the other departments under it have no icon.

Items that can’t be chosen

->disabledOptions([...]): Legal and Internal audit take no orders. They are shown in grey and can’t be chosen; the server refuses them too.

Note: Try it

Type “legal”: Legal is grey. Clicking it opens it instead of choosing it, and Contracts under it can be chosen.

Hidden items

->hiddenOptions([...]): HR and everything under it are left out of the list and the search, and the server refuses them.

Note: Try it

Scroll through the top-level departments: there is no HR. Type “recruiting”: nothing is found.

An extra item before the tree

->prepend([...]) adds an item that is not in the database, such as “No department”, before the top-level departments. It is saved like any other item.

Note: Try it

Open the list: “No department” comes first. Choose it and press “Show what would be saved”: the value is none.

Branches already open

->defaultOpenLevel(1): when the list opens, the top-level departments are already open, so the second level is visible at once.

Note: Try it

Click the field: Sales, Operations, Finance and the others are open and show their departments.

Show how many are chosen

->badges(false): instead of a badge per department, the field says how many are chosen. Useful when people pick dozens.

Note: Try it

Tick three or four departments. The field shows “4 selected”.

A list that is always open

->alwaysOpen(): the tree is shown under the field all the time, without covering the fields below it.

Note: Try it

Open Tools and choose Hand tools. The list stays open, and the field shows the path.

Add a department without leaving the form

->createOptionForm([...]): the + button opens Filament’s modal. The new department is saved, chosen in the field and shown in the tree.

Note: Try it

Click + next to the field. Type “Pricing” as the name, choose Sales as the parent department and press Create. The field shows Sales › Pricing. (This one is saved: the demo is reset every hour.)