Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ToggleButtons can display only icons #15530

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from

Conversation

thaqebon
Copy link

@thaqebon thaqebon commented Feb 6, 2025

Description

Add onlyIcons() to ToggleButtons to hide option labels and display only icons:

  • Hides button labels by setting them as sr-only.
  • Optionally consider option labels as icons when using options() to skip the use of icons().
use Filament\Forms\Components\ToggleButtons;

ToggleButtons::make('status')
    ->options([
        'draft' => 'Draft',
        'scheduled' => 'Scheduled',
        'published' => 'Published'
    ])
    ->icons([
        'draft' => 'heroicon-o-pencil',
        'scheduled' => 'heroicon-o-clock',
        'published' => 'heroicon-o-check-circle',
    ])
    ->onlyIcons()

Or

ToggleButtons::make('status')
    ->options([
        'draft' => 'heroicon-o-pencil',
        'scheduled' => 'heroicon-o-clock',
        'published' => 'heroicon-o-check-circle',
    ])
    ->onlyIcons(optionLabelAsIcon: true)

Visual changes

Before: option label is an empty string
before
After: use onlyIcons()
after

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

- Hide button labels by setting them as sr-only
- Optionally consider option labels as icons when using `->options()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

1 participant