+
+ The keepTabsContentMounted (boolean) prop controls whether tab contents remain mounted in the DOM
+ when switching between tabs. This is useful when you want to preserve the internal state of each tab's content.
+
+
+
Without keepTabsContentMounted (default: false)
+
+ By default, when you switch tabs, the previous tab's content is unmounted and its state is lost. Try
+ incrementing the counter or typing text, then switch tabs and come back - the state will be reset.
+
+
+ {Array(3)
+ .fill(true)
+ .map((v, index) => (
+ Tab {index + 1}}
+ numTab={index + 1}
+ active={index + 1 === 1}
+ >
+
+
+ ))}
+
+
+
+ With keepTabsContentMounted={'{'}true{'}'}
+
+
+ When enabled, all tab contents remain mounted (but hidden) in the DOM. The state is preserved when switching
+ between tabs. Try incrementing the counter or typing text, then switch tabs and come back - the state will be
+ maintained.
+
+
+ {Array(3)
+ .fill(true)
+ .map((v, index) => (
+ Tab {index + 1}}
+ numTab={index + 1}
+ active={index + 1 === 1}
+ >
+
+
+ ))}
+
+
+
+ Use cases: This prop is particularly useful when tab contents have:
+
+
+
Form inputs that users fill across multiple tabs
+
Interactive components with internal state (counters, toggles, etc.)
+
Media players or timers that should continue running
+
Complex components with expensive initialization
+
+
+ Note: When keepTabsContentMounted is true, inactive tabs are hidden using
+ visibility techniques (visually hidden) but remain in the DOM, which may have performance implications if tabs
+ contain heavy content.
+
+
+ )
+}
+
+ArticleKeepTabsContentMounted.displayName = 'ArticleKeepTabsContentMounted'
+
+ArticleKeepTabsContentMounted.propTypes = {
+ className: PropTypes.string
+}
+
+export default ArticleKeepTabsContentMounted
diff --git a/components/molecule/tabs/demo/index.js b/components/molecule/tabs/demo/index.js
index b89907860..7cae83f9f 100644
--- a/components/molecule/tabs/demo/index.js
+++ b/components/molecule/tabs/demo/index.js
@@ -3,9 +3,10 @@ import {H1, Paragraph} from '@s-ui/documentation-library'
import ArticleActiveTabs from './Articles/ArticleActiveTabs.js'
import ArticleDefault from './Articles/ArticleDefault.js'
import ArticleIconsCounters from './Articles/ArticleIconsCounters.js'
+import ArticleKeepTabsContentMounted from './Articles/ArticleKeepTabsContentMounted.js'
+import ArticleTabsJustifyContent from './Articles/ArticleTabsJustifyContent.js'
import ArticleType from './Articles/ArticleType.js'
import ArticleVariant from './Articles/ArticleVariant.js'
-import ArticleTabsJustifyContent from './Articles/ArticleTabsJustifyContent.js'
import {CLASS_DEMO_SECTION} from './config.js'
import './index.scss'
@@ -19,6 +20,8 @@ const Demo = () => {
+
+
diff --git a/components/molecule/tabs/package.json b/components/molecule/tabs/package.json
index e714e9236..1bffc229f 100644
--- a/components/molecule/tabs/package.json
+++ b/components/molecule/tabs/package.json
@@ -20,7 +20,8 @@
},
"dependencies": {
"@s-ui/component-dependencies": "1",
- "@s-ui/react-hooks": "1"
+ "@s-ui/react-hooks": "1",
+ "@s-ui/react-primitive-visually-hidden": "1"
},
"repository": {
"type": "git",
diff --git a/components/molecule/tabs/src/components/MoleculeTabs.js b/components/molecule/tabs/src/components/MoleculeTabs.js
index 95ded26b6..395dccbff 100644
--- a/components/molecule/tabs/src/components/MoleculeTabs.js
+++ b/components/molecule/tabs/src/components/MoleculeTabs.js
@@ -4,8 +4,39 @@ import cx from 'classnames'
import PropTypes from 'prop-types'
import useOnScreen from '@s-ui/react-hooks/lib/useOnScreen'
+import PrimitiveVisuallyHidden from '@s-ui/react-primitive-visually-hidden'
+
+import {BASE_CLASS, CLASS_CONTENT, CLASS_SCROLLER, TABS_JUSTIFY_CONTENT, TYPES, VARIANTS} from '../config.js'
+
+const Wrapper = ({isActive, keepTabsContentMounted, children, id, numTab, ...props}) => {
+ if (isActive) {
+ return (
+