Skip to content

Commit

Permalink
feat: add tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Oct 29, 2024
1 parent 10f98c1 commit 3edc678
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions components/tabs/tabs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package tabs

import (
htmx "github.com/zeiss/fiber-htmx"
)

// TabsProps is a struct that contains the properties of the Tabs component
type TabsProps struct {
ClassNames htmx.ClassNames
}

// Tabs is a component that renders a list of tabs
func Tabs(props TabsProps, children ...htmx.Node) htmx.Node {
return htmx.Div(
htmx.Merge(
htmx.ClassNames{
"tabs": true,
},
props.ClassNames,
),
htmx.Role("tablist"),
htmx.Group(children...),
)
}

// TabsBoxed is a component that renders a list of tabs in a box
func TabsBoxed(props TabsProps, children ...htmx.Node) htmx.Node {
return htmx.Div(
htmx.Merge(
htmx.ClassNames{
"tabs": true,
"tabs-boxed": true,
},
props.ClassNames,
),
htmx.Role("tablist"),
htmx.Group(children...),
)
}

// TabProps is a struct that contains the properties of the Tab component
type TabProps struct {
ClassNames htmx.ClassNames
Active bool
}

// Tab is a component that renders a tab.
func Tab(props TabProps, children ...htmx.Node) htmx.Node {
return htmx.A(
htmx.Merge(
htmx.ClassNames{
"tab": true,
"tab-active": props.Active,
},
props.ClassNames,
),
htmx.Role("tab"),
htmx.Group(children...),
)
}

0 comments on commit 3edc678

Please sign in to comment.