Source Code

<div class="container py-5 d-flex justify-content-center">
  <div class="card bsaudit-card">
    <div class="card-body p-3">
      <div class="d-flex gap-2 mb-2">
        <input type="search" class="form-control form-control-sm" id="bsauditSearch" placeholder="Search actor or action...">
        <select class="form-select form-select-sm" id="bsauditType" style="max-width:130px;">
          <option value="">All types</option>
          <option value="security">Security</option>
          <option value="content">Content</option>
          <option value="billing">Billing</option>
        </select>
      </div>
      <p class="small text-muted mb-2" id="bsauditCount"></p>
      <ul class="list-unstyled mb-0" id="bsauditList"></ul>
    </div>
  </div>
</div>

Bootstrap Audit Log Viewer — Free HTML CSS JS Snippet

Bootstrap Audit Log Viewer · Dashboards · Plain HTML, CSS & JS · Live preview

What's included

Features

Text search and the type dropdown combine with real AND logic, not an accidental OR
Search matches both actor name and action text, with matches safely highlighted in both
The highlight query is escaped for safe RegExp use, and the source text is HTML-escaped before rendering
Each entry's severity tone is stored independently of its category, not derived automatically from it
A live "X of Y events" count reflects exactly what both active filters currently allow through

About this UI Snippet

Bootstrap Audit Log Viewer — HTML, CSS & JavaScript

Screenshot of the Bootstrap Audit Log Viewer snippet rendered live

Search text and the type dropdown filter the exact same LOG array together inside one render() call — matches only keeps an entry where both typeOk and textOk are true, so searching "dana" while the type filter is set to "Content" correctly shows nothing (Dana's visible actions here are security-type), rather than the two filters accidentally behaving as an OR and returning a confusing mixed result.

The search box matches against both the actor's name and the action text in one pass, and every match gets the same safe-highlighting treatment used in bootstrap-search-results-highlighting — the query is escaped before being used to build a RegExp (so a search containing a regex-special character can't break or misbehave), and the source text is HTML-escaped before highlighting (so an actor name or action text can never be misinterpreted as markup).

Each entry's tone field is independent of its type field — a security event can be a routine invite (secondary) or a genuinely concerning new-device sign-in (warning), which is why tone is stored per entry rather than derived automatically from type; two events of the same category don't necessarily carry the same real-world severity.

Build with AI

Build, Understand, Optimize, and Extend It With AI

Hand this snippet to an AI coding assistant like Claude and ask it to add a date-range filter alongside the existing search and type filters (combining with the same AND logic), or to add a CSV export button that downloads the currently filtered entries, not the full unfiltered log.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a Bootstrap 5.3 filterable, searchable audit log viewer, using the real Bootstrap CDN framework (bootstrap.min.css and bootstrap.bundle.min.js), not custom CSS made to resemble it.

Requirements:
- A list of at least 7 sample audit log entries, each with an actor name, an action description, a type (e.g. security, content, billing) shown as a colored badge, and a relative timestamp.
- A search input filtering by actor name or action text, and a type dropdown filtering by category — both filters must combine with AND logic, narrowing the same list together rather than one overriding the other.
- Matching search text must be safely highlighted in both the actor name and action text, with the search query escaped for safe use in a RegExp and the source text HTML-escaped before rendering.
- Show a live "X of Y events" count reflecting the currently filtered results, and an explicit no-matches message when both filters together exclude everything.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.

Step by step

How to Use

  1. 1
    Load the snippetAll 7 audit events show, each tagged with a colored type badge and a relative time.
  2. 2
    Type "dana" in the search boxThe list narrows live to Dana's two events, with "Dana" highlighted in yellow in each.
  3. 3
    Select "Content" from the type dropdown while still searching "dana"The list empties, since none of Dana's visible events are content-type — both filters apply together.
  4. 4
    Clear the search and leave "Content" selectedOnly the content-type events show, regardless of actor.
  5. 5
    Reset both filtersAll 7 events reappear, and the count reads "7 of 7 events".

Real-world uses

Common Use Cases

DEV
Admin panels and internal security dashboards
Pairs with bootstrap-user-permission-matrix for a fuller access-and-activity review panel.
Compliance and SOC2-style activity reporting
A searchable, filterable event log is a common requirement for enterprise security reviews.
Support tooling investigating a specific user's account history
Search by actor name to quickly review everything a specific team member has done.

Got questions?

Frequently Asked Questions

They combine with AND logic — an entry must satisfy both the current search text and the current type selection (when either is set) to appear, which is why searching one actor while filtering to an unrelated type can correctly return zero results.

Yes — the query is escaped before being used to build a RegExp, the same technique used in bootstrap-search-results-highlighting, so typing a character like "(" or "*" searches for it literally instead of breaking or matching unpredictably.

Two events of the same type can carry very different real-world significance — a routine invite and a suspicious new-device sign-in are both "security" events, but only one deserves a warning-colored badge, which is why tone is set per entry rather than inferred from type.

Yes. Keep LOG as static data, track search and type filter in component state, and derive the filtered/highlighted list in the render function using the same combined AND-filter and escape-then-highlight approach.