A custom Gutenberg block for WordPress that displays tabbed content with image-backed tab triggers, fully accessible keyboard navigation, and proper ARIA semantics.
▶ Try it live in WordPress Playground — spins up a disposable WordPress in your browser with the plugin installed and a ready-made demo page showing the block in action.
- 🎨 Image-backed tabs — pick an image from the media library for each tab trigger.
- ♿ Accessible by default — implements the WAI-ARIA Tabs pattern with
role="tablist",role="tab", androle="tabpanel". - ⌨️ Keyboard navigation — move between tabs with
←/→, jump to first/last withHome/End. - 🧩 Sidebar editing — each tab's image, title, description, and link are set in the block's Inspector sidebar.
- 🌐 Translation ready — all strings are wrapped with
@wordpress/i18n. - 📐 Alignment & spacing — supports
wide/fullalignment and vertical margin controls. - 🚀 No third-party dependencies — built entirely on WordPress core packages.
The block is built with the @wordpress/scripts toolchain and the WordPress Block API v3:
src/tabs.js— the shared BEM markup, rendered by both the editor preview and the saved output (a single source of truth).src/edit.js— the editor UI: Inspector controls for each tab's image, title, description, and link.src/save.js— the block's static markup saved to post content.src/view.js— a lightweight, dependency-freeTabsAutomaticclass that assigns the ARIA roles/ids and wires up click + keyboard interaction on the front end.src/block.json— block metadata, attributes, supports, and asset registration.
- Clone the repository into your
wp-content/pluginsdirectory:git clone https://github.com/shamimmoeen/custom-tab-block.git
- Install dependencies and build:
cd custom-tab-block npm install npm run build - Activate Custom Tab Block from the Plugins screen in WordPress.
The repository ships with a pre-built build/ directory, so the plugin works immediately after activation even without running the build step.
This project uses @wordpress/scripts. The common commands:
npm start # Start the development build with file watching
npm run build # Create a production build
npm run format # Format source files
npm run lint:js # Lint JavaScript
npm run lint:css # Lint styles
npm run plugin-zip # Create a distributable plugin .zip- Add the Custom Tab Block from the block inserter.
- Open the block settings sidebar and fill in the Tab 1 Data and Tab 2 Data panels:
- Image — the background image shown on the tab trigger.
- Title — the bold heading inside the tab panel.
- Description — the body copy.
- Link — the destination for the "Read More" button.
- On the front end, visitors switch tabs by clicking a tab or using the keyboard.
The block follows the WAI-ARIA Authoring Practices for tabs:
| Key | Action |
|---|---|
← Arrow Left |
Move to the previous tab |
→ Arrow Right |
Move to the next tab |
Home |
Move to the first tab |
End |
Move to the last tab |
Only the active tab is in the tab order; arrow keys move focus between tabs, and the matching panel is revealed automatically.
- WordPress 6.1 or higher
- PHP 7.0 or higher
The demo images used in the live preview are free stock photos from Pexels:
- Charming Mountain Chapel in the Dolomites — photo by Ivan Palchuk.
- Bikes Parked by a River — photo by Ersin.