Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      IBM launches new integration to help unify AI security and governance

      June 18, 2025

      Meet Accessible UX Research, A Brand-New Smashing Book

      June 18, 2025

      Modernizing your approach to governance, risk and compliance

      June 18, 2025

      ScyllaDB X Cloud’s autoscaling capabilities meet the needs of unpredictable workloads in real time

      June 17, 2025

      RAIDOU Remastered: The Mystery of the Soulless Army Review (PC) – A well-done action-RPG remaster that makes me hopeful for more revivals of classic Atlus titles

      June 18, 2025

      With Windows 10 circling the drain, Windows 11 sees a long-overdue surge

      June 18, 2025

      This PC app boosts FPS in any game on any GPU for only $7 — and it just got a major update

      June 18, 2025

      Sam Altman claims Meta is trying to poach OpenAI staffers with $100 million bonuses, but “none of our best people have decided to take them up on that”

      June 18, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Why Inclusive Design Solutions Are important for Accessibility

      June 18, 2025
      Recent

      Why Inclusive Design Solutions Are important for Accessibility

      June 18, 2025

      Microsoft Copilot for Power Platform

      June 18, 2025

      Integrate Coveo Atomic CLI-Based Hosted Search Page into Adobe Experience Manager (AEM)

      June 18, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      RAIDOU Remastered: The Mystery of the Soulless Army Review (PC) – A well-done action-RPG remaster that makes me hopeful for more revivals of classic Atlus titles

      June 18, 2025
      Recent

      RAIDOU Remastered: The Mystery of the Soulless Army Review (PC) – A well-done action-RPG remaster that makes me hopeful for more revivals of classic Atlus titles

      June 18, 2025

      With Windows 10 circling the drain, Windows 11 sees a long-overdue surge

      June 18, 2025

      This PC app boosts FPS in any game on any GPU for only $7 — and it just got a major update

      June 18, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CSS shape() Commands

    CSS shape() Commands

    May 2, 2025

    The CSS shape() function recently gained support in both Chromium and WebKit browsers. It’s a way of drawing complex shapes when clipping elements with the clip-path property. We’ve had the ability to draw basic shapes for years — think circle, ellipse(), and polygon() — but no “easy” way to draw more complex shapes.

    Well, that’s not entirely true. It’s true there was no “easy” way to draw shapes, but we’ve had the path() function for some time, which we can use to draw shapes using SVG commands directly in the function’s arguments. This is an example of an SVG path pulled straight from WebKit’s blog post linked above:

    <svg viewBox="0 0 150 100" xmlns="http://www.w3.org/2000/svg">
      <path fill="black" d="M0 0 L 100 0 L 150 50 L 100 100 L 0 100 Q 50 50 0 0 z " />
    </svg>

    Which means we can yank those <path> coordinates and drop them into the path() function in CSS when clipping a shape out of an element:

    .clipped {
      clip-path: path("M0 0 L 100 0 L 150 50 L 100 100 L 0 100 Q 50 50 0 0 z");
    }

    I totally understand what all of those letters and numbers are doing. Just kidding, I’d have to read up on that somewhere, like Myriam Frisano’s more recent “Useful Recipes For Writing Vectors By Hand” article. There’s a steep learning curve to all that, and not everyone — including me — is going down that nerdy, albeit interesting, road. Writing SVG by hand is a niche specialty, not something you’d expect the average front-ender to know. I doubt I’m alone in saying I’d rather draw those vectors in something like Figma first, export the SVG code, and copy-paste the resulting paths where I need them.

    The shape() function is designed to be more, let’s say, CSS-y. We get new commands that tell the browser where to draw lines, arcs, and curves, just like path(), but we get to use plain English and native CSS units rather than unreadable letters and coordinates. That opens us up to even using CSS calc()-ulations in our drawings!

    Here’s a fairly simple drawing I made from a couple of elements. You’ll want to view the demo in either Chrome 135+ or Safari 18.4+ to see what’s up.

    CodePen Embed Fallback

    So, instead of all those wonky coordinates we saw in path(), we get new terminology. This post is really me trying to wrap my head around what those new terms are and how they’re used.

    In short, you start by telling shape() where the starting point should be when drawing. For example, we can say “from top left” using directional keywords to set the origin at the top-left corner of the element. We can also use CSS units to set that position, so “from 0 0” works as well. Once we establish that starting point, we get a set of commands we can use for drawing lines, arcs, and curves.

    I figured a table would help.

    Command What it means Usage Examples
    line A line that is drawn using a coordinate pair The by keyword sets a coordinate pair used to determine the length of the line. line by -2px 3px
    vline Vertical line The to keyword indicates where the line should end, based on the current starting point.

    The by keyword sets a coordinate pair used to determine the length of the line.

    vline to 50px
    hline Horizontal line The to keyword indicates where the line should end, based on the current starting point.

    The by keyword sets a coordinate pair used to determine the length of the line.

    hline to 95%
    arc An arc (oh, really?!). An elliptical one, that is, sort of like the rounded edges of a heart shape. The to keyword indicates where the arc should end.

    The with keyword sets a pair of coordinates that tells the arc how far right and down the arc should slope.

    The of keyword specifies the size of the ellipse that the arc is taken from. The first value provides the horizontal radius of the ellipse, and the second provides the vertical radius. I’m a little unclear on this one, even after playing with it.

    arc to 10% 50% of 1%
    curve A curved line The to keyword indicates where the curved line should end.

    The with keyword sets “control points” that affect the shape of the curve, making it deep or shallow.

    curve to 0% 100% with 50% 0%
    smooth Adds a smooth Bézier curve command to the list of path data commands The to keyword indicates where the curve should end.

    The by keyword sets a coordinate pair used to determine the length of the curve.

    The with keyword specifies control points for the curve.

    I have yet to see any examples of this in the wild, but let me know if you do, and I can add it here.

    The spec is dense, as you might expect with a lot of moving pieces like this. Again, these are just my notes, but let me know if there’s additional nuance you think would be handy to include in the table.

    Oh, another fun thing: you can adjust the shape() on hover/focus. The only thing is that I was unable to transition or animate it, at least in the current implementation.

    CodePen Embed Fallback

    CSS shape() Commands originally published on CSS-Tricks, which is part of the DigitalOcean family. You should get the newsletter.

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLinux Candy: ricksay – Rick and Morty quotes of the day
    Next Article Ferron is a web server optimized for speed, security and efficiency

    Related Posts

    News & Updates

    RAIDOU Remastered: The Mystery of the Soulless Army Review (PC) – A well-done action-RPG remaster that makes me hopeful for more revivals of classic Atlus titles

    June 18, 2025
    News & Updates

    With Windows 10 circling the drain, Windows 11 sees a long-overdue surge

    June 18, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    A Comprehensive Guide to LLM Routing: Tools and Frameworks

    Machine Learning

    Over 20 Malicious Crypto Wallet Apps Found on Google Play, CRIL Warns

    Development

    Microsoft releases updated HLK and VHLK for Windows 11 24H2 & Server 2025

    Operating Systems

    CVE-2025-43921 – cPanel WHM GNU Mailman Unauthenticated List Creation Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    CVE-2025-46786 – Zoom Workplace Apps XML External Entity (XXE) Injection Vulnerability

    May 14, 2025

    CVE ID : CVE-2025-46786

    Published : May 14, 2025, 6:15 p.m. | 51 minutes ago

    Description : Improper neutralization of special elements in some Zoom Workplace Apps may allow an authenticated user to impact app integrity via network access.

    Severity: 4.3 | MEDIUM

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    How to Install Jenkins on Kubernetes Cluster Step-by-Step

    June 15, 2025

    Salesforce OmniStudio Flaws Expose Encrypted Data

    June 10, 2025

    Bitrix24 Review: How Good is the All-in-One CRM?

    May 17, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.