> For the complete documentation index, see [llms.txt](https://docs.limio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.limio.com/developers/custom-components/development-guidelines.md).

# Development Guidelines

Guideline to work with Custom Components

These guidelines outline the best practices and requirements for developing custom components in Limio.

### How to create new Custom Components

To create a Custom Components, you can:

* take an existing **Limio Component** and turn it into a **Custom Component** to accelerate your development.
* Create one from scratch.

It is important to note that all **Custom Components** are owned and maintained by your development team once created or forked. Each **Custom Component** can be laid out as you wish, spit into multiple files or a single file containing all of your logic.

### Styling

Use `.css` files for styling your components. Sass (`.scss`, `.sass`) and Less (`.less`) are also supported, and shipped Limio components use them. CSS modules work for each of these: name the file `.module.css`, `.module.scss` or `.module.less` and import the class names.

### Source languages

This section applies to Limio release 118.0.1 and later.

Write your component in JavaScript or TypeScript. The Limio build compiles `.js`, `.jsx`, `.ts` and `.tsx` files.

| Source                               | Support    | What the build does                                                                                               |
| ------------------------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------- |
| JavaScript with JSX in a `.jsx` file | Supported  | Compiles the file.                                                                                                |
| TypeScript in a `.ts` or `.tsx` file | Supported  | Removes the types and compiles the file. The build does not do a type check.                                      |
| JSX in a `.js` file                  | Deprecated | Compiles the file and writes `DEPRECATED: JSX in <file>` to the build log. Rename the file to `.jsx`.             |
| Flow annotations                     | Deprecated | Removes the annotations and writes `DEPRECATED: Flow in <file>` to the build log. Migrate the file to TypeScript. |

* The build reads the entry file from `main` in the `package.json` of the component. For a TypeScript component, set `main` to your entry file, for example `./index.tsx`. If `main` is not set, the build looks for `./index.js`, then `./index.jsx`, then `./index.ts`.
* If you rename the entry file from `.js` to `.jsx`, the build finds the `.jsx` file. A change to `main` is not necessary.
* The build compiles JSX to `React.createElement` calls. Import `React` in each file that contains JSX.
* From Limio release 118.0.40, the build does not use the `tsconfig.json` at the root of your repository. It compiles TypeScript with `target: esnext`, `jsx: react` and `verbatimModuleSyntax: false`.
* The build finds Flow in a `.js`, `.mjs` or `.jsx` file from the `@flow` comment. The error `Flow is not supported` in a build log means that the compiler found a `@flow` comment that the build did not remove. Remove the Flow annotations from that file.

### Build environment

This section applies to Limio release 118.0.37 and later. Earlier releases can use other versions or other tools.

Limio builds your components in the build image of your Limio release. The build does not use the tools on your machine.

| Tool            | The Limio build uses |
| --------------- | -------------------- |
| Node.js         | Version 22           |
| Package manager | pnpm, version 11     |
| Bundler         | Vite                 |

The build does not use Yarn. The pnpm install does not use a lockfile, so a `yarn.lock` or `package-lock.json` file in your repository does not set the versions that pnpm installs. pnpm installs each dependency from the version range in the `package.json` of the component.

These versions belong to the release image, so they can change when Limio upgrades your environment.

### Supported imports

Import platform code from `@limio/sdk` and its subpaths only. Those exports are the supported interface, and they are the ones this documentation describes.

A deep import into another Limio package, for example `@limio/shop/src/shop/checkout/basket/index.ts`, reaches internal code. Limio renames, moves and deletes internal code in any release, and the release notes do not list those changes, because they are not part of the supported interface. A component that imports internal code can therefore stop building, or stop working, after an upgrade.

If you need behaviour that `@limio/sdk` does not export, ask Limio Support. Do not reach into the internals.

### Understanding your Key files

There are some key files you should know about:

1. **Component Entry Point:**
   * **File Path:** `./components/[componentDir]/index.js`
   * This is the main file of your component where your React component is exported.
   * Your component **must be exported as the default export** from this file.
2. **Storybook File:**
   * **File Path:** `./component-playground/src/stories/[componentDir].stories.js`
   * This file defines your component's stories for Storybook, allowing you to display and test your component in various states and configurations.
   * Use Storybook to test and showcase your component in various states. This ensures functionality across multiple scenarios and datasets.
3. **Component Package JSON:**
   * **File Path:** `./components/[componentDir]/package.json`
   * Contains:
     * **Dependencies:** Manage external packages required by your component. Where your environment permits third-party packages, Limio installs the packages with pnpm when it builds your component, and bundles them with your component. In some environments, Limio also runs `npm install` in your component folder. The install runs with `--ignore-scripts`, so a package that must run a post-install script does not work. Ask Limio Support to permit third-party packages in your environment.
     * **Limio Props:** Define custom properties (e.g., string, boolean, picklist) to make your component customizable within the Limio ecosystem. This allows users to adapt the component's behavior and appearance according to their needs. You can learn more about each Prop Types [here](https://docs.limio.com/developers/custom-components/prop-types.md).
     * **Translatable Fields:** List in `translatableFields` the default text that a content editor can translate. Limio then shows a **Localisation** tab for your component in the Page Builder. Each item in the list must be the exact default text that your component gives to the `t()` function of the `useTranslation` hook. An empty list gives no tab. See [Localisation for translatable fields](https://docs.limio.com/components/component-library/legacy-configuration-components/localisation-for-translatable-fields).
   * Declare each package that Limio supplies at runtime as a peer dependency with `"*"`, and do not add it to `dependencies`. Your component must use the copy that Limio runs, because a second copy of a package such as React breaks your component. The supplied packages include `react`, `react-dom`, `@fortawesome/react-fontawesome`, `@fortawesome/fontawesome-svg-core` and `@limio/sdk`.
   * Do not use a `workspace:` version for any dependency. npm cannot resolve a `workspace:` version, and the build fails. The Yarn path form, for example `workspace:packages/limio-sdk`, also stops the pnpm install with `Invalid workspace: spec`.
   * Keep your `package.json` clean and test fields to ensure smooth integration with Limio.
   * The **name**, **description**, and **version** for your component are defined in the `package.json` file. These fields:
     * Appear to the user in **Limio's** **Page Builder**.
     * Are pulled into your component during rendering.

#### Example `package.json`

```json
{
  "name": "headings",
  "version": "1.0.0",
  "description": "A headings component",
  "main": "./index.js",
  "dependencies": {
    "react-i18next": "^11.3.1"
  },
  "peerDependencies": {
    "react": "*"
  },
  "limioProps": [
    {
      "id": "heading",
      "label": "Heading",
      "type": "string",
      "default": "Lorem ipsum dolor sit amet"
    },
    {
      "id": "subheading",
      "label": "Subheading",
      "type": "string",
      "default": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
    },
    {
      "id": "componentId",
      "label": "Component Id",
      "type": "string",
      "default": "headings-limio"
    }
  ]
}
```

### SEO best practices

* **Use Semantic Headings (`h1`, `h2`, etc.) Properly**
  * Each component should use appropriate heading levels (`h2`, `h3`, etc.) based on its placement in the page.
  * Avoid multiple `<h1>` tags unless the component is the primary heading of the page.
* **Ensure Proper Use of ARIA Attributes**
  * If the component is interactive (e.g., buttons, modals, dropdowns), use proper ARIA roles (e.g., `role="button"`, `aria-expanded`, `aria-labelledby`).
  * This helps screen readers and improves usability, indirectly benefiting SEO.
* **Use Descriptive `alt` Attributes for Images**
  * If the component includes an image, always provide an `alt` attribute.
  * Avoid generic descriptions like `"image"`; use meaningful content.
* **Avoid Excessive Nesting**
  * Use only the necessary number of divs (`<div>`), spans, or other elements. Over-nesting can make the HTML structure difficult to interpret.
* **Use Meaningful Link Text**
  * If the component includes links, avoid generic anchor text like `"Click here"`.
  * Instead, use descriptive text like `<a href="example.com">Learn more about our services</a>`.

#### Accessibility best practices

Custom components must meet **WCAG 2.1 AA** standards, required under the European Accessibility Act (EAA) from June 2025.

**Must-haves:**

* **Keyboard navigable** — all interactive elements (buttons, links, inputs) must be usable without a mouse
* **Visible focus indicators** — never remove `outline` styles without a visible replacement
* **Colour contrast** — 4.5:1 ratio for normal text, 3:1 for large text
* **Image alt text** — meaningful `alt` on informative images, `alt=""` on decorative ones
* **Form labels** — every input needs an associated `<label>`, not just placeholder text
* **ARIA for interactive components** — use `aria-expanded`, `aria-label`, `aria-live` etc. where native HTML semantics aren't sufficient


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.limio.com/developers/custom-components/development-guidelines.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
