Provider
Provider component which aggregates the main Clay, Icon, and Modal.
install | yarn add @clayui/core |
---|---|
version | 3.119.0 |
Example
import {Provider} from '@clayui/core';
<Provider spritemap={spritemap}>
<Icon symbol="books" />
<Icon symbol="times" />
</Provider>
Application provider
A Provider is a component that be at the root of your application. Provider is used by other Clay components to define theme
scopes, render icons with spritemap
, or help handle Modal creation in your application.
Theme
Themes in Clay is different from patterns that are common in other libraries, Clay's CSS framework is built using Sass and we allow to create themes based on CSS scope, a class is added in Clay components that use React.Portal
to render elements in the body for example.
<Provider theme="cadmin">Content</Provider>
Icon spritemap
Icons need the path where to find the icon collection to be rendered. Clay components that use the Icon
component pass props from spritemap
to the icon, to avoid passing spritemap
to all your components at different levels, add the spritemap path in Provider
to that Icon
can use and avoid passing the property on all components.
<Provider spritemap={spritemap}>
<Icon symbol="books" />
<Icon symbol="times" />
</Provider>
API
Property | Description |
---|---|
children React.ReactNode | The content of the Provider. |
reducedMotion 'user' | 'always' | 'never' | Defines the transition for the entire tree. The default value is 'user' |
spritemap string | Path to the location of the spritemap resource. |
storageMaxSize number | Set the amount of items that can be cached, set to zero will be
treated as infinite, be aware to set an ideal size to offer a
positive experience for your user but not use a large amount of memory. The default value is 20 |