Basic example

Mark.js is a text highlighter written in JavaScript. It can be used to dynamically mark search terms or custom regular expressions and offers you built-in options like diacritics support, separate word search, custom synonyms, iframes support, custom filters, accuracy definition, custom element, custom class name and more. Mark.js will wrap matches with a specified element and optionally with an assigned class. When not changing the default element mark, browsers will ensure that it looks highlighted by default

Example

Lorem ipsum dolor sit āmet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna lorem ipsum aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, nò sea takimata sanctus est lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur lorem sadipscing elitr
Exclude matches

When having a context that contains multiple elements and you need to ignore matches in some of them, the option exclude may be worth gold. You can pass an array of exclusion selectors and matches within these selectors will be ignored from highlighting. Initialize mark.js directly on the div containing the content (in this case .mark-exclude), or specify a exclude array matching the elements that should be ignored.

Example

Lorem ipsum dolor sit āmet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna lorem ipsum aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, nò sea takimata sanctus est lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur lorem sadipscing elitr
Synonyms

There might be cases where highlighting synonyms for words is helpful for users. Take "one" and "1" as an example. When a user searches for "one last todo", he might expect to highlight also "1 last todo". In German languages, you could also map umlauts, e.g. "ü" with "ue" or "ö" with "oe". The following example will add the synonym "1" for "one", "10" for "ten" and vice versa.

Example

Calm down, get hold of yourself. For example, Before you tell him what you think of him, count to ten. Often used as an imperative, this phrase in effect means that if one takes the time to count from one to ten one can regain one's composure.
Element and class

When you're calling mark.js on some container – whether by mark() or by markRegExp() – it will find matches and wraps them with a defined element (<mark> by default) and optionally with a class assigned to that element. So assuming we'd like to highlight "text" with a span tag and a classes bg-primary, bg-opacity-10, text-primary assigned, then this could be done with element and className options.

Example

Lorem ipsum dolor sit āmet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna lorem ipsum aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, nò sea takimata sanctus est lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur lorem sadipscing elitr
List filtering and highlighting

The following configuration allows us not only to highlight search term, but also filter a specific list (or table) and hide all entries that don't match. This can be done with mark method that highlights custom search terms, and unmark method that removes all highlights created by the library. This config can be used in lists, list groups, tables, dropdown menus and other components.

Example

President Birthplace
Zachary Taylor Barboursville, Virginia
Warren G. Harding Blooming Grove, Ohio
John Quincy Adams Braintree, Massachusetts
John F. Kennedy Brookline, Massachusetts
James Buchanan Cove Gap, Pennsylvania
Rutherford B. Hayes Delaware, Ohio
Dwight D. Eisenhower Denison, Texas
Chester A. Arthur Fairfield, Vermont
Toggle options dynamically

In some use cases you might need to allow users to toggle specific options dynamically via selects or checkboxes. This example demonstrates how a group of checkboxes can turn on and off certain options without changes in JS configuration. A general use case would be custom filtering. You can use accuracy, punctuation, separateWordSearch, caseSensitive, ignoreJoiners options. Note - some options such as RegExp can't be toggled and requires JS configuration.

Example


Lorem ipsum dolor sit āmet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna lorem ipsum aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, nò sea takimata sanctus est lörem ipsum dolor sit amet. Lörem ipsum dolor sit amet, consetetur lorem sadipscing elitr
Activity
New notifications
James has completed the task Submit documents from Onboarding list
2 hours ago
Margo has added 4 users to Customer enablement channel
3 hours ago
Subscription #466573 from 10.12.2021 has been cancelled. Refund case #4492 created
4 hours ago
Older notifications
Nick requested your feedback and approval in support request #458
3 days ago
Mike added 1 new file(s) to Product management project
new_contract.pdf
112KB
1 day ago
All hands meeting will take place coming Thursday at 13:45.
2 days ago
Christine commented on your community post from 10.12.2021
2 days ago
HR department requested you to complete internal survey by Friday
3 days ago
Loading...
Demo configuration
Color mode
Direction
Layouts
Purchase Limitless