Reputation:
I have the following styles in Figma:
button {
display: flex;
flex-direction: row;
align-items: center;
padding: 10px 16px;
position: absolute;
width: 227px;
height: 40px;
/* Button/Red */
background: #E30513;
/* RedBtn */
box-shadow: 0px 4px 12px rgba(157, 84, 81, 0.44);
border-radius: 10px;
}
<button type="submit">
Make request
</button>
I tried to rewrite these styles on tailwind for the button:
<script src="https://cdn.tailwindcss.com"></script>
<button
type="submit"
class="inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-xl shadow-sm text-white bg-red-600 hover:bg-red-600 focus:outline-none focus:ring-2 focus:ring-offset-2"
>
Make request
</button>
However, I have faced with problems:
border-radius: 10px
only rounded-lg
or rounded-xl
.padding: 10px 16px;
only pre-defined padding values#E30513
Could you explain me, how to use TailwindCSS in my case?
Upvotes: 1
Views: 2423
Reputation: 8858
Specifically, in a CSS file, you can assign Tailwind classes to each other using the @apply
directive.
@apply
- TailwindCSS Docsbutton {
@apply flex flex-row items-center absolute w-[227px] h-10 shadow-[0px_4px_12px_rgba(157,84,81,0.44)] px-4 py-2.5 rounded-[10px];
background: #e30513;
}
You can also look for a transformation tool. I'd like to highlight just one, simply because it's open-source:
Many types of converters have been created within a large project. In my opinion, they can effectively speed up this kind of work. However, it might still be worth creating custom template settings and simplifying the code.
Upvotes: 0
Reputation: 166
There are basically two ways to solve this problem.
Tailwind CSS v3 actually supports setting arbitrary values.
border-radius: 10px
can be represented as rounded-[10px]
padding: 10px 16px
can be represented as py-[10px] px-[16px]
box-shadow: 0px 4px 12px rgba(157, 84, 81, 0.44)
can be represented as shadow-[0px_4px_12px_rgba(157,84,81,0.44)]
background: #E30513
can be represented as bg-[#E30513]
Here's an example of your button: TailwindCSS Playground
Alternatively, if you plan to use these values more than once, you could also easily extend your Tailwind CSS configuration.
Here are the links to the relevant documentation pages:
borderRadius
in your theme - TailwindCSS Docspadding
in your theme - TailwindCSS DocsboxShadow
in your theme - TailwindCSS DocsbackgroundColor
in your theme - TailwindCSS DocsUpvotes: 1
Reputation: 1855
Here is how you can do it directly from TailwindCSS classes using arbitrary values.
<script src="https://cdn.tailwindcss.com"></script>
<button
type="submit"
class="
flex flex-row items-center py-[10px] px-[16px]
absolute w-[227px] h-[40px] bg-[#E30513]
shadow-[0px_4px_12px_rgba(157,84,81,0.44)]
rounded-[10px]
"
>
Make request
</button>
Upvotes: 0