Skip to content

feature: show-label on top-bar actions - #527

Open
SRWieZ wants to merge 1 commit into
NativePHP:mainfrom
SRWieZ:feat/top-bar-action-visible-label
Open

SRWieZ wants to merge 1 commit into
NativePHP:mainfrom
SRWieZ:feat/top-bar-action-visible-label

Conversation

@SRWieZ

@SRWieZ SRWieZ commented Oct 3, 2026

Copy link
Copy Markdown
Member

What's wrong

Top-bar actions are always drawn as a bare icon. label is only read by screen readers, and an action with a label but no icon shows a generic "more" icon. Sometimes a word is clearer than an icon ("Add", "Edit").

What this does

A new opt-in show-label attribute draws the label:

  • label only → text button
  • icon + label → icon and text side by side

Without show-label, nothing changes. On iOS the toolbar would otherwise shrink a label down to its icon, so it's told to keep both. On Android it's a regular text button, so the disabled look and the touch ripple still work.

How to reproduce

The first two actions show their label, the third stays icon-only as before.

// routes/mobile.php
Route::native('/repro/top-bar-labels', \App\NativeComponents\TopBarLabels::class);
// app/NativeComponents/TopBarLabels.php
namespace App\NativeComponents;

use Illuminate\View\View;
use Native\Mobile\Edge\NativeComponent;

class TopBarLabels extends NativeComponent
{
    public int $count = 0;

    public function add(): void
    {
        $this->count++;
    }

    public function render(): View
    {
        return view('native.top-bar-labels');
    }
}
{{-- resources/views/native/top-bar-labels.blade.php --}}
<native:column class="w-full h-full bg-zinc-100 items-center justify-center">
    <native:top-bar title="Items">
        <native:top-bar-action id="add" label="Add" show-label @press="add" />
        <native:top-bar-action id="edit" icon="pencil" label="Edit" show-label @press="add" />
        <native:top-bar-action id="share" icon="square.and.arrow.up" label="Share" @press="add" />
    </native:top-bar>
    <native:text class="text-[17]">Presses: {{ $count }}</native:text>
</native:column>

A top-bar action always renders as a bare icon — the label prop is
a11y-only, and a label-only action falls back to the ellipsis /
more_vert placeholder. show-label makes the label visible: text alone
("Edit"-style), or icon + text when an icon is set. iOS needs
.labelStyle(.titleAndIcon) because toolbars collapse a Label to
icon-only; Android renders a TextButton so the M3 disabled tone and
ripple still apply. Unset keeps today's icon-only rendering.
@simonhamp

Copy link
Copy Markdown
Member

Does this respect custom text colours on Android the same way it does iOS?

Looks like import androidx.compose.foundation.layout.width is now imported twice

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.

2 participants