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.
1. Installation
Section titled “1. Installation”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.
npm install @plusui/core @plusui/react2. Component Usage
Section titled “2. Component Usage”Now you can start using Plus UI components in your React application.
Importing a Component
Section titled “Importing a Component”Import any component you need from the @plusui/react package. Let’s use the Button component as an example.
import { PlusButton } from '@plusui/react';Using Props
Section titled “Using Props”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>Handling Events
Section titled “Handling Events”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>3. Complete Example
Section titled “3. Complete Example”Here is a complete example of a simple React App component that uses Plus UI.
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.