Skip to content

Tabs

Tabs components are Layout Fields that allow users to switch between different content areas within the same context. They are highly effective for breaking down large forms into logical, manageable pieces.

tabs.ts
import { golemForm } from '@golemui/gui-shared';
export default golemForm().create({
form: [
{
uid: 'tabs_basic',
kind: 'layout',
type: 'tabs',
props: {
tabs: [
{
uid: 'tab_personal',
label: 'Personal',
},
{
uid: 'tab_work',
label: 'Work',
},
{
uid: 'tab_other',
label: 'Other',
},
],
defaultOpen: 'tab_personal',
},
children: [
{
uid: 'tab_personal',
kind: 'input',
type: 'textinput',
path: 'personal_email',
label: 'Personal Email',
},
{
uid: 'tab_work',
kind: 'input',
type: 'textinput',
path: 'work_email',
label: 'Work Email',
},
{
uid: 'tab_other',
kind: 'input',
type: 'textarea',
path: 'notes',
label: 'Additional Notes',
},
],
},
],
});
tabs.json
{
"form": [
{
"uid": "tabs_basic",
"kind": "layout",
"type": "tabs",
"props": {
"tabs": [
{ "uid": "tab_personal", "label": "Personal" },
{ "uid": "tab_work", "label": "Work" },
{ "uid": "tab_other", "label": "Other" }
],
"defaultOpen": "tab_personal"
},
"children": [
{
"uid": "tab_personal",
"kind": "input",
"type": "textinput",
"path": "personal_email",
"label": "Personal Email"
},
{
"uid": "tab_work",
"kind": "input",
"type": "textinput",
"path": "work_email",
"label": "Work Email"
},
{
"uid": "tab_other",
"kind": "input",
"type": "textarea",
"path": "notes",
"label": "Additional Notes"
}
]
}
]
}

Use these props to customize your Tabs component.

proptypedescription
tabsarrayRequired. Array of tab definitions: { label: string, uid: string }
defaultOpenstringThe uid of the tab that should be open by default. Defaults to the first tab
renderModestringEither 'all' (renders hidden tabs in DOM) or 'activeOnly' (renders only the open tab). Defaults to 'all'

Tabs can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables used to style the tabs.

CSS VariableDescription
--gui-bg-defaultBackground color for tab buttons and panels
--gui-border-defaultBorder color for tab buttons and panels
--gui-text-defaultText color for labels
--gui-space-3Padding inside tab buttons and panels
--gui-radius-mdBorder radius for tab buttons and panels

This is the anatomy of the Tabs Component in case you want to use your CSS styles.

tabs-anatomy.html
<div class="gui-tabs">
<nav class="gui-widget gui-widget--horizontal" id="tabs_uid">
<ul role="tablist">
<li role="presentation">
<button type="button" role="tab" aria-selected="true" class="active" id="tab_tabs_uid_0">
Personal
</button>
</li>
<li role="presentation">
<button type="button" role="tab" aria-selected="false" id="tab_tabs_uid_1">
Work
</button>
</li>
<li role="presentation">
<button type="button" role="tab" aria-selected="false" id="tab_tabs_uid_2">
Other
</button>
</li>
</ul>
</nav>
<section role="tabpanel" id="tabpanel_tabs_uid_0" aria-labelledby="tab_tabs_uid_0">
<div class="gui-widget">
<!-- Child widgets for Personal tab -->
</div>
</section>
<section role="tabpanel" id="tabpanel_tabs_uid_1" aria-labelledby="tab_tabs_uid_1" hidden>
<!-- Content for Work tab (hidden) -->
</section>
<section role="tabpanel" id="tabpanel_tabs_uid_2" aria-labelledby="tab_tabs_uid_2" hidden>
<!-- Content for Other tab (hidden) -->
</section>
</div>