Skip to content

Commit 2d09369

Browse files
docs(tabs): document the new parameter for the Tabs class
1 parent ac7bac8 commit 2d09369

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

content/components/tabs.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,20 @@ Create a new Tabs object with parameters such as an array of the tab and content
239239
</tr>
240240
</thead>
241241
<tbody>
242+
<tr class="border-b dark:bg-gray-800 dark:border-gray-700">
243+
<td class="px-6 py-4 font-medium">
244+
<code class="text-blue-600 dark:text-blue-400">tabsElement</code>
245+
</td>
246+
<td class="px-6 py-4">
247+
Element
248+
</td>
249+
<td class="px-6 py-4">
250+
Required
251+
</td>
252+
<td class="px-6 py-4">
253+
Parent HTML element of the tabs component.
254+
</td>
255+
</tr>
242256
<tr class="border-b dark:bg-gray-800 dark:border-gray-700">
243257
<td class="px-6 py-4 font-medium">
244258
<code class="text-blue-600 dark:text-blue-400">items</code>
@@ -383,6 +397,8 @@ Check out the following example to learn how to initialize and manipulate a Tabs
383397
First of all, create an array of objects that contains the id, trigger element, and content element of each tab, set the active tab based on the id, and optionally set a callback function after a new tab has been shown.
384398

385399
```javascript
400+
const tabsElement = document.getElementById('tabs-example');
401+
386402
// create an array of objects with the id, trigger element (eg. button), and the content element
387403
const tabElements = [
388404
{
@@ -427,7 +443,7 @@ import { Tabs } from 'flowbite';
427443
* tabElements: array of tab objects
428444
* options: optional
429445
*/
430-
const tabs = new Tabs(tabElements, options);
446+
const tabs = new Tabs(tabsElement, tabElements, options);
431447
```
432448

433449
Lastly, you can now use the methods on the Tabs object to show another tab element, get a tab element based on the id, or get the current active tab element.
@@ -449,7 +465,7 @@ You can use this HTML code as an example for the JavaScript code from above.
449465

450466
```html
451467
<div class="mb-4 border-b border-gray-200 dark:border-gray-700">
452-
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center text-gray-500 dark:text-gray-400" id="tabExample" role="tablist">
468+
<ul class="flex flex-wrap -mb-px text-sm font-medium text-center text-gray-500 dark:text-gray-400" id="tabs-example" role="tablist">
453469
<li class="mr-2" role="presentation">
454470
<button class="inline-block p-4 border-b-2 border-transparent rounded-t-lg hover:text-gray-600 hover:border-gray-300 dark:hover:text-gray-300" id="profile-tab-example" type="button" role="tab" aria-controls="profile-example" aria-selected="false">Profile</button>
455471
</li>
@@ -490,6 +506,8 @@ Here's an example that applies the types from Flowbite to the code above:
490506
import { Tabs } from "flowbite";
491507
import type { TabsOptions, TabsInterface, TabItem } from "flowbite";
492508

509+
const tabsElement: HTMLElement = document.getElementById('tabs-example');
510+
493511
// create an array of objects with the id, trigger element (eg. button), and the content element
494512
const tabElements: TabItem[] = [
495513
{
@@ -528,7 +546,7 @@ const options: TabsOptions = {
528546
* tabElements: array of tab objects
529547
* options: optional
530548
*/
531-
const tabs: TabsInterface = new Tabs(tabElements, options);
549+
const tabs: TabsInterface = new Tabs(tabsElement, tabElements, options);
532550

533551
// open tab item based on id
534552
tabs.show('contacts');

0 commit comments

Comments
 (0)