BY Shubham Khare27 Jun 2022 Edit
Expander

WebAtoms Expander

This article explains Expander control in detail and highlights a way to implement this control which is present in the WebAtoms framework. The Expander is the user interface control imported from the WebAtoms library.

What is Expander control?

WebAtoms Expander is the functional component. For implementing the Expander control, there is no need to extend it into our class component. It helps in easy implementation of the layout, which is needed to expand and collapse, which can help add multiple interacting options on a single screen.

Properties of Expander control

  • icon - icon is a string property used in assigning the icon code or path name. It is an optional property utilized for enhancing the layout by displaying icons.

  • isExpanded- isExpanded is a boolean property that expands the form layout when set to true and collapses when set to false. By toggling the isExpanded property, we can expand or collapse the view on some DOM event.

How to implement the Expander control?

In this example, we will use the Expander control to display a form in separate sections where each section is a separate Expander, shown separately in the ExpanderDemoScreen.

Code for ExpanderDemoScreen

In this example, we will create three simple forms inside an Expander where each Form in the Expander has unique user fields. The layout of the screen only allow one Form to display at a time. When one Form is in an expanded state, the other two remain collapsed.

image

image

image

Code snippet for css of ExpanderDemoScreen

image

Code snippet for ExpanderDemoViewModel

The logic for implementing desired expand and collapse behavior.

image

Advantages of Expander

  • Expander control helps create layouts having a master-detail flow. Mainly beneficial when there is a requirement for implementing single-page applications.

  • We can generate dynamic layouts, as Expander gives us control over the view displayed when a particular event has occurred.

  • An Expander control is beneficial when there is a requirement of showing only a part of a large layout at a time, making it efficient in small screen sizes.

  • The Expander control is a lightweight and responsive control.

  • 'Expander' can be expanded or collapsed without defining any event.

  • As 'Expander' is a functional component hence it is reusable and gets initialized in the constructor of the class component.

BY Shubham Khare
LikeCommentSave
LikeCommentSaveShare
0
Categories
General
YantraJS
Developer Guides
Tutorials
Web Atoms Updates

POPULAR POSTS
17 Mar 2021
LATEST ACTIVITY
Simmi Kava
commented this post.
Simmi Kava
liked this post.
Show more
ARCHIVES
2024
2023
2022
2021
TAGS
javascript (56)
developer (25)
javascriptdeveloper (16)
Xamarin.Forms (16)
Html (14)
typescript (12)
webatoms (12)
xamarin (11)
coding (10)
web-atoms (10)
arrays (9)
android (8)
javascript-developer (8)
csharp (7)
dotnet (7)
css (6)
update (6)
dotnet-standard (5)
function (5)
iOS (5)
methods (4)




Web Atoms: JSX (TSX + TypeScript) for Xamarin.Forms, Hot Reload Your App in Production Environment

PlaygroundSamples Repository