Nexo Maker Docs
  • Welcome
  • Getting Started
    • Basic Concepts
      • Starting a Expansion
      • Compiling your Expansion
  • Visual API
    • Modularjs
      • Modularjs Basics
      • Styling
      • useState()
      • useEffect()
      • useGlobalState()
      • useProjectState()
    • [Deprecated] Components
      • Custom HTML documents
    • Themes
      • Replace Assets
      • Assets List
  • Functional API
    • Post Functions
      • Post Sidebar Button
      • Post Editor Module
    • Get Functions
      • Load Assets
      • Load File
      • Get Project
  • API Changelogs
    • Changelog 0.6.1
Powered by GitBook
On this page
  • 🧠 Use Case: Custom-Styled Components
  • πŸ“„ Sample doc.html
  • 🎨 Sample style.css
  • βœ… Benefits of Using loadFile() with defineStyle()
  1. Visual API
  2. [Deprecated] Components

Custom HTML documents

Nexo Maker supports fully custom HTML-based components, making it easy to design rich user interfaces for your tools and extensions.

Previous[Deprecated] Components NextThemes

Last updated 18 days ago

To load external HTML or CSS files into your plugin’s UI, you can use the loadFile() function provided by the API. This is particularly powerful when combined with defineStyle(), which merges your HTML and CSS into a single renderable component.


❇️ You may be interested into reading

🧠 Use Case: Custom-Styled Components

You can pair loadFile() with defineStyle() to render a complete HTML document with CSS styling directly inside the Nexo Maker UI.

πŸ’‘ Example

const html = await api.nexomaker.loadFile(__dirname + "/doc.html", "utf-8");
const css = await api.nexomaker.loadFile(__dirname + "/style.css", "utf-8");

const styledComponent = await api.nexomaker.defineStyle({
  htmldoc: html,
  styledoc: css
});

api.nexomaker.postSidebarIcon({
  button: "Custom Page",
  key: "custom-page",
  icon: await api.nexomaker.imgconvert(__dirname + "/assets/icon.png"),
  route: "/custom",
  component: styledComponent
});

πŸ“„ Sample doc.html

<div class="my-doc">
  <h2>Custom Page</h2>
  <p>This UI is built entirely with HTML and styled using a separate CSS file.</p>
</div>

🎨 Sample style.css

.my-doc {
  padding: 20px;
  background-color: #ffffff;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-family: Arial, sans-serif;
}

.my-doc h2 {
  color: #4caf50;
}

βœ… Benefits of Using loadFile() with defineStyle()

  • Modularity: Keep your UI structure and styling cleanly separated.

  • Maintainability: Easier to update layout and design without touching JS logic.

  • Flexibility: Use the same HTML and CSS in multiple places or expansions.

readfile()