Object Hierarchy:

Object hierarchy for SearchBar


[ CCode ( type_id = "gtk_search_bar_get_type ()" ) ]
public class SearchBar : Widget, Accessible, Buildable, ConstraintTarget

SearchBar is a container made to have a search entry (possibly with additional connex widgets, such as drop-down menus, or buttons) built-in.

The search bar would appear when a search is started through typing on the keyboard, or the application’s search mode is toggled on.

For keyboard presses to start a search, the search bar must be told of a widget to capture key events from through set_key_capture_widget. This widget will typically be the top-level window, or a parent container of the search bar. Common shortcuts such as Ctrl+F should be handled as an application action, or through the menu items.

You will also need to tell the search bar about which entry you are using as your search entry using connect_entry. The following example shows you how to create a more complex search entry.

Creating a search bar

A simple example

CSS nodes

╰── revealer
╰── box
├── [child]
╰── [button.close]
n CSS node with name searchbar. It has a child node with name revealer that contains a node with name box. The box node contains both the CSS node of the child widget as well as an optional button node which gets the .close style class applied.


GtkSearchBar uses the gtk_accessible_role_search role.

Namespace: Gtk
Package: gtk4



Creation methods:


Inherited Members:

All known members inherited from class Gtk.Widget