Skip to content

New Component: TabBar#811

Open
scttfrdmn wants to merge 1 commit intocharmbracelet:masterfrom
scttfrdmn:feature/tabbar-component
Open

New Component: TabBar#811
scttfrdmn wants to merge 1 commit intocharmbracelet:masterfrom
scttfrdmn:feature/tabbar-component

Conversation

@scttfrdmn
Copy link

New Component: TabBar

This PR adds a simple, customizable tab bar component for Bubble Tea applications.

Description

The TabBar component provides a horizontal tab navigation system that can be used to switch between different views within a Bubble Tea application. It supports keyboard navigation, custom styling, and active tab highlighting.

Features

  • Horizontal tabs with customizable styling
  • Active tab highlighting with different border colors
  • Keyboard navigation methods (Next, Prev, Activate)
  • Adjustable width to fit different layouts
  • Simple API integration with Bubble Tea applications

Example

// Create tabs
tabs := []string{"Home", "Projects", "Settings", "About"}

// Initialize the tab bar with Home tab active (index 0)
bar := tabbar.New(tabs, 0)

// In your model's Update method:
switch msg := msg.(type) {
case tea.KeyMsg:
    switch msg.String() {
    case "right", "tab":
        return m, m.tabBar.Next()
    case "left", "shift+tab":
        return m, m.tabBar.Prev()
    }
case tabbar.TabChangeMsg:
    // Handle tab change if needed
}

Motivation

Many Bubble Tea applications need tabbed interfaces to organize content, but there isn't a standard component for this in the bubbles library. This component fills that gap with a simple, reusable implementation.

Testing

I've tested this component in several projects, including the CloudWorkstation TUI, which uses it for its main navigation system. The example in this PR demonstrates the component's functionality.

Notes

  • The component is designed to be simple and customizable
  • It follows the Bubble Tea component pattern with Init/Update/View methods
  • It can be extended with additional features if needed

🤖 Generated with Claude Code

This PR adds a simple, customizable tab bar component for Bubble Tea applications.
The TabBar provides a horizontal tab navigation system that can be used to switch
between different views within an application.

Features:
- Horizontal tabs with customizable styling
- Active tab highlighting with different border colors
- Keyboard navigation methods (Next, Prev, Activate)
- Adjustable width to fit different layouts
- Simple API integration with Bubble Tea applications

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant