Site icon R-bloggers

How to Make Your Shiny App Beautiful

[This article was first published on Tag: r - Appsilon | Enterprise R Shiny Dashboards, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Shiny apps are very often used for quick prototyping and proof of concept.

However, if you want to use a Shiny app in production and make it attractive to the users, you need to make sure that the app is not only functional but also visually appealing and efficient.

When users find the UI attractive, they are more likely to use the app and forgive minor usability issues. This aesthetic-usability effect is related to people’s tendency to perceive attractive products as more usable. They usually believe that things that look better will work better, which may not reflect reality.

On one side, this effect can distort the process of finding real issues in UI during usability testing, but on the other side, it could be taken to our advantage to some extent. The aesthetic-usability effect is the main reason why a good user experience shouldn’t only be a functional UI – it should also be a beautiful UI.

In this blog post, I will show you how to improve the design of your Shiny app and how to make the code more efficient for some use cases.

TL;DR:

Table of Contents


Design Improvements

Even without a design mockup, you can make your Shiny app look good by following some logical rules. Of course, artistic talent helps, but a lot of things that make the UI intuitive and beautiful can be learned.

Keep in mind that you shouldn’t follow all these rules blindly because, in some cases, there may be some exceptions. Rather than treating them as strict rules, think of them as helpful guidelines that work well in most cases.

In this blog post, I will focus on user interface improvements (visual and interaction aspects) and code refactoring. I will not cover the topic of user experience (UX) design, which is a much broader topic. However, I will mention some UX design aspects that are related to UI design.

1. Minimize the Cognitive Load

Cognitive load is the user’s brain effort required to use an interface. Minimize cognitive load to make your UI user-friendly and easy to use. Your users will appreciate it. There are many ways to reduce cognitive load; some of them are:

< !--[if lt IE 9]>< ![endif]--> < video class="wp-video-shortcode" id="video-23082-1" width="450" loop="1" autoplay="1" preload="metadata" controls="controls">< source type="video/webm" src="https://wordpress.appsilon.com/wp-content/uploads/2024/02/shiny-enterprise.webm?_=1" />https://wordpress.appsilon.com/wp-content/uploads/2024/02/shiny-enterprise.webm

2. Visual Hierarchy

Visual Hierarchy is a visual design principle that helps to organize UI elements in a way that users can easily perceive the importance of each element. It helps to draw attention to the most important elements and to make the UI more intuitive.

Without a clear visual hierarchy, too many elements seem to be important, and in this case, none is. When you follow visual hierarchy rules, you can influence users’ perception and guide them to perform desired actions. It can be achieved by using different visual properties, such as size, color, contrast, alignment, repetition, proximity, whitespace, texture and style. I’ll describe some of them in more detail.

Color

Color is one of the most powerful tools in UI design. It can be used to draw attention to the most important elements, to group elements, to create a mood, to make it more accessible, and so on.

< video class="wp-video-shortcode" id="video-23082-2" width="450" loop="1" autoplay="1" preload="metadata" controls="controls">< source type="video/webm" src="https://wordpress.appsilon.com/wp-content/uploads/2024/02/color_importance.webm?_=2" />https://wordpress.appsilon.com/wp-content/uploads/2024/02/color_importance.webm

uxmisfit.com

View 1  View 2  About  Contact

Contrast

Size

Elements size and weight matter. The bigger and bolder the element, the more attention it attracts. Use bigger size and weight for primary information and smaller for secondary one.

 

Typography & Iconography

  1. If possible, use the client company’s in your application. If not, try to find a similar one. It’s good to use a that is related to the client’s brand. In other cases, pick the one that fits the style of your app. The rounded seems to be more playful, while the sharp seems to be more formal.
  2. Remember to use the selected consistently everywhere. In some cases, a secondary family could also be used, for example, for text in paragraphs. The uniformity and consistency here sound like a minor detail, but it makes a difference.
  3. Use icons to indicate the meaning of the information upfront:
    • Their meaning should be clear for the users (clarity rule). Also, don’t use the same icon for two different meanings.
    • Their design should be simple and consistent in the UI. If you decide to use linear-style icons, it’s usually better not to mix them with solid-style icons.

Managing Screen Real Estate, Positioning, Spacing

  1. Progressive disclosure – Don’t try to fit too much information on one screen. Use progressive disclosure techniques to prevent overloading the user with too much information.
  2. Effectively use the real estate on the screen – but don’t make the UI too dense. Add some white space by increasing paddings, margins or gaps to make the UI lighter and less cluttered. The white space promotes balance and visual order; don’t underestimate its superpower in attractive interfaces.
  3. Make data visualization elements adjust to the screen size whenever possible. Check if it works correctly on smaller or bigger screens by zooming in/out in the browser.
  4. Whitespace – The more whitespace around a component, the more attention it attracts. Use space to emphasize the most important elements.
  5. According to F and Z reading patterns, the top left part of the app should display the most important information (culturally influenced).
  6. Grouping – Group related elements together to make the UI more intuitive (e.g. filters, metrics, data visualizations). Use the same spacing for elements in a group to make it clear they are related. It’s a good idea to use multiple box/card components for grouping.

3. Consistency

Consistency is the key to creating a visually attractive interface with a sense of order and professionalism. The important step to achieve it is to use a design system containing predefined styles, modular components, usage guidelines, etc.

  1. Uniformity – use the same styles for the components which are related.
  2. Standardization – use standardized components, like buttons, forms, and icons, creating a design language that is familiar to the users.
  3. Use a consistent color palette, typography and iconography based on the design system.
  4. Details like border-radius or box shadows should also be consistent across the app and included in the design system.

4. Minimize interaction cost

It’s the sum of mental, physical and time efforts a user invests to interact with UI. It includes actions like looking, thinking, searching, scrolling, reading, clicking, waiting, typing, etc.

  1. Optimize the amount of clicks and scrolling to perform some action.
  2. Keep related actions close – according to Fitts’s Law, the closer and larger a target, the faster it is to click on that target.
  3. Reduce distractions – optimize the amount of information on the screen, and keep it simple and clean.
  4. Minimize choice to speed up user’s decisions – e.g. hide some filters or secondary settings in the popover element.

Explore reactable.extras 0.2.0: Elevate your Shiny apps with enhanced interactivity and efficiency. Dive into the new features now.

5. Efficiency / Performance

Application loading speed is one of the most important factors influencing user experience (UX).

Learn how ‘shiny.worker’ can offload heavy calculations, speeding up your app’s performance. Click here to discover more.

6. Other

< video class="wp-video-shortcode" id="video-23082-3" width="450" loop="1" autoplay="1" preload="metadata" controls="controls">< source type="video/webm" src="https://wordpress.appsilon.com/wp-content/uploads/2024/02/animation.webm?_=3" />https://wordpress.appsilon.com/wp-content/uploads/2024/02/animation.webm

Sass Code Refactoring

This part is related to the Sass/CSS and HTML code refactoring. I listed some suggestions regarding the code quality, best practices, and developers’ frequent mistakes.

The most important thing is to be consistent and use the same convention for specific cases. top_navBar-dark is definitely not a good choice for a class name.

This code:

.parent-element {
& .child-element {
...
}
}

Is equivalent to this code:

.parent-element {
.child-element {
...
}
}
.parent {
display: flex;
gap: 10px;

.child-1 {
padding-bottom: 10px;
}

.child-2 {
margin-top: 10px;
}
}

you could just use gap property:

.parent {
display: flex;
gap: 30px;
}

Instead of:

transition: all 0.2s;

use

transition: background-color 0.2s, color 0.2s, border-color 0.2s;

Conclusion

You can significantly improve the user experience and visual appeal of your Shiny app by having a clear visual hierarchy, minimizing cognitive load and interaction cost, implementing a design system consistently and improving your app’s performance. At the same time, don’t forget about keeping your Sass/CSS code clean and optimized.

Last but not least, it’s very important to watch the examples of dashboard apps with a good design and analyze what works well and what could be improved. You will not only learn a lot from it but also gain some inspiration and a good eye for design.

Here is a list of websites where you can find a lot of examples of good-quality dashboards and other app designs:

You’ve just explored a wealth of strategies on design, efficiency, and code optimization. Ready to take your Shiny app to the next level? Contact us, and let’s get started on optimizing your app’s performance and aesthetics together!

You May Also Like

The post appeared first on appsilon.com/blog/.

To leave a comment for the author, please follow the link and comment on their blog: Tag: r - Appsilon | Enterprise R Shiny Dashboards.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Exit mobile version