Disabled input text color on iOS
To swiftly set a custom color for disabled input text on iOS, simply use:
Just overwrite red
with your preferred color. Then rejoice as your CSS magic dramatically transforms your disabled text into your chosen hue.
Diving into the problem
All browsers, including iOS's Safari, color disabled HTML inputs differently due to their unique default styles. This presents a unique puzzler. How can you bring consistency to the user experience across devices and browsers?
Say hello to consistency
Making disabled inputs look uniform across platforms is a cinch with a few lines of CSS:
This smattering of CSS uses the color
property for universal browser coverage, and -webkit-text-fill-color
for Safari on iOS. Remember to test across both mobile and desktop to ensure a similar experience for all users.
Expelling ghosts — transparency and more
How to ditch transparency
Each browser, Safari in particular, can slap a transparency layer on disabled inputs. But you're not about to let Safari ruin your party. You'll use -webkit-text-fill-color
and opacity: 1
to throw the unwanted ghost out of your text party.
Dancing with !important
While !important
can get your styles priority, it's like doing the samba solo at a blues party. Awkward. Use sparingly, but astutely to avoid a messy CSS fiesta.
Accessibility? Checked!
Your cool color choices need to get along with the WCAG 2 contrast ratio guidelines. Consider contrast when strutting your styling genius, to give all users, including those with visual impairments, an equal chance to join the party.
Navigating through edge cases
Handling fickle iOS updates
Because Apple can sneak in changes with each iOS update, stay ahead of the game by keeping an eye on the latest changes in Safari Technology Preview.
Giving a solid base to your styles
Bring consistency across all the quirky browsers by slapping on normalize.css.
Caring for legacy fans
For your users strutting older browsers, introduce fallbacks or conditional stylesheets to give a welcoming hug to legacy systems. You can even consider feature detection. Just don't forget to test!
Non-obvious tips and tricks
Switching themes like clothes
Custom properties say hello. Introduce CSS variables in the mix to switch theme colors without messing with component styles.
JavaScript to the rescue
Ever thought about letting JavaScript come to the CSS party? Sometimes, you might get the urge to swing the text color based on form validation or user actions. Well, JavaScript is your friend here.
Consistency is your best friend
Remember, typography isn't the only VIP at the styling party. Borders, backgrounds, padding...they all need matching outfits. Ensure consistency across every form element, because unity, my friend, is strength.
Was this article helpful?