When creating user interfaces in OutSystems, aligning items horizontally across different devices can be tricky, especially when building responsive layouts. In today’s dev tip, expert OutSystems Developer Izam Basiron compares two common methods for creating columns in OutSystems: the traditional column width approach and the more modern column widget. He also shares practical tips for aligning items using Flexbox, a powerful tool that offers more control and flexibility for responsive designs.
The column width method in OutSystems is a classic way to define layouts. It uses fixed fractional widths such as four-col or three-col to set column sizes.
The column widget, on the other hand, is based on Flexbox, a modern layout system that offers far greater control over how columns behave across different devices. Flexbox allows developers to fine-tune responsiveness, ensuring that layouts adjust smoothly depending on the screen size.
Flexbox is a versatile and reliable layout system that can help you create clean, professional UIs in OutSystems. Here are a few practical tips for aligning items horizontally using Flexbox properties:
To align a title with an icon, use display: flex. Apply align-items: baseline to ensure that the text and icon are aligned along the baseline of the text. Additionally, use justify-content: space-between to push the items to opposite ends of the container. This is perfect for creating a balanced layout with titles and icons.
// c/c++ .container { display: flex; align-items: baseline; justify-content: space-between; }
To align multiple items horizontally, apply display: flex and again use align-items: baseline. Add gap to create spacing between the items. To make one item fill the available space, use flex: 1. This will ensure your layout looks balanced and items are evenly distributed.
// c/c++ .item { flex: 1; }
To make sure items wrap onto the next line when the screen size is too small, apply flex-wrap: wrap. This, combined with flex: 1, ensures that your layout remains responsive and adaptable across different devices.
// c/c++ .container { display: flex; flex-wrap: wrap; }
Beyond basic layouts, the column widget in OutSystems can be extended with more advanced Flexbox properties:
You can set custom widths by using flex properties. For example, applying flex: 2 to the first and second columns and flex: 1 to the third column creates a more dynamic layout that better suits your content.
// c/c++ .column1 { flex: 2; } .column2 { flex: 2; } .column3 { flex: 1; }
Flexbox allows you to reorder columns based on screen size. For instance, you might want the third column to display first on mobile devices. By applying the order property, you can ensure that the most important content is visible first on smaller screens.
// c/c++ .column { order: 3; }
While the traditional column width approach is still useful for simpler layouts, the column widget, built on Flexbox, offers much more control and flexibility for responsive design. With these practical tips and advanced Flexbox techniques, you can create clean, responsive layouts that adapt perfectly to different screen sizes in OutSystems.
Want to learn more valuable Dev Tips? Sign up for our newsletter and stay updated with the latest insights! Also, don't forget to check out our upcoming OutSystems courses to scale your career.
[custom_like]