Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion app/playground/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TerminalApp } from '@/components/terminal-app'
import { Terminal, TerminalCommand, TerminalDiff, TerminalOutput, TerminalSpinner, TerminalBadge, ThemeSwitcher } from '@/components/terminal'
import { Terminal, TerminalCommand, TerminalDiff, TerminalOutput, TerminalSpinner, TerminalBadge, ThemeSwitcher, TerminalBreadcrumbs } from '@/components/terminal'
import { TerminalProgress } from '@/components/terminal-progress'
import { LogDemo } from './log-demo'
import { PromptDemo } from './prompt-demo'
Expand Down Expand Up @@ -161,6 +161,32 @@ export default function PlaygroundPage() {
</Terminal>
</section>

<section className="flex flex-col gap-2">
<h2 className="text-lg font-semibold font-mono text-[var(--term-fg)]">
TerminalBreadcrumbs
</h2>
<Terminal title="breadcrumbs-demo.sh">
<TerminalCommand>pwd</TerminalCommand>
<TerminalOutput>
<TerminalBreadcrumbs items={[
{ label: '~', href: '#' },
{ label: 'dev', href: '#' },
{ label: 'terminal-ui', href: '#' },
{ label: 'src', active: true }
]} />
</TerminalOutput>
<div className="mt-4" />
<TerminalCommand>cat config.json</TerminalCommand>
<TerminalOutput>
<TerminalBreadcrumbs separator="›" items={[
{ label: 'root' },
{ label: 'settings' },
{ label: 'theme' }
]} />
</TerminalOutput>
</Terminal>
</section>

<section className="flex flex-col gap-2">
<h2 className="text-lg font-semibold font-mono text-[var(--term-fg)]">
Typing Animation
Expand Down
75 changes: 75 additions & 0 deletions components/terminal-breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
'use client'

import { Fragment } from 'react'

export interface BreadcrumbItem {
label: string
href?: string
active?: boolean
}

export interface TerminalBreadcrumbsProps {
/** Array of breadcrumb segments */
items: BreadcrumbItem[]
/** Separator string between items (default: '/') */
separator?: string
/** Additional classes applied to the root element */
className?: string
}

/**
* Displays a directory path or navigation trail in a terminal style.
*
* @param items - Array of breadcrumb segments
* @param separator - Separator string between items (default: '/')
* @param className - Additional classes applied to the root element
*
* @example
* ```tsx
* <TerminalBreadcrumbs items={[
* { label: '~' },
* { label: 'projects' },
* { label: 'terminal-ui', active: true }
* ]} />
* ```
*/
export function TerminalBreadcrumbs({
items,
separator = '/',
className = '',
}: TerminalBreadcrumbsProps) {
return (
<nav aria-label="Breadcrumb" className={`flex flex-wrap items-center gap-1.5 font-mono text-sm ${className}`.trim()}>
{items.map((item, index) => {
const isLast = index === items.length - 1
const active = item.active ?? isLast

const content = (
<span className={`transition-colors ${active ? 'text-[var(--term-blue)] font-bold' : 'text-[var(--term-fg)] hover:text-[var(--term-cyan)]'}`}>
{item.label}
</span>
)

return (
<Fragment key={index}>
{item.href && !active ? (
<a href={item.href} className="outline-none focus-visible:ring-1 focus-visible:ring-[var(--term-blue)] rounded">
{content}
</a>
) : (
<span className="outline-none">
{content}
</span>
)}

{!isLast && (
<span className="text-[var(--term-fg-dim)] select-none" aria-hidden>
{separator}
</span>
)}
</Fragment>
)
})}
</nav>
)
}
1 change: 1 addition & 0 deletions components/terminal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,4 @@ export { TerminalAutocomplete, useAutocomplete, COMMON_COMMANDS, COMMON_FLAGS, f
export { TerminalGhosttyTheme, GhosttyThemePicker } from './terminal-ghostty'
export { ThemeSwitcher } from './theme-switcher'
export { TerminalBadge } from './terminal-badge'
export { TerminalBreadcrumbs } from './terminal-breadcrumbs'