Introducing AlienX extension – The next evolution of UI development.Check it out on VS Code
Enjoy AlienUI React? Give it a star on Github ⭐
A customizable switch for enabling and disabling options.
A default switch for toggling on and off.
import React, { useState } from "react";
const Switch = () => {
const [isEnabled, setIsEnabled] = useState(false);
return (
<div
className={`relative inline-flex h-7 w-14 items-center rounded-full cursor-pointer transition ${
isEnabled ? "bg-black" : "bg-gray-400"
}`}
onClick={() => setIsEnabled(!isEnabled)}
>
<span
className={`inline-block h-6 w-6 transform rounded-full bg-white transition ${
isEnabled ? "translate-x-6" : "translate-x-1"
}`}
/>
</div>
);
};
export default Switch;
import React from "react";
import Switch from "./components/comp/Switch/GalaxySwitch";
const App = () => {
return (
<div>
<Switch />
</div>
);
};
export default App;