Browser extension popup UI implementation

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_website-b2b-advance_0.png
    B2B ADVANCE company website development
    1212
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    852
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_bitrix-bitrix-24-1c_fixper_448_0.png
    Website development for FIXPER company
    815

Implementation of Popup Interface for Browser Extension

Popup is an HTML page that opens when clicking the extension icon in the toolbar. It lives from click to close (loss of focus or explicit close) and doesn't persist state between openings — this should be considered in design.

Popup Limitations

  • Maximum size: ~800×600 px, Chrome limits viewport height
  • Lifetime: created on opening, destroyed on closing
  • No alert(), confirm() — blocked by browser
  • CSP forbids inline scripts and eval — all JS must be in .js files
  • Cannot be opened programmatically from content script without user gesture (in MV3)

File structure

popup/
├── popup.html
├── popup.js      (or popup.tsx + build)
└── popup.css
<!-- popup.html -->
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=350">
  <link rel="stylesheet" href="popup.css">
  <!-- NO inline scripts — CSP violation -->
</head>
<body>
  <div id="app"></div>
  <script src="popup.js"></script>
</body>
</html>

React in Popup

Popup with React is standard practice for complex interfaces:

// popup/App.tsx
import { useEffect, useState } from 'react';
import browser from 'webextension-polyfill';

interface TabInfo {
  url: string;
  title: string;
}

export function App() {
  const [tab, setTab] = useState<TabInfo | null>(null);
  const [enabled, setEnabled] = useState(false);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    async function init() {
      // Get active tab data
      const [activeTab] = await browser.tabs.query({ active: true, currentWindow: true });
      setTab({ url: activeTab.url ?? '', title: activeTab.title ?? '' });

      // Load saved settings
      const { extensionEnabled } = await browser.storage.local.get('extensionEnabled');
      setEnabled(extensionEnabled ?? false);
      setLoading(false);
    }
    init();
  }, []);

  async function toggleEnabled() {
    const next = !enabled;
    setEnabled(next);
    await browser.storage.local.set({ extensionEnabled: next });

    // Notify content script on active tab
    if (tab) {
      const [activeTab] = await browser.tabs.query({ active: true, currentWindow: true });
      if (activeTab.id) {
        browser.tabs.sendMessage(activeTab.id, { type: 'TOGGLE', enabled: next });
      }
    }
  }

  if (loading) return <div className="popup-loading">Loading...</div>;

  return (
    <div className="popup">
      <header className="popup__header">
        <img src="/icons/icon32.png" alt="" />
        <h1>My Extension</h1>
      </header>

      <section className="popup__body">
        <div className="popup__url" title={tab?.url}>{tab?.title}</div>

        <label className="toggle">
          <input
            type="checkbox"
            checked={enabled}
            onChange={toggleEnabled}
          />
          <span className="toggle__label">
            {enabled ? 'Enabled' : 'Disabled'}
          </span>
        </label>
      </section>

      <footer className="popup__footer">
        <button onClick={() => browser.runtime.openOptionsPage()}>
          Settings
        </button>
        <button onClick={() => browser.tabs.create({ url: 'https://example.com/help' })}>
          Help
        </button>
      </footer>
    </div>
  );
}

Size and styling

Popup should be convenient in 320–400 px width range. Typical markup:

/* popup.css */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  width: 360px;
  min-height: 200px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #fff;
}

.popup {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.popup__header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.popup__body {
  flex: 1;
  padding: 16px;
}

.popup__footer {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
}

Timeline

Simple popup with toggle and storage: 1–2 days. Complex popup with React, background sync, and multiple tabs: 3–5 days.