State Pages Deprecated
Deprecated: use Web Pages for new work State pages and UI components still run, but new pages should use Web Pages: faster, simpler and fully indexable. The migration guide shows which web block replaces what.

RUAL Components

A Custom Component can embed the components that ship with RUAL, such as input.jsx, button.jsx and translate_key.jsx. Give each one a unique uid and pass the parameters listed below.

The default components are React functional components

By default, RUAL offers an extensive selection of components within blueprinting. These standard blocks are React-based functional components, integrated into blueprinting. This page shows how to use them inside your custom components, and lists the common ones with their names.

Every reactive component needs a unique uid

Most reactive components need their own unique identifier, so they can listen for changes in the global state or handle other RUAL events.

  • Extract the uid from the params by prefixing them with uid, .
  • Make each injected component's uid unique by prefixing it with an identifier of your own, in combination with the existing uid.

Using translations

The translation component requests translations and can incorporate HTML content into them. The translate function is available for use within JavaScript and React as well.

translate-component.jsx
import { Translate } from './translate_key.jsx';

export default function CustomExampleTranslate (props) {
  return (
    <div>
      <Translate bp_translate_key="key_to_translate" />
    </div>
  );
}

Using inputs

The input components are integrated with the global state through the state get and set key blocks in blueprinting. Constructing your own input is feasible, but often unnecessary.

input-component.jsx
import { TextInput } from './input.jsx';

export default function CustomExampleInput ({ uid, onenter }) {
  return (
    <div>
      <TextInput uid={'input_' + uid} bp_field="form.name" onenter={onenter} />
    </div>
  );
}

Commonly used components

Nearly all of these accept the default parameters uiclass, uistyle and uiattributes. A children parameter means the component supports React children: nest other components within its tags. The full props contract is in the Component Props Reference.

CategoryFilenameParams
Inputsinput.jsxuid, bp_field, type, onenter
input_file.jsxuid, bp_action_guid, bp_field, type, onenter
input_price.jsxuid, bp_field, disabled
input_date.jsxuid, bp_field
input_checkbox.jsxuid, bp_field, value
Buttonsbutton.jsxvalue, icon, iconclass, iconstyle, type, inpinfunction
button_content.jsxchildren, icon, iconclass, iconstyle, type, inpinfunction
Contenttranslate_key.jsxbp_translate_key, language

Styling: apply the root props to your root element

Accept the uiclass, uistyle and uiattributes props and apply them to your component's root element. That lets blueprint authors style instances from the canvas without touching your code. Keep everything inside the root on your own classes. Per-component props and data-fetching patterns are in the Component Props Reference and RUAL Library.

Migrate from State Pages Move a page from state blocks and components to web blocks.

Frequently asked

Can I reuse RUAL's built-in components inside my custom component?

Yes. RUAL's default components are React functional components, and you can embed them inside your own custom components. Commonly used ones include input.jsx, button.jsx and translate_key.jsx, and each accepts documented parameters.

Why does each RUAL component need a uid?

Most reactive components need their own unique identifier so they can listen for changes in the global state or handle other RUAL events. When you inject built-in components into a custom component, extract the uid from the params and prefix it with your own identifier to keep it unique.

How do I let blueprint authors style my custom RUAL component?

Accept the uiclass, uistyle and uiattributes props and apply them to your component's root element. That is the contract that lets blueprint authors style instances from the canvas without touching your code.