Edit page

Global Props

Sometimes it can be useful to share some configuration props between multiple instances of components of the same or different kind.

This can be achieved by wrapping application or its part with RUIProvider and passing in the common props through globalProps prop. With or without using RUIProvider the component can be configured by passing in the props directly. The props passed in directly always take precedence over props coming from RUIProvider.

Basic Usage

To define global props, you need to import RUIProvider first:

import { RUIProvider } from '@react-ui-org/react-ui';

Then wrap application or its part with RUIProvider with defined globalProps attribute holding an object. Keys are names of the components, and their values are objects with arbitrary props you want to pass to the specified components.

Keys conform to actual names of components:

<RUIProvider globalProps={{
Button: { priority: 'filled' },
TextField: { variant: 'filled' },
SelectField: { variant: 'filled' },

See working example: