How to Customize the Polylang Language Switcher Dropdown in Bricks?

Hi,

I’m using the Polylang Language Switcher element in Bricks and would like to know how to customize its dropdown appearance and behavior.

Specifically, I have two questions:

  1. Dropdown Toggle Arrow: When using the Dropdown layout, is there a built-in option to display an arrow or chevron icon next to the currently selected language, indicating that the menu can be expanded or collapsed? If not, what is the recommended way to add one?

  2. Dropdown Item Hover Styling: When the dropdown is expanded, how can I customize the appearance of individual language items when hovering over them? For example, I’d like to change the background color of a language item on hover.

I couldn’t find settings for either of these in the element’s available styling options.

Thanks in advance!

The Polylang dropdown uses a native HTML select, so its styling options differ from a regular Bricks Dropdown element.

Arrow: There isn’t a dedicated chevron control. To use the browser’s own dropdown arrow, add this under the language switcher’s Style → CSS → Custom CSS:

%root% select {
  -webkit-appearance: auto;
  appearance: auto;
}

For a specific custom chevron, use a background image on the select, with appearance: none and enough padding to leave space for the icon.

Item hover: The expanded options are handled by the browser/operating system. Individual option hover backgrounds cannot be styled consistently across browsers with ordinary CSS. For reliable custom hover colors, use a custom language-link dropdown rather than the native select.

There’s also a related explanation here: NO BUG: Polylang flag selector element size & hover - #4 by timmse

Thanks for the explanation!

Regarding your suggestion to use a custom language-link dropdown for reliable hover styling, could you clarify what you mean by that?

Are you referring to building a custom dropdown using standard Bricks elements (such as a Div, Button and nested links), with each language link generated dynamically through Polylang?

Or is there an existing Bricks feature, element or recommended approach that can achieve this without writing custom PHP?

I’d prefer to keep the language links dynamically generated by Polylang, so that they automatically point to the corresponding translated pages rather than manually defining each language URL.

Could you point me in the right direction?

Thanks!

You can keep the language links dynamically generated by Polylang without writing custom PHP.

What I meant is to place the existing Polylang Language Switcher element inside a regular Bricks Dropdown:

  1. Add a Bricks Dropdown and use “Languages” as its label, for example.
  2. Remove its placeholder links and change the inner Content container’s HTML tag from ul to div, since the language switcher provides its own list.
  3. Insert the Polylang Language Switcher into that container, disable its Dropdown option, and set its direction to vertical.
  4. Keep Force home disabled, so Polylang links to the corresponding translations rather than always linking to the language homepages. Enable Hide if no translation if you only want to show available translations.

The outer Bricks Dropdown provides the toggle and arrow. The language switcher inside provides regular links, whose hover backgrounds you can style with CSS. For example, add this under the Language Switcher’s Style → CSS → Custom CSS:

%root% a:hover,
%root% a:focus-visible {
  background-color: #eee;
}

This keeps Polylang responsible for generating the URLs, so you don’t need to maintain individual language links manually.

{"content":[{"id":"pldrop","name":"dropdown","parent":"pldemo","settings":{"tag":"div","text":"Languages","toggleOn":"click","ariaLabel":"Choose language","contentWidth":"240px","_width":"max-content","_typography":{"color":{"hex":"#172554"}},"_cssCustom":"#brxe-pldrop>.brx-submenu-toggle {\n padding: 12px 16px;\n border: 1px solid #94a3b8;\n border-radius: 8px;\n background-color: #fff;\n}\n#brxe-pldrop>.brx-dropdown-content {\n background-color: #fff;\n border: 1px solid #94a3b8;\n border-radius: 8px;\n padding: 8px;\n box-shadow: 0 8px 24px rgb(0 0 0 / 12%);\n}"},"children":["plcont"]},{"id":"plcont","name":"div","parent":"pldrop","settings":{"tag":"div","_hidden":{"_cssClasses":"brx-dropdown-content"}},"label":"Dropdown content (div)","children":["pllang"]},{"id":"pllang","name":"polylang-language-switcher","parent":"plcont","settings":{"direction":"column","showNames":true,"hideIfNoTranslation":true,"hideIfEmpty":false,"_width":"100%","_gap":"4px","_cssCustom":"#brxe-pllang {\n margin: 0;\n}\n#brxe-pllang li {\n width: 100%;\n list-style: none;\n}\n#brxe-pllang a {\n display: flex;\n padding: 12px 16px;\n border-radius: 4px;\n color: #172554;\n text-decoration: none;\n}\n#brxe-pllang a:hover {\n background-color: #dbeafe;\n color: #1e40af;\n}\n#brxe-pllang a:focus-visible {\n background-color: #dbeafe;\n color: #1e40af;\n}"},"label":"Dynamic Polylang links","children":[]}],"source":"bricksCopiedElements","sourceUrl":"https://bricks.local","version":"2.4.6"}