Skip to content

Trix

A rich text editor web component for writing messages, comments, and articles in web apps.

Stars
20k
Forks
1.1k
Licence
MIT
Language
JavaScript
Last update
9 days ago
Type
Library

What it is

Trix is a WYSIWYG (what you see is what you get) text editor that you add to a web page so users can format text with bold, lists, quotes and links. It is built from standard web components and produces simple, consistent HTML. It comes from 37signals, the company behind Basecamp, and is used there.

  • Add a formatted comment box to a web form using a trix-editor tag
  • Save editor content to a hidden form input and submit it with your form
  • Add custom toolbar buttons that trigger your own actions via the trix-action-invoke event
  • Populate an editor with stored HTML content on page load

Great for

  • Developers adding a rich text box to a Rails or other web app
  • Teams that want simple, consistent HTML output for comments or messages
  • Projects that need embedded attachments inside text
  • Developers who want control over editor behavior instead of browser contenteditable quirks

Not ideal for

  • Non-developers looking for a ready-made app; Trix is a component to integrate, not a standalone product
  • Projects needing complex document features like tables or heavy page layout, which the README does not describe
  • Sites that must support old browsers, since it targets evergreen desktop and mobile browsers
Step-by-step guide: how to use TrixInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    Include from npm CDN (simplest)

    <link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.0.8/dist/trix.css"> <script type="text/javascript" src="https://unpkg.com/trix@2.0.8/dist/trix.umd.min.js"></script>
  2. 2

    Run it

    • Add the trix.css and trix.umd.min.js tags to the head of your page
    • Place an empty <trix-editor></trix-editor> tag in your page body
    • Optionally add a hidden input with an id and reference it with the editor's input attribute to submit content with a form
  3. 3

    Get the most out of it

    • Use the input attribute with a hidden field to submit editor content with forms
    • Override Trix.config.toolbar.getDefaultHTML() to customize the toolbar without modifying Trix
    • Add custom buttons with data-trix-action="x-..." and listen for trix-action-invoke
    • Set willCreateInput = false with ElementInternals support to skip the hidden input when using the name attribute

Downloads

Strengths

  • Built on standard web APIs such as Custom Elements and Element Internals
  • Treats contenteditable as an input device, giving consistent behavior across browsers
  • Produces terse, consistent HTML output

Trade-offs

  • The README describes only basic editing; advanced features are not detailed in the excerpt
  • Requires JavaScript integration work and some HTML knowledge to set up forms and toolbars
  • Trix content must be sanitized carefully when loaded from untrusted sources

How it compares

ProjectStarsTypeLevelUpdatedBest for
trix (this)20kLibraryintermediate9 days agoDevelopers adding a rich text box to a Rails or other web app
tiptap38.9kLibraryintermediate4 days agoDevelopers building a custom text editor into a web product
lexical24kLibraryintermediate4 days agoDevelopers adding a rich text editor to a web app
pell12kLibrarybeginner2.5 years agoWeb developers who need a simple rich text box in a form or admin page
milkdown12kLibraryadvanced4 days agoDevelopers adding a rich markdown editing box to a web app
tui.editor18kLibraryintermediate2.3 years agoWeb developers who want an embeddable Markdown editor in their own site or app

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.