Button
Buttons trigger an action in a web page. It allows the developer to handle an action on user interaction.

Usage
The button text can be changed, and it uses a onclick prop which is handled internally.
npm i react-hartan
import { Button } from "react-hartan"
function App() {
return (
<>
<Button></Button>
</>
)
}
export default AppCustomization With Props
buttonText-> Accepts a node/string type, sent by the user which is shown as the button name.onClickFunction-> Accepts a function, written by the user, which handles the logic when the button is clicked.id-> The id prop is similar to the id attribute in HTML. It allows to provide overall component id.userButtonStyle-> Custom styling prop that accepts the classes written by the user, which defines the custom styling for the button component.
import { Button } from "react-hartan"
function App() {
return (
<>
<Button></Button>
</>
)
}
export default App// App.css
.my-class{
font-size: 2rem;
background-color: red;
}
// App.jsx
import { Button } from "react-hartan"
import "./App.css"
function App() {
const btnTxt = "Custom Text";
async function onclick() {
async function fetchData() {
const response = await fetch("https://farzi-vichar-api.vercel.app/language/hindi/random");
const result = await response.json();
return result;
}
const data = await fetchData();
console.log(data);
}
return (
<>
<Button buttonText={btnTxt} onClickFunction={onclick} userButtonStyle={"my-class"}></Button>
</>
)
}
export default AppComponent Code
This is the code for the Button component.
Last updated