Skip to content

React

How to install and use Plus UI in your React applications.

This guide will walk you through setting up Plus UI in a React project and demonstrate how to use our components, including handling properties and events.

First, install the necessary Plus UI packages. @plusui/core contains all the web components, and @plusui/react provides React-specific wrappers for a seamless integration.

Terminal window
npm install @plusui/core @plusui/react

Now you can start using Plus UI components in your React application.

Import any component you need from the @plusui/react package. Let’s use the Button component as an example.

import { PlusButton } from '@plusui/react';

You can customize components by passing props. These props correspond to the component’s attributes. For example, you can change the variant and size of the PlusButton.

<PlusButton variant="filled" size="large">
Large Filled Button
</PlusButton>

Plus UI components emit custom events. In React, these are converted to on[EventName] props. For the plus-click event, you would use the onPlusClick prop.

const handleClick = () => {
alert('Button clicked!');
};
<PlusButton onPlusClick={handleClick}>
Click Me
</PlusButton>

Here is a complete example of a simple React App component that uses Plus UI.

src/App.js
import React from 'react';
import { PlusButton } from '@plusui/react';
function App() {
const handleClick = () => {
alert('Plus UI button was clicked!');
};
return (
<div className="App">
<h1>Welcome to Plus UI with React!</h1>
{/* Example with props */}
<PlusButton variant="secondary" size="small">
Secondary Button
</PlusButton>
{/* Example with an event handler */}
<PlusButton variant="filled" onPlusClick={handleClick}>
Click to Trigger Event
</PlusButton>
</div>
);
}
export default App;

Join the Community

Plus UI is built by the community. Join us on our platforms to contribute, get help, and stay up to date.