Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

coachben's avatar

Add a search title above the AboveContent Filters in filament 3

Any ideas how i can make the searchable field appear just above the filters in the Header area.

0 likes
2 replies
LaryAI's avatar
Level 58

To add a searchable field above the filters in the Header area, you can follow these steps. Assuming you are using a front-end framework like React or Vue.js, I'll provide examples for both.

React Example

  1. Create a Search Component:
import React from 'react';

const Search = ({ onSearch }) => {
  return (
    <div className="search-container">
      <input
        type="text"
        placeholder="Search..."
        onChange={(e) => onSearch(e.target.value)}
      />
    </div>
  );
};

export default Search;
  1. Add the Search Component Above the Filters in Your Header Component:
import React, { useState } from 'react';
import Search from './Search';
import Filters from './Filters';

const Header = () => {
  const [searchTerm, setSearchTerm] = useState('');

  const handleSearch = (term) => {
    setSearchTerm(term);
    // Add logic to filter content based on search term
  };

  return (
    <header>
      <Search onSearch={handleSearch} />
      <Filters searchTerm={searchTerm} />
    </header>
  );
};

export default Header;

Vue.js Example

  1. Create a Search Component:
<template>
  <div class="search-container">
    <input type="text" placeholder="Search..." @input="onSearch" />
  </div>
</template>

<script>
export default {
  methods: {
    onSearch(event) {
      this.$emit('search', event.target.value);
    }
  }
};
</script>
  1. Add the Search Component Above the Filters in Your Header Component:
<template>
  <header>
    <Search @search="handleSearch" />
    <Filters :searchTerm="searchTerm" />
  </header>
</template>

<script>
import Search from './Search.vue';
import Filters from './Filters.vue';

export default {
  components: {
    Search,
    Filters
  },
  data() {
    return {
      searchTerm: ''
    };
  },
  methods: {
    handleSearch(term) {
      this.searchTerm = term;
      // Add logic to filter content based on search term
    }
  }
};
</script>

General HTML/CSS/JavaScript Example

If you are not using a framework, you can achieve this with plain HTML, CSS, and JavaScript.

  1. HTML Structure:
<header>
  <div class="search-container">
    <input type="text" id="search" placeholder="Search..." />
  </div>
  <div id="filters">
    <!-- Your filter elements go here -->
  </div>
</header>
  1. JavaScript to Handle Search:
document.getElementById('search').addEventListener('input', function(event) {
  const searchTerm = event.target.value;
  // Add logic to filter content based on search term
});
  1. CSS for Styling (Optional):
.search-container {
  margin-bottom: 10px;
}

#filters {
  /* Your filter styles */
}

By following these steps, you can add a searchable field above the filters in the Header area. Adjust the logic to filter content based on your specific requirements.

coachben's avatar

layout: FiltersLayout::AboveContent is what you need.. Together with the Some grid or section. Hope this helps someone out there.

` ->filtersFormSchema(fn (array $filters): array => [ Grid::make() ->schema([ $filters['organisation'], ]) ->columnSpanFull(),

            Section::make(fn () => $this->agent->isMobile() ? 'Search Filters' : '')
                // ->description('Decision Superstars.')
                ->schema([
                    //call a custom filter that has a form
                    $filters['topic'],

`

Please or to participate in this conversation.