Overview
Citizen uses a component-based architecture to organize UI elements. All components implement theCitizenComponent interface and are located in includes/Components/.
Namespace: MediaWiki\Skins\Citizen\Components
CitizenComponent Interface
The base interface all components must implement.getTemplateData
Returns template data for Mustache rendering.Associative array of template variables for Mustache rendering
Core Components
CitizenComponentPageHeading
Manages page heading display including titles and taglines. Location:includes/Components/CitizenComponentPageHeading.php
Constructor
Factory for creating User objects
Cache for user gender information
Service for looking up user identities
Factory for language variant conversion
Language object for localization
Message localization service
OutputPage object for the current page
Title object for the current page
Raw title HTML from parent template
Template Data
Page tagline HTML (namespace tagline, user info, or site tagline)
Modified page heading HTML with styled parentheses
CitizenComponentPageTools
Manages the page tools menu including article tools, languages, and share functionality. Location:includes/Components/CitizenComponentPageTools.php
Constants
Constructor
Configuration object
Message localization service
Current page title
Current user
Permission manager for access checks
Number of available languages
Page tools menu data from sidebar
Language links data
Language variant data
Template Data
Article tools menu data
Whether page tools should be shown (based on
CitizenShowPageTools config)Whether there are any article tools to show
Whether language links or variants are available
Whether Universal Language Selector is ready (currently always false)
Number of available languages
Whether the page can be shared (exists and is content page)
Localized share button text
CitizenShowPageTools config accepts:
true: Always visiblefalse: Never visible'login': Only visible if logged in'permission-*': Only visible if user has permission (e.g.,'permission-edit')
CitizenComponentSearchBox
Provides enhanced search box with keyboard shortcuts and powered-by message. Location:includes/Components/CitizenComponentSearchBox.php
Constructor
Message localization service
Registry for checking loaded extensions
Base search box data from parent template
Template Data
Array of keyboard hint data (↑↓ for select, / for open, Esc for exit)
Powered-by message (CirrusSearch or MediaWiki)
Search toggle shortcut display text
URL to Special:Randompage
CitizenComponentMainMenu
Organizes sidebar navigation into main menu structure. Location:includes/Components/CitizenComponentMainMenu.php
Constructor
Sidebar data from parent template
Template Data
First portlet menu data (processed through CitizenComponentMenu)
Remaining portlet menus (each processed through CitizenComponentMenu)
Other Components
Citizen includes additional components for specific UI elements:- CitizenComponentBodyContent - Wraps main content, handles collapsible sections
- CitizenComponentButton - Renders button elements
- CitizenComponentFooter - Site footer with links
- CitizenComponentKeyboardHint - Keyboard shortcut hints
- CitizenComponentLink - Link elements
- CitizenComponentMenu - Menu container
- CitizenComponentMenuListItem - Individual menu items
- CitizenComponentPageFooter - Page metadata footer
- CitizenComponentPageSidebar - Sidebar content
- CitizenComponentSiteStats - Site statistics display
- CitizenComponentStickyHeader - Sticky header behavior
- CitizenComponentTableOfContents - Table of contents
- CitizenComponentUserInfo - User information display
Creating Custom Components
To create a new component:- Implement the
CitizenComponentinterface - Add constructor with required dependencies
- Implement
getTemplateData()method - Return array of template variables
Related
- SkinCitizen - Main skin class
- Hooks - Hook handlers that modify component data