Here are some examples showcasing tabs.
Tabs are transparent by default and don't automatically do anything since
they are simple <a>
(anchor) elements. You can set the
href
attribute to make them link to another page.
If you want the tabs to change their content, you can use the
radio
option. Note that this does not allow the use
of icons or other HTML elements in the title.
Tab 1 content
Tab 2 content
Tab 3 content
Tab 1 content
Tab 2 content
Tab 3 content
= daisy_tabs(css: "tabs-lifted w-[500px]", radio: true) do |tabs|
- # Add some space before the first tab
- tabs.with_tab(title: "", css: "!w-14 !cursor-auto", disabled: true)
- (1..3).each do |i|
- tabs.with_tab(title: "Tab #{i}", content_wrapper_css: "bg-base-100 border-base-300 rounded-box p-6", checked: i == 1) do
%p Tab #{i} content
You can also use tabs with Turbo Frames to load content dynamically.
%turbo-frame#tabs--turob-tabs-example
= daisy_tabs(css: "tabs-lifted w-[500px]") do |tabs|
- (2..4).each do |i|
- is_checked = params[:custom_tab] ? params[:custom_tab] == i.to_s : i == 3
- tabs.with_tab(href: "?custom_tab=#{i}", checked: is_checked) do |tab|
- tab.with_title(css: "test-tab") do
.flex.gap-x-2.items-center
%span.w-4.h-4
= heroicon_tag("bars-#{i}")
%span.whitespace-nowrap #{i} Bars
- tab.with_custom_content(css: "tab-content bg-base-100 border-base-300 rounded-box p-6") do
%p #{i} bars content...