Back
Transform your data entry fields into luminous orbs that glow as you type, enhancing user engagement with ethereal effects.
In this tutorial, you'll learn how to create a captivating input field that lights up with a radiant glow as users type. This playful interaction not only makes your website more engaging but also invites users to interact with their data input more enjoyably. Let's dive in!
The first step in building our Radiant Globe Input is setting up the HTML structure. By using semantic tags, we ensure that our design is both accessible and search-engine friendly. Here’s the basic structure:
<div class="radiant-globe-container">
<input type="text" aria-label="Luminous orb input" class="radiant-globe" placeholder="Type here...">
</div>
We use a div to hold our input field, styled as a glowing orb. The input field is given a descriptive aria-label for accessibility and a placeholder to guide users on what to do.
Our JavaScript will create a shimmering effect that grows as more text is entered. This is achieved by dynamically adjusting the input's CSS properties based on its content length.
function updateGlobeEffect() {
const globeInput = document.querySelector('.radiant-globe');
globeInput.addEventListener('input', function() {
const length = globeInput.value.length;
globeInput.style.boxShadow = `0 0 ${5 + length * 2}px rgba(255, 215, 0, 0.8)`;
globeInput.style.background = `rgba(255, 250, 240, ${0.5 + length * 0.05})`;
});
}
updateGlobeEffect();
Here, the updateGlobeEffect function adds an event listener to the input, causing it to adjust the box shadow and background color intensity based on the length of the text inside. This not only creates visual feedback but also enhances user interaction.
The styling utilizes transitions and conditions to keep the animation smooth. The aim is to provide a tactile, glowing interaction that visually responds to user input. Here’s the CSS code:
.radiant-globe {
border: none;
padding: 15px 30px;
border-radius: 50px;
font-size: 18px;
transition: background 0.3s, box-shadow 0.3s;
outline: none;
width: 200px;
text-align: center;
box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
background: rgba(255, 250, 240, 0.5);
}
.radiant-globe:focus {
box-shadow: 0 0 15px rgba(255, 165, 0, 0.9);
background: rgba(255, 240, 200, 0.7);
}
The CSS ensures that our input field is viewable in the center with a focus state that further accentuates its glowing appearance. The tactile motion provided by transitions enhances usability, delivering a calm yet fascinating experience.
Adhering to accessibility guidelines, all our buttons and input fields include aria-labels to assist screen readers. Placeholder text guides users, and focus states ensure our fields are keyboard accessible. By maintaining semantic HTML and clear headings, our design remains SEO friendly and easily navigable by search engines.
With this Radiant Globe Input, you're not only redesigning an input field but enhancing your website's interactivity and user involvement!
<div class="radiant-globe-container">
<input type="text" aria-label="Luminous orb input" class="radiant-globe" placeholder="Type here...">
</div>
<script>
function updateGlobeEffect() {
const globeInput = document.querySelector('.radiant-globe');
globeInput.addEventListener('input', function() {
const length = globeInput.value.length;
globeInput.style.boxShadow = `0 0 ${5 + length * 2}px rgba(255, 215, 0, 0.8)`;
globeInput.style.background = `rgba(255, 250, 240, ${0.5 + length * 0.05})`;
});
}
updateGlobeEffect();
</script>
<style>
.radiant-globe-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.radiant-globe {
border: none;
padding: 15px 30px;
border-radius: 50px;
font-size: 18px;
transition: background 0.3s, box-shadow 0.3s;
outline: none;
width: 200px;
text-align: center;
box-shadow: 0 0 8px rgba(255, 215, 0, 0.8);
background: rgba(255, 250, 240, 0.5);
}
.radiant-globe:focus {
box-shadow: 0 0 15px rgba(255, 165, 0, 0.9);
background: rgba(255, 240, 200, 0.7);
}
</style>
Thank you for reading this article.
Comments
No comments yet. Be the first to comment!