Popcorn Hack: Fill in the Blanks

  1. The checkbox on a toggle keeps track of whether it is on or off.
  2. The slider is the visible part of the toggle that changes color when it is turned on.
  3. The .switch class controls the toggle’s position, size, padding, and alignment.
  4. The border-radius property makes the slider have rounded edges.
  5. The &before class dictates the white circle of the toggle.

Popcorn Hack: Find the Bug

The toggle’s track <span> was missing its class. Adding ocs__toggle-track brings back the visible switch, and aria-hidden="true" tells screen readers to skip it because it is only for looks.

Challenge

Find the Bug: the track span now has the ocs__toggle-track class. Press Run and flip the toggle.

Lines: 1 Characters: 0
UI Output

Homework: Study Settings Panel

A settings panel with three toggles. Each one has its own label and controls a different part of the page:

Toggle What it does when it is on
Show Notifications Shows a callout with new lesson updates
Show Study Tips Shows a card with study tips
Highlight Due Dates Turns the due date cell into an accent cell

Under the toggles, a status line shows how many toggles are on, and it updates every time one is flipped. Comments in the JavaScript explain how each part works.

Challenge

Homework: three toggles that each change something on the page, plus a live count of how many are on. Press Run and flip the toggles.

Lines: 1 Characters: 0
UI Output