Skip to content
ui8kit

component / components

File Tree

File Tree component

Install

npx ui8kit add file-tree

Pulls in: box, compose, kit-box, utils

Preview

No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add file-tree
components/file-tree.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead`
  from the utils to the keydown (vertical, no loop).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type FileTreeProps = {
    label?: string;
    class?: string;
    children?: Snippet;
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import { cn } from "../utils";

  let { label, class: className, children }: FileTreeProps = $props();
</script>

<Box class={cn("flex flex-col gap-2 p-2", className)} role="tree" aria-label={label} data-slot="file-tree">
  {@render children?.()}
</Box>

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add file-tree
components/file-tree.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead`
 * from the utils to the keydown (vertical, no loop).
 */
import { type ReactNode } from "react";
import { Box } from "../compose";
import { cn } from "../utils";

export type FileTreeProps = {
  label?: string;
  className?: string;
  children?: ReactNode;
};

export function FileTree({ label, className, children }: FileTreeProps) {
  return (
    <Box className={cn("flex flex-col gap-2 p-2", className)} role="tree" aria-label={label} data-slot="file-tree">
      {children}
    </Box>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add file-tree
components/file-tree.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead`
  from the utils to the keydown (vertical, no loop).
-->
<script lang="ts">
export type FileTreeProps = {
  label?: string;
  class?: string;
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import { cn } from "../utils";

const { label, class: className } = defineProps<FileTreeProps>();
defineSlots<{ default?(): unknown }>();
</script>

<template>
  <Box :class="cn('flex flex-col gap-2 p-2', className)" role="tree" :aria-label="label" data-slot="file-tree">
    <slot />
  </Box>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add file-tree
components/file-tree.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead`
 * from the utils to the keydown (vertical, no loop).
 */
import { type JSX } from "solid-js";
import { Box } from "../compose";
import { cn } from "../utils";

export type FileTreeProps = {
  label?: string;
  class?: string;
  children?: JSX.Element;
};

export function FileTree({ label, class: className, children }: FileTreeProps) {
  return (
    <Box class={cn("flex flex-col gap-2 p-2", className)} role="tree" aria-label={label} data-slot="file-tree">
      {children}
    </Box>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add file-tree
blocks/file-tree.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/patterns/file-tree.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// FileTreeProps are the props of FileTree; the values are the JSON shapes of the TypeScript props.
type FileTreeProps struct {
	Label any `json:"label"`
	Class string `json:"className"`
}

// The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead` from the utils to the keydown (vertical, no loop).
templ FileTree(p FileTreeProps) {
	{{ vLabel := p.Label }}
	@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cnv("flex flex-col gap-2 p-2", p.Class)), Attrs: uiutils.Attrs("role", "tree", "aria-label", vLabel, "data-slot", "file-tree")}}) {
		{ children... }
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add file-tree
blocks/file-tree.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/file-tree.json
    The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead` from the utils to the keydown (vertical, no loop).
    Props (p): label, className; children: markup. -#}
{%- set v_label = (p.label ?? null) -%}
{%- set c_1 -%}
  {{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s(og_cnv(['flex flex-col gap-2 p-2', (p.className ?? '')])), 'attrs': og_attrs(['role', 'tree', 'aria-label', v_label, 'data-slot', 'file-tree']), 'children': c_1}, with_context = false) }}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add file-tree
blocks/file-tree.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/file-tree.json
    The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead` from the utils to the keydown (vertical, no loop).
    Props (p): label, className; children: markup. *}
{var $v_label = ($p['label'] ?? null)}
{capture $c_1}
  {=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s(og_cnv(['flex flex-col gap-2 p-2', ($p['className'] ?? '')])), 'attrs' => og_attrs(['role', 'tree', 'aria-label', $v_label, 'data-slot', 'file-tree']), 'children' => (string) $c_1])|noescape}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add file-tree
blocks/file-tree.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/patterns/file-tree.json
    The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead` from the utils to the keydown (vertical, no loop).
    Props (p): label, className; children: markup. -#}
{%- set v_label = og_def(p['label'], none) -%}
{%- set c_1 -%}
  {{ og_slot(og_def(children, none))|safe }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(og_cnv(['flex flex-col gap-2 p-2', og_def(p['className'], '')])), 'Attrs': og_attrs(['role', 'tree', 'aria-label', v_label, 'data-slot', 'file-tree'])}, 'children': c_1}) }}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

The list of a file tree. Put FileTreeItem in it. Arrow keys and type-ahead: attach `moveFocus` and `typeahead` from the utils to the keydown (vertical, no loop).

Props of FileTree
PropTypeDefault Description
label string-accessible name of the tree