FCHubFCHub.co

Currency Switcher

A polished dropdown with flag icons, keyboard navigation, style presets, and both block and shortcode support.

The currency switcher is how your visitors pick their currency. Not a sad native browser dropdown — a proper custom widget with flag icons, keyboard navigation, multiple size modes, style presets, and a little freshness badge that says "yes, these rates are current." It now ships as both a Gutenberg block and a shortcode, so it works in classic themes, block themes, and Full Site Editing layouts.

Currencies appear in the order you've set in Settings → Currencies. Drag them to rearrange.

Add It to Your Site

Gutenberg Block

Open the block inserter and search for Currency Switcher. Add it to:

  • pages and posts
  • headers and footers in the Site Editor
  • template parts
  • synced patterns
  • sidebars or utility rows built with blocks

If you just want a fast sandbox for testing, insert the Currency Showcase pattern first and work from there.

The block supports:

  • optional label text
  • label placement before, after, above, or below the switcher
  • trigger visibility toggles for flag, code, symbol, and currency name
  • dropdown visibility toggles for flags, codes, symbols, names, and active checkmark
  • optional rate line and checkout context note inside the dropdown footer
  • small, medium, and large trigger sizes
  • auto or full-width layout
  • start or end dropdown alignment
  • dropdown opening up or down
  • style presets: Default, Pill, Minimal, Subtle, Glass, and Contrast

Editor preview now uses your configured currency list and the configured default display currency, instead of always pretending the first currency in the list is active.

Shortcode

[fchub_currency_switcher]

The shortcode is still fully supported for classic themes, widget areas, PHP templates, or legacy content. Existing installs do not need to migrate anything.

Optional shortcode attributes:

[fchub_currency_switcher label="Select currency" align="right" show_symbol="yes" show_option_symbols="yes" dropdown_direction="up" size="lg"]

Supported attributes:

Layout

AttributeValuesDefault
labelany text(none)
label_positionbefore, after, above, belowbefore
alignleft, center, rightleft
sizesm, md, lgmd
width_modeauto, fullauto
dropdown_positionstart, endstart
dropdown_directiondown, updown

Trigger elements

AttributeValuesDefault
show_flagyes / noyes
show_codeyes / noyes
show_symbolyes / nono
show_nameyes / nono

Dropdown options

AttributeValuesDefault
show_option_flagsyes / noyes
show_option_codesyes / noyes
show_option_symbolsyes / nono
show_option_namesyes / noyes
show_active_indicatoryes / noyes

Footer context

AttributeValuesDefault
show_rate_badgeyes / noyes
show_rate_valueyes / nono
show_context_noteyes / nono

If the plugin is disabled or you haven't added any currencies yet, both the block and the shortcode output nothing. No broken markup, no empty boxes.

You can also place it multiple times on the same page — header and footer, for example. Each instance works independently.

How It Looks

When closed, the switcher sits as a compact button showing the visitor's current currency with its flag:

Shop page with the currency switcher button in the top right corner

Click it, and a dropdown opens with every currency you've configured — each with its flag, code, and full name:

Shop page with the currency switcher dropdown open, showing PLN, EUR, USD, and GBP options

The active currency is highlighted in blue. At the bottom, a rate freshness badge tells visitors when rates were last updated — green dot means fresh, red dot means stale:

Currency switcher dropdown close-up with flag emojis, currency names, and rate freshness badge

What Happens When Someone Switches

Visitor clicks a currency

The button dims slightly to show something's happening.

Preference is saved

Their choice is remembered — in a browser cookie (sticks for 90 days) and in their account if they're logged in. No need to pick again next time.

Page refreshes with new prices

The page reloads and every price on the site is now in the selected currency. Product cards, cart totals, checkout — everything updates.

Block Style Presets

The block includes six built-in visual presets:

  • Default — neutral, close to the classic switcher look
  • Pill — fully rounded trigger, good for headers and utility bars
  • Minimal — lower visual weight, lighter borders, cleaner dropdown
  • Subtle — softer background and gentler contrast
  • Glass — translucent trigger and dropdown with blur, good for layered headers
  • Contrast — dark high-contrast preset for bold headers, utility bars, or darker brand accents

Use presets for overall appearance, then use the block settings for content and layout. That keeps the editor flexible without turning the inspector into a control panel from a fighter jet.

Advanced Display Controls

The switcher now lets you tune the trigger and the dropdown independently.

Examples:

  • compact header mode: flag + code, no label, no badge
  • more descriptive footer mode: stacked label, code + symbol + name
  • minimalist utility bar: name only in trigger, symbols only in dropdown
  • dense mobile row: small size, full width, dropdown opening upward

That separation matters. The trigger is about what the visitor sees before opening it. The dropdown is about how much context they need to make the right choice.

Smart Dropdown Fit

On the frontend, the dropdown now tries to stay inside the viewport instead of blindly trusting the preferred side when there isn't enough room. It still respects your configured alignment and direction as the first choice, but will clamp or flip when the available space says "absolutely not."

Rate Freshness Badge

The little footer inside the dropdown that reads "Rates updated 2 hours ago" with a coloured dot.

  • Green dot — rates are fresh, everything's current
  • Red dot — rates haven't been updated in a while

You can toggle this on or off in the Checkout settings. It's a small touch, but it builds trust — visitors can see that the converted prices aren't based on exchange rates from three months ago.

Keyboard Navigation

The switcher is fully keyboard-accessible — you can navigate the whole thing without touching a mouse:

KeyWhat It Does
Enter or SpaceOpens the dropdown, or selects the focused currency
Arrow Down / UpMoves through the currency list
Home / EndJumps to the first or last currency
EscapeCloses the dropdown
TabCloses the dropdown and moves focus along naturally

No JavaScript? No Problem

If a visitor has JavaScript disabled (rare, but it happens), they get a plain fallback form with a native <select> and submit button. Same currencies, same result, just less pretty. The preference is still saved when possible, so the site does not fall apart the moment JavaScript takes the day off.

Matching Your Theme

The switcher ships with clean, neutral styling that works with most themes out of the box. If you need to tweak colours, border radius, or shadow to match your brand — see the CSS custom properties reference in the Developer Reference.

In block themes, the block can also live comfortably inside template parts and layout containers without resorting to a shortcode block, which is the entire point of living in the present.

On this page