Walkthrough
Learn how to incorporate all of the built-in styling utilities to build responsive and stylistic views.
Getting Started
Rock Mobile provides a rich set of typography, color, and utility classes designed to make building responsive and visually consistent UIs easy. These classes can be used not only within the predefined blocks and components but also in your own custom XAML layouts.
Enough talk... let's dive in! In this walkthrough, we're going to build a "Person" card that automatically adapts to both light and dark modes, ensuring a seamless user experience regardless of the theme.
To start, let's create the base of our "Person" card. This card will display a person's name in a simple yet elegant design, leveraging the utility classes provided by the mobile shell. Here's the XAML code for our base card:
Let’s take a closer look at what’s happening in this XAML code. There are two elements that utilize our custom utility classes.
<Rock:StyledBorder>
: This is a custom border element that provides styling options through theStyleClass
property. We provide the following styles:p-16
: Adds padding of 16 units inside the border, giving the content some breathing room.bg-interface-softest
: Sets the background color to the softest level of the interface color palette, ensuring high contrast and readability.border
: Applies a 1px border around the element.border-interface-soft
: Sets the border color to a soft tone from the interface color palette, providing a subtle yet distinct outline.rounded
: Applies an 8px border radius to the frame.
<Rock:Avatar>
: Displays an avatar for the current person.<Label>
: Displays the person’s name. TheLabel
is styled to stand out prominently on the card.StyleClass="text-interface-strongest, title3, bold"
:text-interface-strongest
: Ensures the text color is the strongest, providing excellent readability.title3
: Applies a title-like font size, making the name visually prominent.bold
: Further emphasizes the text by making it bold.
<Rock:Tag>
: Displays the person's campus and record status. Under the hood, these tags use our interface colors dependent on theType
.
Applying these styles results in a theme-responsive card.
In this walkthrough, we've explored how to leverage Rock Mobile's powerful built-in styling utilities to create responsive and visually appealing user interfaces. By using these utilities, you can ensure that your designs are both consistent and adaptable, providing a seamless user experience across different themes, including light and dark modes.
Last updated