I have a classic select
input which receive an array of strings.
Problem, the chevron is on absolute right of the select, against the border.
I want to move its poition to the left a little.
How to achieve that with tailwind ?
Here is a Tailwind playground
Here is the code :
<div class="m-8">
<select class="h-10 w-full rounded border border-solid border-neutral-300 px-4 text-sm">
<option value="none">None</option>
{list?.map((item) => (
<option key="{item}" value="{item}">{item}</option>
))}
</select>
</div>
2
Answers
We can’t add padding to the default select arrow. The workaround you can do is use
outline
property. You can achieve is using following code.Here, we are giving border to just the right side and setting it to 8px of width. This will work as a padding after we add the outline. Don’t forget to set border colour to transparent. Then add outline property and set the colour you want to outline. This will create the same effect that you wanted with border and padding.
Here’s the tailwind playground
The "select" elements are complicated to style. For more freedom I would opt for a home made dropdown.
Otherwise there are always some css tricks:
https://play.tailwindcss.com/YsqkNDblz7