### Install the package
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Install the plugin via Composer.
```bash
composer require bezhansalleh/filament-language-switch
```
--------------------------------
### Configure Modal Display Mode
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Example of chaining configuration methods to set up a modal display with specific columns and width.
```php
$switch
->flags([...])
->itemStyle(ItemStyle::FlagOnly)
->displayMode(DisplayMode::Modal)
->columns(3)
->modalWidth('lg');
```
--------------------------------
### Configure Trigger Icon
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Customize the trigger icon using Heroicons or any installed Blade Icons package string.
```php
use Filament
Support
Icons
Heroicon;
// Just change the icon (style stays as default)
$switch->trigger(icon: Heroicon::GlobeAlt);
// Any Blade Icons string works too
$switch->trigger(icon: 'heroicon-o-globe-alt');
$switch->trigger(icon: 'phosphor-translate');
// Or change both in one call
$switch->trigger(
style: TriggerStyle::IconLabel,
icon: Heroicon::GlobeAlt,
);
```
--------------------------------
### Build the theme
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Compile the theme assets.
```bash
npm run build
```
--------------------------------
### Configure Control Panel Live Mode
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Toggle between live updates and manual staging mode for the control panel.
```php
$switch->controlPanel(live: false); // enabled + staged (Apply button)
$switch->controlPanel(true, live: false); // same thing, explicit
```
--------------------------------
### Enable Control Panel
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Enable the developer control panel within the configuration callback.
```php
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['en', 'fr', 'ar'])
->controlPanel();
});
```
--------------------------------
### Publish Plugin Views
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Publish the package views to your application for deep customization.
```bash
php artisan vendor:publish --tag="language-switch-views"
```
--------------------------------
### Configure theme CSS
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Add the plugin source to your custom theme's CSS file.
```php
@source '../../../../vendor/bezhansalleh/filament-language-switch/**';
```
--------------------------------
### Configure modal with grid
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Arrange modal locales into columns.
```php
$switch
->displayMode(DisplayMode::Modal)
->columns(2)
->modalWidth('lg');
```
--------------------------------
### Enable Language Switcher on Outside Panels
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Configure the switcher to appear on unauthenticated pages and set its placement.
```php
use BezhanSalleh\LanguageSwitch\Enums\Placement;
$switch
->visible(outsidePanels: true)
->outsidePanelPlacement(Placement::TopEnd);
```
--------------------------------
### Configure LanguageSwitch in Service Provider
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Register the locales within the boot method of a service provider.
```php
use BezhanSalleh\LanguageSwitch\LanguageSwitch;
public function boot(): void
{
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch->locales(['en', 'fr', 'ar']);
});
}
```
--------------------------------
### Configure modal display mode
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Enable modal mode with specific locales and width.
```php
use BezhanSalleh\LanguageSwitch\Enums\DisplayMode;
$switch
->locales(['en', 'fr', 'ar', 'de', 'es', 'pt', 'ja', 'ko', 'zh'])
->displayMode(DisplayMode::Modal)
->modalWidth('lg');
```
--------------------------------
### Enable Native Labels
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Display locale names in their own native language.
```php
$switch->nativeLabel();
```
--------------------------------
### Configure slide-over display
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Enable the slide-over variant for the modal display mode.
```php
$switch
->displayMode(DisplayMode::Modal)
->modalSlideOver();
```
--------------------------------
### Customize modal heading and icon
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Set custom text, icon, and color for the modal.
```php
$switch
->displayMode(DisplayMode::Modal)
->modalHeading('Choose Language')
->modalIcon('heroicon-o-language')
->modalIconColor('primary');
```
--------------------------------
### Render in User Menu
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Explicitly sets the render hook to place the switch inside the user profile menu.
```php
$switch->renderHook(PanelsRenderHook::USER_MENU_PROFILE_AFTER);
```
--------------------------------
### Set Placement Mode
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Define how the switcher is attached to the page using placement modes.
```php
use BezhanSalleh\LanguageSwitch\Enums\Placement;
use BezhanSalleh\LanguageSwitch\Enums\PlacementMode;
$switch->outsidePanelPlacement(Placement::TopCenter, PlacementMode::Pinned);
```
--------------------------------
### Configure Dropdown Placement
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Defines the direction in which the language dropdown menu opens.
```php
$switch->dropdownPlacement('top-end');
```
--------------------------------
### Force Pinned Overlay Placement
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Overrides automatic docking behavior to ensure the switcher remains a pinned overlay.
```php
use Filament\View\PanelsRenderHook;
// Force a body-start overlay even when a user menu is present
$switch
->outsidePanelPlacement(Placement::TopEnd, PlacementMode::Pinned)
->outsidePanelsRenderHook(PanelsRenderHook::BODY_START);
```
--------------------------------
### Set Display Locale
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Specify the language used for generating auto-translated labels.
```php
// Labels generated in French (e.g., "Anglais" for English)
$switch->displayLocale('fr');
```
--------------------------------
### Configure LanguageSwitch
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Use this configuration block to define supported locales, custom flag assets, display modes, and trigger styles within the LanguageSwitch service.
```php
use BezhanSalleh\LanguageSwitch\Enums\DisplayMode;
use BezhanSalleh\LanguageSwitch\Enums\TriggerStyle;
use BezhanSalleh\LanguageSwitch\LanguageSwitch;
use Filament\Support\Icons\Heroicon;
LanguageSwitch::configureUsing(function (LanguageSwitch $switch) {
$switch
->locales(['en', 'fr', 'ar', 'de', 'es'])
->flags([
'en' => asset('flags/us.svg'),
'fr' => asset('flags/fr.svg'),
'ar' => asset('flags/sa.svg'),
'de' => asset('flags/de.svg'),
'es' => asset('flags/es.svg'),
])
->displayMode(DisplayMode::Modal)
->columns(2)
->modalWidth('lg')
->circular()
->nativeLabel()
->trigger(
style: TriggerStyle::FlagLabel,
icon: Heroicon::GlobeAlt,
)
->excludes(['admin'])
->userPreferredLocale(fn () => auth()->user()?->locale);
});
```
--------------------------------
### Disable Control Panel
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Explicitly disable the control panel in the configuration.
```php
$switch->controlPanel(false);
```
--------------------------------
### Toggle Visibility Context
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Control whether the switcher appears inside or outside of Filament panels.
```php
$switch->visible(insidePanels: false, outsidePanels: true);
```
--------------------------------
### Associate Flags with Locales
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Map locale keys to flag image assets for display in the switcher.
```php
$switch->flags([
'en' => asset('flags/us.svg'),
'fr' => asset('flags/fr.svg'),
'ar' => asset('flags/sa.svg'),
]);
```
--------------------------------
### Configure Modal Sizing
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Adjusts the height of flags and avatars when using the modal display mode.
```php
$switch
->displayMode(DisplayMode::Modal)
->flagHeight('h-20') // Default: 'h-16'
->avatarHeight('size-10'); // Default: 'size-8'
```
--------------------------------
### Override Outside Panel Routes
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Specify the list of routes where the switcher should be rendered.
```php
$switch->outsidePanelRoutes([
'auth.login',
'auth.register',
'auth.password-reset.request',
'auth.password-reset.reset',
]);
```
--------------------------------
### Configure Item Styles
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Define the visual representation of locale items using the ItemStyle enum.
```php
use BezhanSalleh\LanguageSwitch\Enums\ItemStyle;
$switch->itemStyle(ItemStyle::FlagOnly); // flag images only, tooltips on hover
$switch->itemStyle(ItemStyle::AvatarOnly); // abbreviations only (EN, FR), tooltips on hover
$switch->itemStyle(ItemStyle::LabelOnly); // text labels only, no visual
$switch->itemStyle(ItemStyle::FlagWithLabel); // flag + locale name (default with flags)
$switch->itemStyle(ItemStyle::AvatarWithLabel); // abbreviation + locale name (default without flags)
```
--------------------------------
### Set User Preferred Locale
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Define a callback to resolve the user's preferred locale from their profile.
```php
$switch->userPreferredLocale(fn () => auth()->user()?->locale);
```
--------------------------------
### Set Render Hook
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Positions the language switch at a specific Filament render hook location.
```php
use Filament\View\PanelsRenderHook;
$switch->renderHook(PanelsRenderHook::SIDEBAR_NAV_END);
```
--------------------------------
### Set locales for dropdown
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Define the available locales for the default dropdown mode.
```php
$switch->locales(['en', 'fr', 'ar']);
```
--------------------------------
### Listen for Locale Changes
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Handle the LocaleChanged event to perform actions like updating the user's locale in the database.
```php
use BezhanSalleh\LanguageSwitch\Events\LocaleChanged;
use Illuminate\Support\Facades\Event;
Event::listen(function (LocaleChanged $event) {
auth()->user()?->update(['locale' => $event->locale]);
});
```
--------------------------------
### Enable Circular Appearance
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Applies a fully rounded style to flags and avatars.
```php
$switch->circular();
```
--------------------------------
### Exclude Panels
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Prevent the language switch from appearing in specific Filament panels.
```php
$switch->excludes(['admin']);
```
--------------------------------
### trigger(style, icon)
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Configures the visual representation of the language switcher trigger. You can pass a TriggerStyle enum to define the visual layout or a string/Heroicon enum to set a custom icon.
```APIDOC
## trigger(style, icon)
### Description
Configures the trigger style and icon for the language switcher. Both parameters are optional and can be used to override default behavior.
### Method
PHP Method
### Parameters
- **style** (TriggerStyle) - Optional - Defines the visual layout (e.g., Icon, Flag, Avatar, Label, or combinations).
- **icon** (string|Heroicon) - Optional - Defines the icon to display, supporting Blade Icons strings or Heroicon enum cases.
```
--------------------------------
### Customize Render Hook Anchors
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Manually override the render hook used for the switcher.
```php
use Filament\View\PanelsRenderHook;
// Dock as a profile item inside the user menu dropdown
$switch->outsidePanelsRenderHook(PanelsRenderHook::USER_MENU_PROFILE_AFTER);
// Or force body-level anchoring for an in-flow mode
$switch
->outsidePanelPlacement(Placement::BottomCenter, PlacementMode::Static)
->outsidePanelsRenderHook(PanelsRenderHook::BODY_END);
```
--------------------------------
### Register Global Icon Alias
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Override the trigger icon globally using Filament's icon alias system.
```php
use Filament
Support
Facades
FilamentIcon;
FilamentIcon::register([
'language-switch::trigger' => 'heroicon-o-globe-alt',
]);
```
--------------------------------
### Override Locale Labels
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Provide custom display names for specific locales.
```php
$switch->labels([
'pt_BR' => 'Brasileiro',
'pt_PT' => 'Europeu',
]);
```
--------------------------------
### Configure Trigger Style
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Use the TriggerStyle enum to override the default trigger appearance, choosing between visual-only or visual-with-label options.
```php
use BezhanSalleh
LanguageSwitch
Enums
TriggerStyle;
// Visual only
$switch->trigger(style: TriggerStyle::Icon); // language icon
$switch->trigger(style: TriggerStyle::Flag); // flag image (requires ->flags())
$switch->trigger(style: TriggerStyle::Avatar); // locale abbreviation (EN, FR, AR)
// Visual with label
$switch->trigger(style: TriggerStyle::IconLabel); // icon + locale name
$switch->trigger(style: TriggerStyle::FlagLabel); // flag + locale name
$switch->trigger(style: TriggerStyle::AvatarLabel); // abbreviation + locale name
// Label only — no visual
$switch->trigger(style: TriggerStyle::Label);
```
--------------------------------
### Set Dropdown Max Height
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Configures the maximum height of the dropdown menu to control scrolling behavior.
```php
$switch->maxHeight('30rem');
$switch->maxHeight('max-content'); // no scroll, grows to fit content
```
--------------------------------
### Embed Multiple Inline Switchers
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Uses explicit keys to prevent unnecessary re-mounting when placing multiple switchers on a single page.
```blade
...
```
--------------------------------
### Embed Language Switcher Inline
Source: https://github.com/bezhansalleh/filament-language-switch/blob/main/README.md
Mounts the language switcher component directly into a custom Blade view location.
```blade
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.