NAME

Chandra::Tabs - Tab component

SYNOPSIS

use Chandra::Tabs;

my $tabs = Chandra::Tabs->new(
    tabs => [
        { label => 'General',  content => sub { '<p>General settings</p>' } },
        { label => 'Advanced', content => sub { '<p>Advanced options</p>' } },
        { label => 'Plugins',  content => sub { '<p>Plugin list</p>' }, badge => 3 },
    ],
    on_change => sub { my ($index, $label) = @_; print "Tab: $label\n" },
);

$app->css(Chandra::Tabs->css);
$tabs->mount($app, '#content');

METHODS

new(tabs = \@tabs, on_change => sub { ... })>

Each tab is a hash with a label, a content (html or code returning html) and an optional badge.

render

The tab headers and the active tab's content.

on_select_tab($index)

Makes that tab active, runs on_change with the index and label, and updates. An index outside the tabs is ignored.

active_index

The index of the active tab.

css

The tabs' stylesheet.

prototype, set_prototype

Object::Proto's prototype accessors.

SLOT ACCESSORS

Functions with the tabs_ prefix and methods of the slot's name: tabs_tabs, tabs_on_change, tabs__active_index, and the component slots tabs__cid, tabs__app, tabs__selector, tabs__mounted, tabs__children and tabs__parent.

tabs - the tabs
on_change - the change callback
tabs_tabs, tabs_on_change, tabs__active_index, tabs__cid, tabs__app, tabs__selector, tabs__mounted, tabs__children, tabs__parent - the slot functions

SEE ALSO

Chandra::Nav, Chandra::Component