Skip to content

Commit

Permalink
expose defaultIndex on Tabs component (#148)
Browse files Browse the repository at this point in the history
* expose defaultIndex on Tabs component

* add defaultIndex prop documentation
  • Loading branch information
willbreitkreutz authored Jan 27, 2025
1 parent 9685d09 commit cdb232f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/components/navigation/tabs.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Tab } from "@headlessui/react";
import gwMerge from "../../gw-merge";

function Tabs({ tabs, fill = false }) {
function Tabs({ tabs, fill = false, defaultIndex = 0 }) {
return (
<Tab.Group defaultIndex={0}>
<Tab.Group defaultIndex={defaultIndex}>
<Tab.List className="gw-flex gw-flex-wrap gw-gap-x-1 gw-text-gray-500 gw-font-semibold gw-border-b-2 gw-border-gray-300">
{tabs.map((tab, idx) => (
<Tab
Expand Down
8 changes: 8 additions & 0 deletions src/app-pages/documentation/navigation/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ const componentProps = [
default: "false",
desc: "If true, the tabs will expand to fill the width of their container.",
},
{
name: "defaultIndex",
type: "number",
default: "0",
desc: "The index of the tab that should be active by default when the Tabs component renders.",
},
];

function TabsDocs() {
Expand Down Expand Up @@ -104,6 +110,7 @@ export default Component;
<div className="gw-rounded-md gw-border gw-border-dashed gw-px-6 gw-py-3 gw-mb-3">
<Tabs
fill
defaultIndex={1}
tabs={[
{
name: "Downloads",
Expand All @@ -128,6 +135,7 @@ function Component() {
return (
<Tabs
fill
defaultIndex={1}
tabs={[
{
name: "Downloads",
Expand Down

0 comments on commit cdb232f

Please sign in to comment.