# Flux 2.0 — Rich text editor A field with a formatting toolbar for short structured text, and the prose styles it produces. Reference: https://flux.kaptio.com/components/rich-text-editor/ Requires: https://flux.kaptio.com/tokens/v2/flux.css and flux-components.css ## Use it when For text that needs a little structure: itinerary notes, supplier instructions, a description shown to travellers. The toolbar covers bold, italic, a heading, a quote and two kinds of list, as one tab stop with arrow-key movement, and each button shows whether its format applies at the cursor. The content is styled by flux-prose, the same class that renders the saved text elsewhere, so what is written is what is shown. ## Do not use it when Not for plain text; use a Textarea. Not for long documents with tables, images and comments; that needs a dedicated editor engine. Not for code. ## Markup ### Editor
Itinerary notes

Day 2: Golden Circle

Pick-up from the hotel at 08:30. Bring a waterproof layer for Gullfoss.

  • Þingvellir National Park
  • Geysir geothermal area
  • Gullfoss waterfall
### Prose

Day 2: Golden Circle

Pick-up from the hotel at 08:30. Bring a waterproof layer for Gullfoss; the spray carries well beyond the viewing platform.

Lunch is included at Friðheimar. Tell the guide about allergies at pick-up.

Booking reference KB-104931. Full terms are in the booking conditions.

## API - flux-editor (class): The field surface holding the toolbar and the content. - data-flux-editor (attribute): Wires the toolbar, its roving focus and its pressed states. - flux-editor__toolbar | __group (class): The toolbar, with role="toolbar" and a label, and its groups. - flux-editor__tool (class): A toolbar button. Give it an aria-label and aria-pressed. - data-command (attribute): On a tool: bold, italic, heading, quote, bullets or numbers. - flux-editor__content (class): The contenteditable region. Add flux-prose, role="textbox", aria-multiline="true" and aria-labelledby. - data-placeholder (attribute): On the content: shown while it is empty. It does not replace the label. - flux-prose (class): Styles rich text anywhere it is read, held to the reading measure. ## Accessibility - The toolbar has a label and roving tabindex, so it is one tab stop. - Each tool reports aria-pressed, so the state is not conveyed by fill alone. - The content has role="textbox" and aria-multiline, and is labelled by the visible label. - Formatting uses the browser’s editing commands so the component works without an engine; a product with its own editor engine binds the same toolbar markup to it. ## Keyboard - Tab: Moves to the toolbar, which is one stop, then to the content. - ← → Home End: In the toolbar, moves between tools. - Enter, Space: On a tool, applies or removes its format. - ⌘B, ⌘I or Ctrl B, Ctrl I: In the content, bold and italic. ## Tokens - --flux-editor-bg | -border | -border-hover - --flux-editor-toolbar-bg | -toolbar-padding - --flux-editor-tool-size | -tool-icon | -tool-hover | -tool-pressed-bg | -tool-pressed-icon - --flux-editor-content-padding | -min-height - --flux-prose-text | -gap | -heading-2 | -heading-3 | -quote-border | -quote-text | -link ## Do - Offer only the formats the text needs. - Render saved text with flux-prose so it matches the editor. - Sanitise the HTML on the server before it is stored or shown. ## Do not - Do not offer colour, font or size controls. Flux sets those. - Do not use the editor where a Textarea would do.