A Bootstrap 5 product inventory table with photo thumbnails, SKUs, prices, color-coded stock meters and status badges, plus search, a category filter, a low-stock switch and sortable columns. It suits store admin panels, warehouse dashboards and back-office product lists.
How it works
The root section.inv-wrap contains .inv-card with a header (.inv-head) holding the title, the live .inv-value total and the .inv-tools controls. On medium screens and up the tools sit next to the title; on phones they stack. The table.inv-table lives in a .table-responsive wrapper, so it scrolls horizontally on narrow screens.
Every product row stores its data in attributes: data-inv-name, data-inv-sku, data-inv-category, data-inv-price and data-inv-stock. The first cell shows a square .inv-thumb image with object-fit: cover next to .inv-name and the monospace .inv-sku. The stock cell uses a native meter element with low="1", high="11" and optimum="100", so the browser picks the bar color by itself: green from 11 units, amber from 1 to 10 and red at 0. The CSS styles the WebKit and Firefox meter pseudo-elements with --inv-ok, --inv-low and --inv-out. Status uses .inv-badge--ok, .inv-badge--low and .inv-badge--out.
The script runs on DOMContentLoaded for every .inv-wrap. applyFilters() listens to input on .inv-q, change on .inv-cat and change on .inv-low-only. It hides rows that do not match, shows the .inv-empty row when nothing is left, recalculates the stock value (price times stock of visible rows, formatted with Intl.NumberFormat) and updates .inv-foot. The .inv-sort buttons sort by name, price or stock, toggle between ascending and descending and set aria-sort on the header cell.
The product photos come from Unsplash; replace them with your own product images.
Customization
--inv-accentin.inv-wrap: recolors the stock value, the active sort header, focus rings and the switch.--inv-ok,--inv-lowand--inv-outin.inv-wrap: change the meter colors for healthy, low and empty stock.--inv-thumbin.inv-wrap: makes the product thumbnails larger or smaller.data-inv-lowon.inv-wrap: sets the limit used by the "Low stock only" switch (default 10).low,highandmaxon eachmeter: move the color thresholds or the full-bar value, e.g.max="500"for a warehouse.- Add
optionelements to.inv-catthat match thedata-inv-categoryvalues of your rows. data-inv-sorton an.inv-sortbutton: names thedata-inv-*attribute to sort by;namesorts alphabetically, any other key numerically.
Use cases
- Ecommerce admin panels: product thumbnails, SKUs and prices appear in one searchable table
- Warehouse tools: color-coded stock meters and status badges show low and out-of-stock items at a glance
- Catalog management: filters and sortable columns help staff find products quickly
- Retail back offices: search narrows a long list of products by name or SKU
Accessibility
The table has a visually hidden caption and scope="col" headers. Sortable headers contain real buttons and expose the current order through aria-sort. The search field and category select have visually hidden labels, and the switch uses role="switch" with a visible label. Each meter is labelled "Stock level" and its number is also shown as text. .inv-foot is a role="status" region that announces how many products are shown. Every thumbnail has descriptive alt text, width and height, and the controls have visible focus styles.
Usage notes
Requires Bootstrap 5 and Bootstrap Icons. Update the status badges together with the stock numbers when you render rows from your own data.