© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
9 replies
vahnmarty

How to easily change the placeholder text on Search?

I want every resource will have different search placeholder, for example in Child Resource, the placeholder should be "Search First Name, Email or Phone Number". In Application Resource "Search Control Number, Status, Name".
Solution
This is was my solution: I created filament.css and filament.js and added it to my AppServiceProvider.

AppServiceProvider.php

Filament::registerScripts([
                asset('js/filament.js'),
            ]);

            Filament::registerViteTheme('resources/css/filament.css');
Filament::registerScripts([
                asset('js/filament.js'),
            ]);

            Filament::registerViteTheme('resources/css/filament.css');


filament.css

@import '../../vendor/filament/filament/resources/css/app.css';

.filament-tables-search-input input{
    @apply max-w-full;
    width: 420px;
}
@import '../../vendor/filament/filament/resources/css/app.css';

.filament-tables-search-input input{
    @apply max-w-full;
    width: 420px;
}


filament.js

document.addEventListener('DOMContentLoaded', function () {
    if(isUri('admin/applications')){
        return changeSearchPlaceholder('First Name, Last Name, Email or Phone');
    }

    if(isUri('admin/children')){
        return changeSearchPlaceholder('First Name, Last Name, School, Email or Phone');
    }

    if(isUri('admin/users')){
        return changeSearchPlaceholder('First Name, Last Name or Email');
    }
  });


function isUri($uri)
{
    var currentURL = window.location.href;
  
    // Define the URI you want to check
    var targetURI = $uri;
  
    // Check if the current URL contains the target URI
    return currentURL.indexOf(targetURI) !== -1;

}

function changeSearchPlaceholder($placeholder)
{
    var searchInput = document.querySelector('.filament-tables-search-input');

    // Check if the element exists
    if (searchInput) {
    // Find the <input> element within the searchInput element
    var inputElement = searchInput.querySelector('input');

    // Check if the <input> element exists
    if (inputElement) {
        // Change the placeholder attribute of the <input> element
        inputElement.placeholder = $placeholder;
    }
    }
}
document.addEventListener('DOMContentLoaded', function () {
    if(isUri('admin/applications')){
        return changeSearchPlaceholder('First Name, Last Name, Email or Phone');
    }

    if(isUri('admin/children')){
        return changeSearchPlaceholder('First Name, Last Name, School, Email or Phone');
    }

    if(isUri('admin/users')){
        return changeSearchPlaceholder('First Name, Last Name or Email');
    }
  });


function isUri($uri)
{
    var currentURL = window.location.href;
  
    // Define the URI you want to check
    var targetURI = $uri;
  
    // Check if the current URL contains the target URI
    return currentURL.indexOf(targetURI) !== -1;

}

function changeSearchPlaceholder($placeholder)
{
    var searchInput = document.querySelector('.filament-tables-search-input');

    // Check if the element exists
    if (searchInput) {
    // Find the <input> element within the searchInput element
    var inputElement = searchInput.querySelector('input');

    // Check if the <input> element exists
    if (inputElement) {
        // Change the placeholder attribute of the <input> element
        inputElement.placeholder = $placeholder;
    }
    }
}
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

deferLoading Placeholder Text
FilamentFFilament / ❓┊help
3y ago
How to add helper text on global search
FilamentFFilament / ❓┊help
12mo ago
Customize the placeholder inside the search box
FilamentFFilament / ❓┊help
3y ago
search placeholder update table
FilamentFFilament / ❓┊help
2y ago