-
Notifications
You must be signed in to change notification settings - Fork 688
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css-borders-4] Use cases for corner-shape
#6980
Comments
ANGLE EXAMPLES
https://www.zelda.com/ (footer links)
https://thewitcher.com/en/witcher3
https://www.leagueoflegends.com/en-us/
button{
corners: angle 11px 0;
transition: corners .25s;
}
button:hover{
corners: angle 0 0;
}
ANGLE AND NOTCHhttps://playvalorant.com/en-us/
|
It seems to me that almost all of these examples are bevel corners and various types of polygons/parallelograms/trapezoids etc. None of them are using Furthermore, I feel that using This allows creating "bevel" corners like this: --corner-size: 10px;
element-shape: polygon(
var(--corner-size) 0, calc(100% - var(--corner-size)) 0, /* top */
100% var(--corner-size), 100% calc(100% - var(--corner-size)), /* right */
calc(100% - var(--corner-size)) 100%, var(--corner-size) 100%, /* bottom */
0 calc(100% - var(--corner-size))
); …which is admittedly a lot more involved than From what I remember the tricky bit of implementing/specifying all of these is border geometry, especially when top, right, bottom, left borders all have different thicknesses and/or colors. Given that the use cases that actually require a non-uniform border AND a custom shape are practically nil, I wonder if there's an easy way to get this out of the way, even if the visual result in these rare cases is suboptimal. @fantasai would love your input. |
Anothe useful, though not much used because of difficuilty of implementation, corner shape seems to be the "squircle" or "superellipse" shape, or at least its approximation with Bezier curves. Searching for "CSS squircles" shows quite a lot of attempts to solve it with existing tools (mostly complex clip-path or even Houdini). |
That is yet another argument for |
@SelenIT wrote:
In #6296 I suggested
|
Did run across a 4 corner notched example. Something like https://www.zelda.com/links-awakening/ Very much agree that corner-shape for polygons gets messy. Once you start using the slash syntax to give corners different widths and heights things get hard to follow. And even more when you throw a 100% corner height or width in it kinda ceases to be a corner anymore. Didn't @tabatkins post something on twitter not too long ago about an idea for a CSS syntax for creating SVGs? What makes the polygon creating an issue is all the |
Maybe |
They already are independent in everything but |
found the tweet I mentioned above:
Also was just thinking that when |
still not having a whole lot of luck finding scoop or notch examples. If anyone knows of places where these are common please don't hesitate to drop links or point in the right direction. https://diamondpearl.pokemon.com/en-us/
https://nierautomata.square-enix-games.com/en-us/home/
https://www.guerrilla-games.com/play/horizon
https://www.animal-crossing.com/new-horizons/
https://unite.pokemon.com/en-us/
|
Because someone is likely to ask... No you couldn't really do the twitter NFT shape with corner-shape. The general hexagon shape yes, but you'd need an SVG path to get all the detail. corner-shape: bevel (angle)
border-radius: 25% / 50%
width: 400px
height: 300px |
@LeaVerou wrote:
I love the idea of being able to define individual shapes for elements. Though I believe this goes far beyond the use case of specifying a different shape for a corner defined via Sebastian |
I think the problem with finding scoop and notch examples is that there isn't an easy way to hack them. Using 'border-image' requires an image, and trying to do it a vector image (SVG) is complicated and slow-rendering and sometimes inconsistent. I think if 'corner-shape' existed and could do scoops, we'd see a lot more designs with scoops, as there are in print design. |
If something is doable with an image, that's annoying but not enough to deter people from using it in production. People have been using images for effects they cannot do in CSS for decades. |
I'm not keen on having yet another way to create polygons and paths. I'd rather we found a way to unite shape-outside and clip-path, and apply borders and box-shadows and filters to those shapes (maybe a keyword to shape-outside or clip-path that does that, with only border-top going all the way around the shape, and maybe with an extra control for how pointy or rounded the miters are). |
I agree with Brad's comments above - we already have these concepts in CSS, we shouldn't be trying to reinvent an (arbitrarily-shaped) wheel. Someone mentioned
So, personally, I'd go with something more like a single
As this builds on the conceptual models of |
VScode
discord.com
https://www.smashbros.com/en_US/
https://www.starwars.com/news/brian-volk-weiss-interview
https://festival.gamesforchange.org/
opera GX new tab page
|
some observations from this so far:
|
Maybe the start of a more complete paint API polyfill for corner-shape? Currently supports only angled corners but with the option for the full 8 value border-radius/corner-size syntax (ie |
I think you are probably right. As one of the authors of that spec, it is disappointing, but I also don't use it much. With raster images:
SVG can be used, but that adds different complications. It can be super complicated, depending on what you are trying to achieve, and it can render slowly, and there are browser differences.
I think I tend to be in that camp, especially with raster images. |
Another scooped corners example https://playwonderlands.2k.com/
|
Don't really know how many more angle/bevel examples we really need but thought this was notable because its a rather big named site: https://www.marcustheatres.com/
|
Update on the paint API polyfill for corner-shape I was making: it now mostly works! Supports angle, notch, scoop, square and round shapes. No % support yet for sizes. Demo page can be found here (chromium only for now): https://jsnkuhn.github.io/corner-shape/ |
So this is a little bit different but still use case related: note the styling difference between the promo image from a blog post (on the top) and the way the same thing is styled on the website (on the bottom) This is just speculation on my part but i'm guessing they would be more similar if it would be easier to do: |
example of a potential |
https://dragonquest.square-enix-games.com/games/en-us/infinity-strash/ another basic |
The header and the back/forward buttons are notched corners. The tabs and their associated content area have scooped corners. Some with borders, some with (potentially) borders and box-shadows, and some with no borders at all. |
Something a little different. Have an anecdote from a person that asked a question on Kevin Powell's discord about how to create a fairly straight forward angled corner element with a border and a transparent background. The community offered a few different options for the design (the usual mask-image or clip-path stuff) but when the poster realized how much work it was going to be they decided to change the design of the page instead of dealing with the angled corners. If |
So the above design seems to be a new trend. Finally ran into a site using this live. Playstation's 2023 Wrap-Up. Don't have a Playstation account so can't login and have a look at how they are doing it but maybe someone else can? |
SVG image: The cards use shared url in M0.039,0 C0.018,0,0,0.012,0,0.028 V0.972 C0,0.988,0.018,1,0.039,1 H0.961 C0.982,1,1,0.988,1,0.972 V0.028 C1,0.012,0.982,0,0.961,0 H0.039 M0.026,0.12 V0.953 C0.026,0.969,0.044,0.981,0.066,0.981 H0.549 C0.568,0.981,0.582,0.971,0.582,0.958 V0.926 C0.582,0.913,0.597,0.903,0.615,0.903 H0.938 C0.956,0.903,0.97,0.892,0.97,0.88 V0.044 C0.97,0.028,0.953,0.016,0.931,0.016 H0.493 C0.475,0.016,0.461,0.026,0.461,0.039 V0.074 C0.461,0.086,0.446,0.097,0.428,0.097 H0.059 C0.041,0.097,0.026,0.107,0.026,0.12 Edit: Will note the website doesn't support browser font-scaling. (WCAG 1.4.4) |
Another live example of the inverted border radius thing from https://www.cutthecode.com/ This one is done with an |
Lots of angled examples here. Shouldn't be surprising considering Def Leppard's logo. Does a good job of showing off some of the issues you can run into using pseudo elements to add on the angles to a rectangle. Some of the angled corners look like they fit perfectly and some have 1px (or possibly less) spaces between the elements and the pseudos. |
just a codepen demo (https://codepen.io/Azametzin/pen/PoVjRZy) but similar to some previous |
All web apps built with Ionic or Framework 7 currently released in the iOS App Store are unable to imitate squircle/smooth corners found throughout iOS. This has already been mentioned, but I wanted to highlight those frameworks because plenty of web-based apps are actively using them. Having the ability to smooth corners would make those apps feel more native on iOS. |
https://www.nintendo.com/jp/switch/bdgea/index.html A 2 for 1 page: 1: Scooped cornered headings accomplished with 2: Angled cornered element with a solid border. This was done with a |
This is an |
Or something like Sebastian |
This is a GIANT chart of the Warhammer timeline. They use different shapes to denote media type. Currently implemented in SVG as you'd expect but some of the hover styling is slightly off. |
Google's Material Design 3 has a "cut corner" shape option (this is the same as corner-shape's "angle" option): https://m3.material.io/styles/shape/shape-scale-tokens#bbf4c8e4-88ed-42a2-be5f-2f776465f6bc |
I believe that the new |
@noamr I'm using your demo website (https://noamr.github.io/squircle-testbed) and trying to achieve the shape I want. I set the border-radius to |
I think the
|
It seems that all of the basic corner shapes (angle/bevel, notch, scoop, squircle) are covered but the rounded variants of those basic shapes would still need addressing. a few examples example:
|
Thanks! Perhaps if some of them become common we can have special basic shapes for them, but let's start with letting people go crazy with Note that neither |
The point of this thread is to collect designs from existing websites where
corner-shape
would make web developers jobs easier. Current live sites are preferred to demos.Some related links:
Similar thread from 2013 when the idea of
corner-shape
was first introduced (note: most use case example from this thread now are dead or link to pages that have been redesigned):https://lists.w3.org/Archives/Public/www-style/2013Mar/0505.html
Lea's original svg corner-shape demo:
https://projects.verou.me/corner-shape/
The working draft spec in it's current state:
https://drafts.csswg.org/css-backgrounds-4/#corner-shaping
corner shape related paintAPI worklets:
--corner-shape
allows per corner shaping including mixing of shapes (angle/scoop/notch/round)--corner-size
options for fullborder-radius
8 value slash syntax (allows for each corner to have different width and height)Example Index:
Angle/Bevel
https://www.marvel.com/ (#6980 (comment))
https://www.zelda.com/ (#6980 (comment))
https://thewitcher.com/en/witcher3 (#6980 (comment))
https://www.leagueoflegends.com/en-us/ (#6980 (comment))
https://nierautomata.square-enix-games.com/en-us/home/ (#6980 (comment))
https://www.guerrilla-games.com/play/horizon (#6980 (comment))
https://www.animal-crossing.com/new-horizons/ (#6980 (comment))
https://squoosh.app/ (#6980 (comment))
https://www.polygon.com/ (#6980 (comment))
https://www.starwars.com/news/brian-volk-weiss-interview (#6980 (comment))
https://festival.gamesforchange.org/ (#6980 (comment))
opera GX new tab page (#6980 (comment))
https://elderscrolls.bethesda.net/en/skyrim (#6980 (comment))
https://www.videogameschronicle.com/ (#6980 (comment))
https://www.monsterhunter.com/rise/us/ (#6980 (comment))
Angle/Bevel extended
https://www.xbox.com/en-US (#6980 (comment))
https://metroid.nintendo.com/ (#6980 (comment))
discord.com (#6980 (comment))
https://www.smashbros.com/en_US/ (#6980 (comment))
https://www.marcustheatres.com/ (#6980 (comment))
Scoop
https://diamondpearl.pokemon.com/en-us/ (#6980 (comment))
https://playwonderlands.2k.com/ (#6980 (comment))
Community Theater site using simple background for a ticket shape
(#6980 (comment))
https://www.residentevil.com/village/us/ (#6980 (comment))
https://bethesda.net/en/game/starfield/media?type=video (#6980 (comment))
Scoop extended
Notch
https://www.zelda.com/links-awakening/ (#6980 (comment))
Notch extended
Squircle
Squircle extended
discord.com? (#6980 (comment))
Mixed shapes
https://playvalorant.com/en-us/ (#6980 (comment))
https://unite.pokemon.com/en-us/ (#6980 (comment))
VScode (#6980 (comment))
The text was updated successfully, but these errors were encountered: