JSFiddle - React, Tailwind, and code Playground

by Venkatesh Dematti

HTML

<label for="dropdown">Choose an option:</label>
<select id="dropdown">
  <option value="option1">Option 1</option>
  <option value="option2">Option 2</option>
  <option value="option3">Option 3</option>
</select>

CSS

select {
  appearance: none; /* Removes default styles */
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 10px;
  font-size: 16px;
  cursor: pointer;
  width: 100%;
  max-width: 300px;
}

/* Add custom dropdown arrow using a background image */
select {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="black"><path d="M7 10l5 5 5-5H7z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  padding-right: 30px;
}

/* Focus state */
select:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 3px rgba(0, 123, 255, 0.5);
}

/* Disabled state */
select:disabled {
  background-color: #f5f5f5;
  color: #999;
  cursor: not-allowed;
}
option {
  background: red;
  color: #333;
  font-size: 16px;
  padding: 10px;
}