Typix LogoTypix
Editor Toolbar

MarkButton

Toggle inline text formatting marks — bold, italic, underline, strikethrough, inline code, superscript, and subscript.

Install

npx typix ui add mark-button

Import

import { MarkButton } from "@/components/typix/main/mark-button";

Props

PropTypeDefaultDescription
typeMarkTypeThe mark to toggle. Required.
textstringOverride the button label.
hideWhenUnavailablebooleanfalseHide the button when the mark can't be applied.
showShortcutbooleantrueShow keyboard shortcut in tooltip.
onToggled(isActive: boolean) => voidCalled after the mark is toggled.
classNamestringAdditional CSS classes.

MarkType

type MarkType =
  | "bold"
  | "italic"
  | "underline"
  | "strike"
  | "code"
  | "superscript"
  | "subscript";

Hook

Use useMark to build a custom button:

import { useMark } from "@/components/typix/main/mark-button";

function MyBoldButton() {
  const { isActive, canToggle, handleToggle, label, Icon } = useMark({ type: "bold" });

  return (
    <button onClick={handleToggle} disabled={!canToggle} aria-pressed={isActive}>
      <Icon size={14} />
      {label}
    </button>
  );
}

On this page