creativetimofficial / material-tailwind

@material-tailwind is an easy-to-use components library for Tailwind CSS and Material Design.
https://material-tailwind.com/
MIT License
3.71k stars 318 forks source link

Button Loading properly not working #806

Closed rezzak-allcode closed 1 week ago

rezzak-allcode commented 1 month ago

` <Button id="primary-btn" className="w-1/2" onClick={() => setOpen(false)} loading={isLoading}

Ok `

dev-phantom commented 3 weeks ago

tried to reproduce this issue on my end but it works fine

kindly provide more context to this or better still you can check if your isLoading state is set to a boolean as the loading prop takes a true, false and an undefined value Hope this helps

sajadevo commented 1 week ago

@rezzak-allcode here is an example of controlling the loading state of the button using the react useState hook.

import { useState } from "react";
import { Button } from "@material-tailwind/react";

export function ButtonDefault() {
  const [isLoading, setIsLoading] = useState(false);

  return (
    <Button onClick={() => setIsLoading((cur) => true)} loading={isLoading}>
      Button
    </Button>
  );
}