Skip to content

Show a subtitle under a menu row's label - #228

Draft
simonhamp wants to merge 5 commits into
mainfrom
feat/menu-item-subtitle
Draft

simonhamp wants to merge 5 commits into
mainfrom
feat/menu-item-subtitle

Conversation

@simonhamp

@simonhamp simonhamp commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Menu rows (:menu, :context-menu, :trailing-menu) can now show a subtitle: a second, smaller line under the label. The devnull app wants it for its Post as menu, where "Simon (@simon-hamp)" wraps onto two lines. With this the row reads "Simon" with "@simon-hamp" underneath.

This is stacked on #224 (menu row pictures and ticks), because it touches the same row renderers. Merge that first, or retarget this to main once it's in.

It depends on NativePHP/mobile-air#740, which adds NavAction::subtitle() to core. Apps set it like any other row option:

NavAction::make('me')->label('Simon')->subtitle('@simon-hamp')->icon(...)

The renderers read the subtitle prop, so without #740 nothing breaks; there's just no way to set it short of ->toElement()->setProp('subtitle', ...). An earlier version of this PR had a MenuItem::subtitle() helper to work around the missing method. That's gone now.

iOS. NativeUIMenuItem puts the label, then the subtitle, then the picture or icon straight into the row's Button (or Toggle, for a ticked row). A SwiftUI Menu draws the second Text as the row's subtitle (it's UIAction.subtitle underneath), for plain, icon, picture and checked rows alike. VoiceOver reads the label and then the subtitle.

The rows used to wrap the text in a Label with the picture or icon as its icon. A menu drops a second Text inside a Label's title, which is why the first version of this PR showed no subtitle on a phone. Without a subtitle the flat version draws the same row as the Label did. I checked all of this in a small SwiftUI app on an iOS 26.2 simulator, with and without subtitles, including a destructive row.

Android. renderAttachedMenuItem puts the label and subtitle in a Column, the subtitle in bodyMedium and onSurfaceVariant. TalkBack reads both as part of the row. Rows without a subtitle are drawn as before.

What to check: iOS picks the menu's width, so a long subtitle may still truncate. I haven't run the fixed version on a device yet.

Checks: Pest 536 passed against core at mobile-air#740 (MenuItemSubtitleTest). swiftc -typecheck -wmo over mobile-air's NativeRender plus resources/ios gives the same 152 errors as #224's head, and a canary in the new code was caught. Kotlin: compiling ContainerRenderers.kt in tests/android (core's other files missing) gives the same 24 errors as #224's head, none in the new lines.

🤖 Generated with Claude Code

simonhamp and others added 3 commits November 20, 2026 22:53
A :menu, :context-menu or :trailing-menu row can now carry an image
(an account's avatar, say) in place of its icon, cut to a circle or,
with image_shape "rounded", a rounded square. The icon shows while the
picture loads and stays if it fails. A row with checked has a tick, for
the option a menu has picked.

Core's NavAction already sends image. image_shape and checked go on the
element with setProp:

    NavAction::make('me')->label('Simon')->icon(...)->image($avatar)
        ->toElement()->setProp('checked', true)

iOS: a SwiftUI Menu is a UIMenu underneath, which can't load or clip an
image itself. NativeUIMenuImages fetches the pictures as soon as the
pressable, button or row that opens the menu is on screen, cuts them to
shape at 24pt and hands the rows ready-made images. A checked row is a
Toggle, so iOS draws its own tick. The three copies of the row renderer
(pressable, button, list item) are now one, NativeUIMenuItem.

Android: renderAttachedMenuItem loads the picture with Coil, clipped to
shape, and puts a tick at the end of a checked row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A :menu, :context-menu or :trailing-menu row can now carry a subtitle,
a second, smaller line under its label, such as an account's handle
under its name. It goes on the element with setProp, like image_shape
and checked:

    NavAction::make('me')->label('Simon')->icon(...)
        ->toElement()->setProp('subtitle', '@simon-hamp')

iOS: the row's title is a second Text after the label, which a SwiftUI
Menu draws as the row's subtitle (UIAction.subtitle underneath).
VoiceOver reads both.

Android: renderAttachedMenuItem puts the subtitle under the label in a
Column, in bodyMedium and onSurfaceVariant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
NavAction is in core and has no subtitle method yet, so this gives
apps a typed way to set the prop, and a class they can check for to
tell whether the installed mobile-ui draws subtitles.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
simonhamp and others added 2 commits November 21, 2026 13:21
Core now has NavAction::subtitle() (NativePHP/mobile-air#740), so the
stop-gap MenuItem::subtitle() helper goes. The renderers still read the
same `subtitle` prop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A menu drops a second Text nested in a Label's title, so rows with a
subtitle showed only their label. Put the texts and the picture or icon
straight into the Button or Toggle instead. The menu reads that as title,
subtitle and image for plain, icon, picture and ticked rows, and rows
without a subtitle look the same as before. Checked on an iOS 26.2
simulator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from feat/menu-item-images to main November 24, 2026 09:32
simonhamp added a commit to NativePHP/mobile-air that referenced this pull request Nov 24, 2026
A menu row can now carry a second, smaller line under its label, such
as an account's handle under its name:

    NavAction::make('me')->label('Simon')->subtitle('@simon-hamp')

It's serialised as a `subtitle` prop, the same way `image` is, and
TopBarAction now accepts it as an attribute. Null or an empty string
clears it. mobile-ui's menus draw it (NativePHP/mobile-ui#228). Core's
own top-bar buttons and menus don't draw it yet.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant