Design4 min read
Add a border color to an input when it’s filled in Webflow

Introduction
| Input state | Natively available in Webflow | Solution |
|---|---|---|
| Hover | Yes | Styles panel |
| Focused | Yes | Styles panel |
| Non-empty (filled in) | No | JS script (this tutorial) |
Webflow doesn't let you change the "non-empty/filled in" state of an input natively.
You can only edit these states:
- Hover
- Pressed
- Focused
Giving an input a specific color can bring a few design and UX benefits:
- Visibility: A specific color can help distinguish a field from the rest of the interface, making the form more intuitive and easier to navigate.
- Feedback: Color can act as instant feedback. For example, a color change can show whether the entered information is valid or not (green for correct, red for an error).
- Aesthetics: A well-chosen color palette can improve the visual harmony of the interface and create a more pleasant user experience.
It’s important to make sure your color choices are accessible and don’t create problems for users with reduced or different color vision. As always, Gemeos Webflow agency has a solution for you!
Tutorial
1. Add this piece of JavaScript
You can add this custom code in an embed, before the <body> tag at the page level, or even at the project level (in Settings) if you want the styling to apply to every input on your site.
<script>
// Add this event to every input in your form
document.querySelectorAll('input').forEach(input => {
input.addEventListener('input', function() {
// Check whether the input contains text
if (this.value.length > 0) {
// Change the border color if the input isn't empty
this.style.borderColor = '#93CDEA'; // You can choose any color you want
} else {
// Reset the border color if the input is empty
this.style.borderColor = ''; // Restore the default border color
}
});
});
</script>2. Customize your input border color
Change the "#93CDEA" color in the code below to the hex code of the color you want.
3. Publish your page and test the result



