File Tree
The files an agent changed, as a folder tree.
Derived from Sidekick todo card and Polaris action list rows. Sidekick has no file tree. The todo card holds Polaris-style rows with a rail for children, and change counts use Polaris success, caution and critical tones.
import { FileTree } from "@replicas/ui";
import { useState } from "react";
export default function FileTreeDemo() {
const [selected, setSelected] = useState("app/page.tsx");
const file = (path: string, name: string, change?: "added" | "modified" | "deleted", added?: number, removed?: number) => (
<FileTree.File
name={name}
change={change}
selected={selected === path}
onClick={() => setSelected(path)}
stats={
change ? (
<>
{added ? <FileTree.Additions>+{added}</FileTree.Additions> : null}
{removed ? <FileTree.Deletions>−{removed}</FileTree.Deletions> : null}
</>
) : undefined
}
/>
);
return (
<FileTree.Root style={{ width: "100%", maxWidth: 300 }}>
<FileTree.Folder name="app" defaultOpen>
<FileTree.Folder name="api" defaultOpen>
{file("app/api/route.ts", "route.ts", "modified", 12, 3)}
</FileTree.Folder>
{file("app/layout.tsx", "layout.tsx")}
{file("app/page.tsx", "page.tsx", "modified", 4, 1)}
{file("app/theme.ts", "theme.ts", "added", 38)}
</FileTree.Folder>
<FileTree.Folder name="components">
{file("components/button.tsx", "button.tsx")}
</FileTree.Folder>
{file("package.json", "package.json")}
</FileTree.Root>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the File Tree in the Shopify style: the measured tokens, the CSS and the structure.
Show Prompt
# Shopify File Tree
The files an agent changed, as a folder tree.
Build a File Tree in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.com). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or Base UI primitives if it has none.
Fidelity: Derived from Sidekick todo card and Polaris action list rows. Sidekick has no file tree. The todo card holds Polaris-style rows with a rail for children, and change counts use Polaris success, caution and critical tones.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-200` | `.5rem` | `.5rem` |
| `--p-border-width-050` | `.125rem` | `.125rem` |
| `--p-color-bg-fill-transparent-hover` | `#00000014` | `#ffffff17` |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-border-focus` | `rgba(80,131,240,1)` | `#97adff` |
| `--p-color-border-secondary` | `rgba(242,242,242,1)` | `#ffffff0f` |
| `--p-color-icon-secondary` | `#606060` | `#aaa` |
| `--p-color-text` | `#101010` | `#eee` |
| `--p-color-text-caution-accent` | `rgba(133,100,0,1)` | `#ead300` |
| `--p-color-text-critical-accent` | `rgba(206,31,24,1)` | `#f78086` |
| `--p-color-text-disabled` | `#a6a6a6` | `#585858` |
| `--p-color-text-success-accent` | `rgba(58,126,9,1)` | `#2ced83` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-letter-spacing-body-medium` | `-.01em` | `-.01em` |
| `--p-font-size-300` | `.75rem` | `.75rem` |
| `--p-font-weight-regular` | `400` | `400` |
| `--p-font-weight-semibold` | `600` | `600` |
| `--p-motion-duration-150` | `150ms` | `150ms` |
| `--p-motion-duration-200` | `200ms` | `200ms` |
| `--p-motion-duration-300` | `300ms` | `300ms` |
| `--p-motion-ease` | `cubic-bezier(.25, .1, .25, 1)` | `cubic-bezier(.25, .1, .25, 1)` |
| `--p-space-050` | `.125rem` | `.125rem` |
| `--p-space-100` | `.25rem` | `.25rem` |
| `--p-space-150` | `.375rem` | `.375rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-300` | `.75rem` | `.75rem` |
| `--p-space-400` | `1rem` | `1rem` |
| `--p-space-500` | `1.25rem` | `1.25rem` |
| `--p-font-size-325` | `.8125rem` | `.8125rem` |
| `--p-font-line-height-400` | `1rem` | `1rem` |
| `--p-font-line-height-500` | `1.25rem` | `1.25rem` |
| `--p-color-bg-fill-secondary` | `#ebebeb` | `#373737` |
| `--p-shadow-100` | `0rem .3125rem .3125rem -.15625rem rgba(0,0,0,.03), 0rem .1875rem .1875rem -.09375rem #00000005, 0rem .125rem .125rem -.0625rem #00000005, 0rem .0625rem .0625rem -.03125rem #00000008, 0rem .03125rem .03125rem 0rem #0000000a, 0rem 0rem 0rem .0625rem #0000000f` | `0rem 0rem 0rem .0625rem #dcdcdc24, 0rem .0625rem 0rem 0rem #ffffff08, 0rem .15625rem .03125rem 0rem #00000057, 0rem .25rem .25rem -.09375rem #0000001f, 0rem .3125rem .3125rem -.15625rem #0000003d` |
| `--sidekick-stroke` | `.09375rem` | `.09375rem` |
| `--sidekick-todo-radius` | `1.125rem` | `1.125rem` |
| `--sidekick-todo-fill` | `#0000000d` | `#ffffff1f` |
| `--ease-sidekick-settle` | `cubic-bezier(.32, .72, 0, 1)` | `cubic-bezier(.32, .72, 0, 1)` |
| `--duration-sidekick-chevron` | `150ms` | `150ms` |
## CSS
Scoped under `[data-style="shopify"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="shopify"] {
.ui-file-tree {
box-sizing: border-box;
display: flex;
flex-direction: column;
min-width: 0;
padding: var(--p-space-100);
border-radius: var(--sidekick-todo-radius);
corner-shape: superellipse(1.4);
background-color: var(--p-color-bg-surface);
box-shadow: var(--p-shadow-100);
color: var(--p-color-text);
font-family: var(--p-font-family-sans);
font-size: var(--p-font-size-325);
line-height: var(--p-font-line-height-500);
letter-spacing: var(--p-font-letter-spacing-body-medium);
}
.ui-file-tree-folder {
display: flex;
flex-direction: column;
}
.ui-file-tree-row {
box-sizing: border-box;
display: flex;
align-items: center;
gap: var(--p-space-150);
width: 100%;
min-width: 0;
margin: 0;
padding: var(--p-space-100) var(--p-space-200) var(--p-space-100) var(--p-space-150);
border: none;
border-radius: var(--p-border-radius-200);
background-color: transparent;
color: var(--p-color-text);
font: inherit;
letter-spacing: inherit;
text-align: start;
user-select: none;
cursor: pointer;
transition: background-color var(--p-motion-duration-300) var(--ease-sidekick-settle);
&:focus-visible {
outline: var(--p-border-width-050) solid var(--p-color-border-focus);
outline-offset: calc(var(--p-space-050) * -1);
}
@media (hover: hover) {
&:hover {
background-color: var(--sidekick-todo-fill);
transition-duration: var(--p-motion-duration-150);
}
}
&:active {
background-color: var(--p-color-bg-fill-transparent-hover);
}
}
.ui-file-tree-file {
padding-inline-start: calc(var(--p-space-150) + var(--p-space-300) + var(--p-space-150));
}
.ui-file-tree-file[data-selected] {
background-color: var(--p-color-bg-fill-secondary);
font-weight: var(--p-font-weight-semibold);
}
.ui-file-tree-chevron {
flex-shrink: 0;
width: var(--p-space-300);
height: var(--p-space-300);
color: var(--p-color-icon-secondary);
transition: transform var(--duration-sidekick-chevron) var(--p-motion-ease);
[data-panel-open] > & {
transform: rotate(90deg);
}
}
.ui-file-tree-icon {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: var(--p-space-500);
height: var(--p-space-500);
color: var(--p-color-icon-secondary);
& svg {
width: var(--p-space-400);
height: var(--p-space-400);
}
}
.ui-file-tree-name {
flex: 1;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ui-file-tree-file[data-change="added"] .ui-file-tree-name {
color: var(--p-color-text-success-accent);
}
.ui-file-tree-file[data-change="modified"] .ui-file-tree-name {
color: var(--p-color-text-caution-accent);
}
.ui-file-tree-file[data-change="deleted"] .ui-file-tree-name {
color: var(--p-color-text-disabled);
text-decoration: line-through;
text-decoration-thickness: var(--sidekick-stroke);
}
.ui-file-tree-stats {
display: flex;
flex-shrink: 0;
gap: var(--p-space-150);
font-size: var(--p-font-size-300);
font-weight: var(--p-font-weight-regular);
line-height: var(--p-font-line-height-400);
letter-spacing: normal;
font-variant-numeric: tabular-nums;
}
.ui-file-tree-additions {
color: var(--p-color-text-success-accent);
}
.ui-file-tree-deletions {
color: var(--p-color-text-critical-accent);
}
.ui-file-tree-children {
box-sizing: border-box;
display: flex;
flex-direction: column;
height: var(--collapsible-panel-height);
margin-inline-start: calc(var(--p-space-150) + var(--p-space-300) / 2 - var(--sidekick-stroke) / 2);
padding-inline-start: var(--p-space-100);
overflow: hidden;
border-inline-start: var(--sidekick-stroke) solid var(--p-color-border-secondary);
transition:
height var(--p-motion-duration-300) var(--ease-sidekick-settle),
opacity var(--p-motion-duration-200) var(--p-motion-ease);
&[data-starting-style],
&[data-ending-style] {
height: 0;
opacity: 0;
}
}
@media (prefers-reduced-motion: reduce) {
.ui-file-tree-row,
.ui-file-tree-chevron,
.ui-file-tree-children {
transition: none;
}
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
import type { ComponentProps, ReactNode } from "react";
import { join } from "./utils";
const folderIcon = (
<svg viewBox="0 0 16 16" fill="none">
<path
d="M2 4.5A1.5 1.5 0 0 1 3.5 3h2.6l1.4 1.5h5a1.5 1.5 0 0 1 1.5 1.5v5.5a1.5 1.5 0 0 1-1.5 1.5h-9A1.5 1.5 0 0 1 2 11.5z"
stroke="currentColor"
strokeWidth="1.25"
strokeLinejoin="round"
/>
</svg>
);
const fileIcon = (
<svg viewBox="0 0 16 16" fill="none">
<path
d="M4 2.5h5l3 3v8a.5.5 0 0 1-.5.5h-7.5a.5.5 0 0 1-.5-.5v-10.5a.5.5 0 0 1 .5-.5zM9 2.5v3h3"
stroke="currentColor"
strokeWidth="1.25"
strokeLinejoin="round"
/>
</svg>
);
function Root({ className, ...props }: ComponentProps<"div">) {
return <div className={join("ui-file-tree", className)} {...props} />;
}
type FolderProps = Omit<BaseCollapsible.Root.Props, "className"> & {
className?: string;
name: ReactNode;
icon?: ReactNode;
};
function Folder({ className, name, icon = folderIcon, children, ...props }: FolderProps) {
return (
<BaseCollapsible.Root className={join("ui-file-tree-folder", className)} {...props}>
<BaseCollapsible.Trigger className="ui-file-tree-row ui-file-tree-folder-trigger">
<svg className="ui-file-tree-chevron" viewBox="0 0 16 16" fill="none" aria-hidden>
<path d="M6 4l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
</svg>
<span className="ui-file-tree-icon" aria-hidden>{icon}</span>
<span className="ui-file-tree-name">{name}</span>
</BaseCollapsible.Trigger>
<BaseCollapsible.Panel className="ui-file-tree-children">{children}</BaseCollapsible.Panel>
</BaseCollapsible.Root>
);
}
type FileProps = Omit<ComponentProps<"button">, "name"> & {
name: ReactNode;
icon?: ReactNode;
selected?: boolean;
change?: "added" | "modified" | "deleted" | "renamed";
stats?: ReactNode;
};
function File({ className, name, icon = fileIcon, selected = false, change, stats, ...props }: FileProps) {
return (
<button
type="button"
className={join("ui-file-tree-row ui-file-tree-file", className)}
data-selected={selected || undefined}
data-change={change}
aria-current={selected || undefined}
{...props}
>
<span className="ui-file-tree-icon" aria-hidden>{icon}</span>
<span className="ui-file-tree-name">{name}</span>
{stats ? <span className="ui-file-tree-stats">{stats}</span> : null}
</button>
);
}
function Additions({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-file-tree-additions", className)} {...props} />;
}
function Deletions({ className, ...props }: ComponentProps<"span">) {
return <span className={join("ui-file-tree-deletions", className)} {...props} />;
}
export const FileTree = {
Root,
Folder,
File,
Additions,
Deletions,
};
```
## Example
```tsx
import { FileTree } from "@replicas/ui";
import { useState } from "react";
export default function FileTreeDemo() {
const [selected, setSelected] = useState("app/page.tsx");
const file = (path: string, name: string, change?: "added" | "modified" | "deleted", added?: number, removed?: number) => (
<FileTree.File
name={name}
change={change}
selected={selected === path}
onClick={() => setSelected(path)}
stats={
change ? (
<>
{added ? <FileTree.Additions>+{added}</FileTree.Additions> : null}
{removed ? <FileTree.Deletions>−{removed}</FileTree.Deletions> : null}
</>
) : undefined
}
/>
);
return (
<FileTree.Root style={{ width: "100%", maxWidth: 300 }}>
<FileTree.Folder name="app" defaultOpen>
<FileTree.Folder name="api" defaultOpen>
{file("app/api/route.ts", "route.ts", "modified", 12, 3)}
</FileTree.Folder>
{file("app/layout.tsx", "layout.tsx")}
{file("app/page.tsx", "page.tsx", "modified", 4, 1)}
{file("app/theme.ts", "theme.ts", "added", 38)}
</FileTree.Folder>
<FileTree.Folder name="components">
{file("components/button.tsx", "button.tsx")}
</FileTree.Folder>
{file("package.json", "package.json")}
</FileTree.Root>
);
}
```
## Foundations
The rest of the Shopify style, as a skill: https://replicas.raphaelsalaja.com/skills/shopify/SKILL.md