> For the complete documentation index, see [llms.txt](https://docs.uibakery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uibakery.io/reference/working-with-components/table/more-ways-to-use-the-component/how-to-highlight-text-in-a-table-using-mark.js.md).

# Highlighting Table text using mark.js

This example may be useful when you need specific text within the table to stand out, say for search highlighting, filter feedback, contextual emphasis, etc. It enhances the user experience by allowing dynamic interaction with the table data. \
Here's how you can configure it in UI Bakery:point\_down:

1. Open the *Custom code* tab in the Builder's footer and add the following code to integrate the *mark.js* library:

```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/mark.js/8.11.1/mark.min.js"></script>
<style>
  mark {
    background: yellow;
    color: black;
  }
</style>
```

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2F4nRX2IY9Db4I5xRZvt65%2FCleanShot%202025-09-09%20at%2013.10.03%402x-min.png?alt=media&amp;token=af5be4ff-fa5d-4042-943d-2a6134f91271" alt=""><figcaption></figcaption></figure>

2. Next, create a *JavaScript Code* action step and specify the following code:

```javascript
const context = document.querySelector('ub-smart-table');
const instance = new Mark(context);
instance.unmark();
instance.mark({{data}});
```

This code selects the table, initializes mark.js, removes any previous highlights, and applies new ones based on the data provided.

{% hint style="info" %}
Instead of the `{{data}}` variable, you can refer to a Text input component, for example, `{{ui.input.value}}`.
{% endhint %}

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FwnMvepqt9ACzKsUhV1VF%2FCleanShot%202025-09-09%20at%2013.52.43%402x-min.png?alt=media&amp;token=b7743c07-98a0-4285-8660-32bb5c828367" alt=""><figcaption></figcaption></figure>

3. Add a *Text input* component to the canvas and assign the action from step 2 to the component's *On Change* trigger.

Done! Now, when the value in the input changes, the text in the table is highlighted accordingly.

<figure><img src="https://837703843-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUX6zPRMFFK0yrTghj7cY%2Fuploads%2FmUPc8MvTyQQYTwUMrmkV%2FCleanShot%202025-09-09%20at%2013.57.52%402x-min.png?alt=media&amp;token=290aa8df-2688-443d-8efd-d3283363c4f5" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.uibakery.io/reference/working-with-components/table/more-ways-to-use-the-component/how-to-highlight-text-in-a-table-using-mark.js.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
