diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility.mdx
index 9f887df4c36..97c9bbbb59e 100644
--- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility.mdx
+++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility.mdx
@@ -7,6 +7,8 @@ showTabs: true
tabs:
- title: Info
key: '/info'
+ - title: Demos
+ key: '/demos'
- title: Properties
key: '/properties'
breadcrumb:
diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/Examples.tsx
index c119c01d735..b07724e544e 100644
--- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/Examples.tsx
+++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/Examples.tsx
@@ -1,20 +1,67 @@
+import React from 'react'
import ComponentBox from '../../../../../../shared/tags/ComponentBox'
-import { P } from '@dnb/eufemia/src'
-import { Form, Visibility } from '@dnb/eufemia/src/extensions/forms'
+import { Flex, P } from '@dnb/eufemia/src'
+import {
+ Field,
+ Form,
+ TestElement,
+ Visibility,
+} from '@dnb/eufemia/src/extensions/forms'
-export const BasedOnBooleanTrue = () => {
+export const BooleanExample = () => {
+ return (
+
+
+
+
+
+ Item 1
+ Item 2
+
+
+
+
+ )
+}
+
+export const InferData = () => {
return (
- This is visible
+ {() => {
+ const MyComponent = () => {
+ const [state, setState] = React.useState(false)
+ const inferData = React.useCallback(() => state, [state])
+
+ return (
+
+
+
+ This is visible
+
+
+ )
+ }
+
+ return
+ }}
)
}
-export const BasedOnBooleanFalse = () => {
+export const BasedOnBooleanTrue = () => {
return (
-
- This is not visible
+
+ This is visible
)
diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/demos.mdx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/demos.mdx
index 0279b53ed13..2082fbcc016 100644
--- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/demos.mdx
+++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/extended-features/Visibility/demos.mdx
@@ -6,14 +6,18 @@ import * as Examples from './Examples'
## Demos
-### Direct properties
+### Boolean example
-
+
-### False (not visible)
+### Direct properties
-
+
### Based on DataContext
+
+### InferData
+
+
diff --git a/packages/dnb-eufemia/src/extensions/forms/Visibility/Visibility.tsx b/packages/dnb-eufemia/src/extensions/forms/Visibility/Visibility.tsx
index 0ab8f02b035..43e6231b2f6 100644
--- a/packages/dnb-eufemia/src/extensions/forms/Visibility/Visibility.tsx
+++ b/packages/dnb-eufemia/src/extensions/forms/Visibility/Visibility.tsx
@@ -82,5 +82,5 @@ function Visibility({
return <>{children}>
}
-Visibility._supportsSpacingProps = true
+Visibility._supportsSpacingProps = 'children'
export default Visibility
diff --git a/packages/dnb-eufemia/src/extensions/forms/Visibility/__tests__/Visibility.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Visibility/__tests__/Visibility.test.tsx
index b92490d3561..3539e9e88d3 100644
--- a/packages/dnb-eufemia/src/extensions/forms/Visibility/__tests__/Visibility.test.tsx
+++ b/packages/dnb-eufemia/src/extensions/forms/Visibility/__tests__/Visibility.test.tsx
@@ -9,6 +9,10 @@ describe('Visibility', () => {
expect(screen.getByText('Child')).toBeInTheDocument()
})
+ it('should have constant of _supportsSpacingProps="children"', () => {
+ expect(Visibility._supportsSpacingProps).toBe('children')
+ })
+
describe('visibility-prop', () => {
it('renders children when visible is true', () => {
render(Child)