Breaking-border on input fields

Does anybody have any resources for me to look at, or any examples on how to actually do a breaking-border label for a input field? Similar to how material ui's input fields look. There's a few strategies I know of, which is using clip path (and calculating the width of the label) or using psuedo elements with a background color on the label itself. Both have their own issues, the clip-path strategy is just plain ugly and annoying, and the background color strategy will only work on one background color. Is there a better way to go about it? Thanks!
No description
5 Replies
alireza9810
alireza981015mo ago
https://youtu.be/nJzKi6oIvBA?si=-8nMvh32Qi6nXlun do you mean something like this?
Tailwind Labs
YouTube
Floating Labels with Tailwind CSS
In this video, you'll learn how to pull off that cool "floating labels" effect using just Tailwind CSS utility classes. We'll use a bunch of new features added in Tailwind CSS v2.2, including the new placeholder-shown variants and the peer sibling selector variant. Source code: https://play.tailwindcss.com/cwqORB8ee7 Tailwind CSS v2.2: https:...
alireza9810
alireza981015mo ago
also for breaking border you could set a background of the bg color with some padding for label to achieve that.
Xaohs
XaohsOP15mo ago
Yeah but that requires me to set a bg-color on the label itself Which is very annoying to do, as i'd have to pass that as props, or do some weird inherit stuff which will force be to set the parent a bg-color
alireza9810
alireza981015mo ago
i don't know the needs and structure of your project. but maybe css variables could help
Xaohs
XaohsOP15mo ago
Hmm, to anyone stumbling across this thread, I have found a different way to handle it, using fieldset and legend, and applying the borders to that, instead of the input field itself, this way the legend can break up the border from the fieldset. It seems MUI also works this way
Want results from more Discord servers?
Add your server