Groupings

Overview

As a Page grows, a long column of controls gets hard to follow. Paper forms solve this by putting related questions in a box, such as the parts of an address. In a Form, a grouping does the same job. In this tutorial, you will use groupings to put buttons side by side, to make titled sections called cards, and to make a row of buttons along the bottom of a Page. You will also find out how people who design screens for a living decide what belongs together.

Goals

You have the following goals for this lesson:

By the end of this lesson, you can

  • Put buttons side by side in a grouping with no title
  • Organize a Page into cards with titled groupings, under a banner
  • Add a footer of buttons to the bottom of a Page
  • Describe how web developers and digital designers break a screen into parts and work as a team

Warm up

Think of a screen you use often, such as a music app or a school website. Which parts of it belong together? Pick two parts that sit in the same box or row, and say why someone might have put them there.

Vocabulary

You will be learning about the following vocabulary words:

Vocabulary
TermDefinition
GroupingA set of controls on a Page that belong together, such as the parts of an address.
CardA grouping with a title, drawn as a box around its controls.
FooterA row of buttons, such as Back and Next, along the bottom of a Page.
DecomposeTo break a big problem or design into smaller parts that are easier to work on.
Digital DesignerA person whose job is to plan and test the layout and navigation of websites and app screens.

New Code to Learn

You will be using the following new pieces of code:

New Code to Learn
Quorum CodeCode ExampleExplanation
use Libraries.Interface.Forms.Groupinguse Libraries.Interface.Forms.GroupingLets your program use the Grouping class.
PAGE:AddGrouping(NAME)Grouping pet = page:AddGrouping("Your pet")Adds a grouping to the Page and returns it.
GROUPING:AddButton(NAME)colors:AddButton("Red")Adds a button to the grouping. A grouping has the same Add actions as a Page, such as AddLabel and AddTextField.
GROUPING:SetTitle(TEXT)pet:SetTitle("Your pet")Gives a grouping a title. A titled grouping is drawn as a card.
GROUPING:PositionFromBottom()buttons:PositionFromBottom()Places a grouping at the bottom of the Page.
GROUPING:SetLeadingButtonCount(COUNT)buttons:SetLeadingButtonCount(1)In a footer, puts this many of the first buttons on the left.

CSTA Standards

This lesson covers the following CSTA K–12 standards:

For teachers · 2026 CSTA K–12 Computer Science Standards

HS-SOC-CE-45

High School · Computing & Society

Analyze how diverse teams of people use computational thinking and computing technologies to solve problems and express ideas.

Also in 2 other lessons

HS-ALG-IM-09

High School · Algorithms & Design

Design a computing technology using human-centered design principles.

Also in 7 other lessons

MS-SOC-CE-44

Middle School · Computing & Society

Analyze how workers in different careers use computational thinking to solve real-world problems.

Only this lesson so far

Every standard, and the lessons that cover it

Explore

In Forms, you learned that a Page puts each control in its own row, from top to bottom. A grouping changes that for the controls inside it. page:AddGrouping(name) adds a grouping to the Page and gives it back to you. Then you add controls to the grouping, not the Page, with the same actions you already know, such as AddLabel, AddTextField and AddButton.

How a grouping is arranged depends on what you give it:

  • With no title, a grouping puts its controls side by side in one row, each with an equal share of the row's width.
  • With a title, set with SetTitle, a grouping is drawn as a card: a box around its controls, with the title at the top.
  • With only buttons, no title, and placed at the bottom with PositionFromBottom, a grouping becomes the Page's footer: a row of buttons along the bottom, with a line above it.

Buttons side by side

Here is the color picker from the Buttons tutorial, with its three buttons in a grouping with no title:

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Forms.FormBehavior
use Libraries.Interface.Forms.Grouping
use Libraries.Interface.Events.BehaviorEvent
use Libraries.Interface.Controls.Button
use Libraries.Game.Graphics.Label

class Main is FormBehavior
    action Main
        Form form
        Page page = form:GetMainPage()
        page:SetTitle("Pick a Color")

        Grouping colors = page:AddGrouping("Colors")

        Button red = colors:AddButton("Red")
        red:SetDescription("Choose red")
        red:SetBehavior(me)

        Button green = colors:AddButton("Green")
        green:SetDescription("Choose green")
        green:SetBehavior(me)

        Button blue = colors:AddButton("Blue")
        blue:SetDescription("Choose blue")
        blue:SetBehavior(me)

        page:AddLabel("Choice", "You haven't picked a color yet.")

        form:Display()
    end

    action Run(BehaviorEvent event)
        Button pressed = cast(Button, event:GetItem())
        Page page = GetPage()
        Label choice = page:GetLabel("Choice")
        choice:SetText("You picked " + pressed:GetName() + ".")
    end
end

Only Main changed. The Page's AddGrouping action makes the grouping, and the buttons are added with the grouping's own AddButton action. Now the three buttons sit in one row. Tab still moves through them in order, left to right, and then on to the label.

Cards, footers and banners

You met banners in the Forms tutorial. A banner is a special grouping for the top of a Page. When a card comes right after a banner at the top of a Page, the card rises a little into the banner, so the two read as one header.

This Page, from a made-up pet-sitting app, uses a banner, two cards and a footer:

use Libraries.Interface.Forms.Form
use Libraries.Interface.Forms.Page
use Libraries.Interface.Forms.Grouping
use Libraries.Interface.Controls.TextField

Form form
Page page = form:GetMainPage()

page:AddBanner("Pet Sitter", "Tell us about your pet")

Grouping pet = page:AddGrouping("Your pet")
pet:SetTitle("Your pet")
pet:AddLabel("Pet name prompt", "Pet's name")
pet:AddTextField("Pet's name")
pet:AddLabel("Kind prompt", "Kind of animal")
TextField kind = pet:AddTextField("Kind of animal")
kind:SetDescription("For example, cat, dog or rabbit")

Grouping care = page:AddGrouping("Care")
care:SetTitle("Care")
care:AddLabel("Food prompt", "Food")
care:AddTextField("Food")
care:AddLabel("Medicine prompt", "Medicine, if any")
TextField medicine = care:AddTextField("Medicine")
medicine:SetDescription("Optional. Leave it empty if your pet takes no medicine")

Grouping buttons = page:AddGrouping("Buttons")
buttons:AddButton("Back")
buttons:AddButton("Next")
buttons:PositionFromBottom()
buttons:SetLeadingButtonCount(1)

form:Display()
Blocks

SetLeadingButtonCount(1) puts the footer's first button, Back, on the left, apart from the others. That is where a Back button usually goes. The buttons don't do anything yet. You could give them a behavior, as in Pages, to move between Pages.

A few things to notice:

  • Find controls the same way. page:GetTextField("Pet's name") finds the text field even though it is inside a grouping. The Page searches inside its groupings for you.
  • Tab order follows the order you add things. Tab goes through the banner, then each card, then the footer. The footer was added last, so it comes last, which matches where it sits on the Page. If you added it first, it would still be placed at the bottom, but Tab would reach it first. Add things in the order a person reads them.
  • Titles take the focus. The banner's title and each card's title can take the focus, so a screen reader user reaches "Your pet" before the fields in that card, and knows what the fields are about.

A grouping can also arrange its controls in its own way, using a layout. That comes much later, in the Layouts tutorial. Some controls always go in a grouping; you will meet one in Radio Buttons.

Grouping is a job skill

Deciding what goes in each card is a kind of decomposition: breaking a big screen into smaller parts, each about one thing. It is part of real jobs. The US Bureau of Labor Statistics describes digital designers as people who develop and test the layout, functions and navigation of websites and interfaces. The duties it lists for web developers and digital designers include meeting with clients about what a site needs, working with other team members to decide what information a site will contain, working with graphic designers on its layout, and making prototypes and mockups (source).

Notice that much of this is teamwork. A client knows what the site is for, other team members decide what information it holds, and designers decide how it is laid out. Each person brings a different view of the same problem. Think about the Pet Sitter page: who might know best what belongs in the "Care" card, a pet owner, a pet sitter or a programmer? Why might a team that includes all three build a better Page than any one of them alone?

Engage

The goal of this activity is to build a small Page with one card and a row of buttons. Choose a made-up topic, such as a book club, a bake sale or a school play. First, on paper, list everything the Page should show. Circle the items that belong together in one card, and pick three short actions, such as "Join", "Remind me" and "Share", for a row of buttons.

Now build it. Your Page needs:

  • a banner with a title;
  • one grouping with a title (a card) that holds at least two labels;
  • one grouping with no title that holds three buttons side by side.

Give each button a description. Run your Page and move through it with only Tab. Check that you reach the banner, the card's title, the labels in the card, and then the buttons, in that order. If you have time, give the buttons a behavior that changes a label, as in the color picker.

Last, write one sentence explaining why you put the items in your card together.

Wrap up

Designers and developers break screens into parts before they build them. Think of a job you might like someday, in or out of computing. What is one big problem in that job that people solve by breaking it into smaller parts? Who would you need on your team to solve it well?