Widgets
Design Home Screen and Lock Screen widgets in the Builder, on their own or as part of an app that shows the app's data, and put them on your iPad.
A widget is a small view on your iPad's Home Screen or Lock Screen: a streak, today's water, a countdown. You design one in the Builder, with the same components, formulas and AI Agent as an app.
There are two kinds:
- A widget project stands on its own. Make one from New, and pick Widget.
- An app's widget belongs to an app and shows the app's data: the values it remembers after it closes. Add one in the app's Screens. See An app's widget.
#Make a widget project
- Tap New Widget on Home or in Widgets. (Or tap New App and pick Widget at the top of the sheet.) The sheet's title says New Widget.
- Give it a name and a description, and tap Create.
The Builder opens on a starter widget: a symbol, the widget's name, and a caption. Change it as you would a screen.
#Widget sizes
The canvas shows the widget at one of iPadOS's widget sizes. Pick another from the size menu in the toolbar, where an app has iPhone and iPad. When both side panels are open, the sizes are in the toolbar's ⋯ menu. The rest of the toolbar is the same as an app's, the AI Agent and Preview, except Finish: a widget goes on your Home Screen from Widgets.
| Size | Points | Where |
|---|---|---|
| Small | 170 × 170 | Home Screen |
| Medium | 379 × 170 | Home Screen |
| Large | 379 × 379 | Home Screen |
| Extra Large | 795 × 379 | Home Screen |
| Lock Screen Circle | 76 × 76 | Lock Screen |
| Lock Screen Rectangle | 172 × 76 | Lock Screen |
One design shows at every size, so make it fit them all. Set the outer stack's Width and Height to Fill (see Width and height), keep text short, and check each size. The Lock Screen draws widgets in one tint, on a dark background.
#What a widget can show
A widget can't be typed into, scrolled, or play things, so the Library leaves out the components that need that:
- text fields and other inputs, sliders, steppers, pickers and menus
- lists, forms and scroll areas
- navigation and tabs
- web views, maps and video
Everything else works: text, labels and SF Symbols, your project's images and fonts, pictures from the web, stacks and grids, shapes and gradients, gauges, progress bars and charts, with values and formulas. Buttons and switches work too: see below.
#Buttons and switches
Tap a widget's Button or Switch on the Home Screen, and its steps run right there, without opening PadCode. A Did keto today button can add to a streak, and a switch can tick off a habit. The widget then shows the change.
- What a tap changes is kept only in variables that are remembered. Remember every variable a widget's button or switch changes.
- In an app's widget, the change is the app's too. The next time the app runs, in Preview or from My Apps, it starts from what the widget changed.
- Steps that show something, like an alert, a sheet, another screen or the camera, do nothing in a widget.
- Tapping anywhere else on the widget opens PadCode: the app, for an app's widget, or the widget's project.
#Pictures and data from the web
A widget's When Shown steps run before it's drawn: Call API, for example, can fill a variable with today's weather or a price. Pictures from the web show too, with a Web Image.
#When a widget updates
- When something changes: you edit it in the Builder, its app saves a remembered value, or you tap one of its buttons.
- When you tap a refresh button: a button with a Refresh Widget step draws the widget again and runs its When Shown steps again, so data from the web is fetched again.
- Every minute, when a formula in it uses
today()ornow(). Text in a date's Timer or Relative style counts by itself, every second. - About every 15 minutes, when it has When Shown steps, to fetch its data again. iPadOS decides exactly when.
- When you ask: PadCode's Reload Widgets action in the Shortcuts app draws every PadCode widget again and runs their When Shown steps. Use it in an automation, for example every hour or when you get home, to keep data from the web fresh. You can also say "Reload PadCode widgets" to Siri.
#Preview
Tap Preview in the toolbar to try the widget as it runs on your Home Screen, big enough to tap. Pick a size at the top. Its buttons and switches run their steps, what they change is kept, its When Shown steps run, and formulas with the time move on each minute. Tap Done editing to go back to the Builder.
#Ask the AI Agent
The AI Agent works on widgets too. In a widget project it keeps to one screen that fits every size. In an app, it adds a widget when you ask for one. Either way, it can't put in a component a widget can't show, and it remembers the variables a widget's buttons change.
#An app's widget
An app can have widgets of its own. They use the app's variables, and show the values the app remembers. A habit tracker's widget can show today's streak, for example. There are two ways to add one.
From New:
- Tap New Widget on Home or in Widgets, or New App and pick Widget.
- Under For, pick the app. The sheet asks only for the widget's name: it goes in the app.
- Tap Create. The app opens in the Builder, on its new widget.
From the app:
- Open the app in the Builder, and open Screens in the left panel.
- Under Widgets, tap Add widget.
Either way, the canvas switches to widget sizes. Design the widget like any widget, using the app's variables in its formulas. To rename it, tap its name in the Screens list while it's selected.
Tap one of the app's screens to go back to it, on the device you were using. To delete a widget, touch and hold it in the list, then tap Delete Widget.
An app's widgets aren't screens. Go to Screen and Page Link don't list them, and Issues shows an error if a step goes to one. The app always opens on its first screen, never on a widget.
The widget shows what the app remembers: what it saved the last time it ran, in Preview or from My Apps, or what the widget's own buttons changed since. Tapping it, anywhere but a button or switch, opens the app.
#Put a widget in a slot
PadCode's Home Screen widget can show any of your widgets: it shows the one in its slot. Open Widgets from PadCode's sidebar.
- Your widgets lists every widget, drawn small, with the app it belongs to and the slots it's in. Tap one to open it in the Builder.
- On your Home Screen has the three steps to add one, then a slot for each widget PadCode can show. Pick a size above them, Small to Lock Screen: each size has its own slots, Small 1, Small 2 and so on.
Under a slot, tap Choose… and pick a widget. To empty a slot, choose Empty. PadCode Free fills one slot: you can change or empty it, and filling a second shows what Pro adds (see Plans and billing).
An app's widget is listed with the app's name first, like Habit Tracker · Streak.
A slot shows its widget the way the Home Screen will. Tap it to open its project in the Builder. When you change a widget, your Home Screen shows the change a moment later.
#Add it to your Home Screen
- Touch and hold an empty spot on the Home Screen, tap Edit, then Add Widget.
- Search for PadCode, tap it, and swipe to the size you want. Tap Add Widget.
- The widget shows its size's first slot, for example Small 1. To show another, touch and hold the widget, tap Edit Widget, and pick a slot.
For the Lock Screen, touch and hold the Lock Screen, tap Customize, then the Lock Screen, and add PadCode's widget under the clock.
Each PadCode widget you add picks its own slot, so you can have several on your iPad at once.
#Share a widget
A widget project shares as a .padwidget file: tap Share in the project's menu. Opening one in PadCode shows it read-only first: tap anything to see how it's made, or Preview to try it running. Add Widget adds it to your projects; Cancel leaves no trace. An app's widgets go with the app, in its .padcode file.
#Get one from the Marketplace
The Marketplace's Widgets tab has ready-made widgets: an Analog Clock whose hands move, Water with a + Glass button, a Countdown, the weather and more. Tap Get: it opens read-only first, with Preview to try it. Add Widget adds it to your projects, to change as you like in the Builder. Then put it in a slot. See The Marketplace.