Documentation
Feedback
Guides
VTEX IO Apps

VTEX IO Apps
Layout Apps
Disclosure Layout
Official extension
Version: 1.0.4
Latest version: 1.0.4

{"base64":"  ","img":{"width":110,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/all_contributors-0-orange.svg?style=flat-square"}}

The Disclosure Layout app creates a layout structure based on disclosure indicators.

{"base64":"  ","img":{"width":658,"height":392,"type":"gif","mime":"image/gif","wUnits":"px","hUnits":"px","length":1021755,"url":"https://cdn.jsdelivr.net/gh/vtexdocs/dev-portal-content@main/images/vtex-disclosure-layout-0.gif"}}
Check this example

Configuration

Step 1 - Adding the Disclosure Layout app to your theme dependencies

In the manifest.json file of your theme, add the Disclosure Layout app as a dependency:


_10
"dependencies": {
_10
+ "vtex.disclosure-layout": "1.x"
_10
}

Now, you can use all the blocks exported by the disclosure-layout app. See the full list below:

Block nameDescription
disclosure-layout
{"base64":"  ","img":{"width":69,"height":20,"type":"svg","mime":"image/svg+xml","wUnits":"px","hUnits":"px","url":"https://img.shields.io/badge/-Mandatory-red"}}
Parent block that enables you to build the disclosure layout using its three children blocks: disclosure-trigger, disclosure-content, and disclosure-state-indicator.
disclosure-triggerDeclares the blocks that will be rendered as disclosure triggers, i.e., the blocks that, when clicked, will open or close the disclosure content (defined by the disclosure-content block).
disclosure-contentDeclares the blocks displaying the desired content when the disclosure trigger is clicked.
disclosure-state-indicatorOptional block that renders the chevron or other UI elements that change when the disclosure is opened or closed.
disclosure-layout-groupWraps many disclosure-layouts blocks at once. You can use this block to control when each should be displayed, allowing only one disclosure-layout open at a time.
disclosure-trigger-groupWraps many disclosure-trigger blocks at once. You can use this block to control when and how the disclosure-layouts blocks declared inside the disclosure-layout-group should be displayed.

Step 2 - Adding the Disclosure Layout blocks to your theme templates

Copy one of the examples below and paste it into your desired theme template, changing as necessary. If needed, add the disclosure-layout block to the block list of the template.

  • Simple example:

_21
{
_21
"disclosure-layout#simple": {
_21
"children": ["disclosure-trigger#simple", "disclosure-content#simple"]
_21
},
_21
"disclosure-trigger#simple": {
_21
"children": ["rich-text#question"]
_21
},
_21
"disclosure-content#simple": {
_21
"children": ["rich-text#answer"]
_21
},
_21
"rich-text#question": {
_21
"props": {
_21
"text": "How can I change my shipping address?"
_21
}
_21
},
_21
"rich-text#answer": {
_21
"props": {
_21
"text": "Call us at (212) 123-1234"
_21
}
_21
}
_21
}

  • Example using the disclosure-layout-group block:

_45
{
_45
"disclosure-layout-group#group": {
_45
"children": ["disclosure-layout#first", "disclosure-layout#second"]
_45
},
_45
_45
"disclosure-layout#first": {
_45
"children": ["disclosure-trigger#first", "disclosure-content#first"]
_45
},
_45
"disclosure-trigger#first": {
_45
"children": ["rich-text#question1"]
_45
},
_45
"disclosure-content#first": {
_45
"children": ["rich-text#answer1"]
_45
},
_45
"rich-text#question1": {
_45
"props": {
_45
"text": "How can I change my shipping address?"
_45
}
_45
},
_45
"rich-text#answer1": {
_45
"props": {
_45
"text": "Call us at (212) 123-1234."
_45
}
_45
},
_45
_45
"disclosure-layout#second": {
_45
"children": ["disclosure-trigger#first", "disclosure-content#first"]
_45
},
_45
"disclosure-trigger#second": {
_45
"children": ["rich-text#question1"]
_45
},
_45
"disclosure-content#second": {
_45
"children": ["rich-text#answer1"]
_45
},
_45
"rich-text#question2": {
_45
"props": {
_45
"text": "How can I track my order?"
_45
}
_45
},
_45
"rich-text#answer2": {
_45
"props": {
_45
"text": "After logging in to your account, you can find this information in the Orders link."
_45
}
_45
}
_45
}

  • Example using the disclosure-state-indicator block:

_10
{
_10
"disclosure-state-indicator": {
_10
"props": {
_10
"Show": "icon-angle--down",
_10
"Hide": "icon-angle--up"
_10
}
_10
}
_10
}

disclosure-layout props

Prop nameTypeDescriptionDefault value
initialVisibilityenumDefines the initial visibility of the layout content. Possible values are: visible (content initially open) or hidden (content is only displayed with user interaction).hidden
animatedbooleanDefines if the layout content should have animations. When set as true, this prop will enable additional data-\* attributes on the content, which you can use as selectors in CSS. It will also ensure that the element will be hidden once the transition has ended.false

disclosure-trigger props

Prop nameTypeDescriptionDefault value
ShowblockName of the block that will be rendered when prompted to show the content.undefined
HideblockName of the block that will be rendered when prompted to hide the content.undefined
asstringHTML tag to be applied to the component when rendered on the UI.button
childrenblockName of the block that will be rendered if no blocks are declared in the Show or Hide props.undefined
blockClassstringBlock ID defined by you that will be used in CSS customizations.undefined

disclosure-content props

Prop nameTypeDescriptionDefault value
blockClassstringBlock ID defined by you that will be used in CSS customizations.undefined
children[block]List of blocks that will render the desired disclosure content.undefined

disclosure-state-indicator props

Prop nameTypeDescriptionDefault value
ShowblockName of the block that will be rendered when prompted to show the content.undefined
HideblockName of the block that will be rendered when prompted to hide the content.undefined

disclosure-layout-group props

Prop nameTypeDescriptionDefault value
maxVisibleenumDefines how many disclosure-layout blocks should be displayed at a time. Possible values are: one (only one disclosure-layout block should have its content displayed at time) or many (different disclosure-layout block content can be displayed at time).one

disclosure-trigger-group props

Prop nameTypeDescriptionDefault value
ShowblockName of the block that will be rendered when prompted to show the content.undefined
HideblockName of the block that will be rendered when prompted to hide the content.undefined
asstringHTML tag to be applied to the component when rendered on the UI.button
childrenblockName of the block that will be rendered if no blocks are declared in the Show or Hide props.undefined
blockClassstringBlock ID defined by you that will be used in CSS customizations.undefined

Customization

To apply CSS customizations in this and other blocks, follow the instructions given in the recipe on Using CSS handles for store customization.

CSS handles
content
content--visible
content--hidden
trigger
trigger--visible
trigger--hidden
triggerGroup
triggerGroup--visible
triggerGroup--hidden
See also
VTEX App Store
VTEX IO Apps