I had a NextJS application that utilized Atomic CSS and featured a button which becomes disabled if a form is left unfilled:
<Button
className="primary"
onClick={handleCreateCommunity}
disabled={!phone || !communityName}
>
Create
</Button>
Now, I am looking to switch to using the new TailwindUI primary button style:
.primary-btn {
@apply inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500;
}
However, I am facing an issue with applying the disabled state. Do I need to create another component like .btn-disabled
? If so, how can I then apply that style when the form remains incomplete?
--
UPDATE:
Here is what my index.css file currently looks like:
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.primary-btn {
@apply inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:bg-gray-300;
}
}