More

    Assume Exterior the Field: Creating Shapes with CSS clip-path & shape-outside | by Ananya Kittane Yogananda | Samsung Web Builders | Aug, 2025

    on

    |

    views

    and

    comments

    Press enter or click on to view picture in full measurement

    Images of Samsung phone on unsplash.com , hexagon and image clipped into the shape of hexagon
    Photos of Samsung telephone on unsplash.com hexagon and picture clipped into the form of hexagon

    Most net layouts reside inside neat rectangles — however what if you happen to might suppose exterior the field?

    With CSS properties like clip-path and shape-outside, you may rework your photos and content material into dazzling shapes that break away from the field ( actually!)

    On this submit, we’ll discover how we might:

    1. Clip photos into circles, stars, and polygons
    2. Add interactive animations to those shapes
    3. Wrap textual content organically round customized shapes to create beautiful, editorial model UIs

    For all of those examples, you possibly can use any editor to comply with alongside — I’ve used CodePen for my demos.

    At its core, clip-path permits you to outline a visual area of a component. It doesn’t have an effect on how textual content flows or how readers interpret content material — it’s purely visible masking. We might consider clip-path as akin to reducing a form (circle, triangle and many others.,) from an oblong piece of paper.

    shape-outside however, lets us outline a form — which can be non-rectangular and let’s textual content stream across the floated factor’s form. It helps us create magazine-style layouts.

    Utilization

    Use clip-path while you need to create customized shapes or masks for a component.

    Use shape-outside while you need to wrap textual content or different content material round a customized form.

    Use each clip-path and shape-outside collectively while you need to clip a component to at least one form whereas wrapping content material round one other form. That is helpful for superior designs the place the factor and its surrounding content material work together in distinctive methods.

    Syntax Overview

    /* clip-path */
    .factor

    /* shape-outside */
    .factor

    /* Utilizing shape-outside & clip-path collectively */
    .factor {
    clip-path: ;
    shape-outside: ;
    float: left;
    }

    Instance values:

    Form-function: circle(), ellipse(), polygon(), inset()

    Geometry Field: content-box, padding-box, border-box

    For extra detailed overview of the syntax, check out shape-outside and clip-path’s MDN articles.

    The Easiest Form: Circles

    Let’s start with the commonest and best form — a circle. That is excellent for avatars and logos.

    Clipping an Picture right into a Circle

    .circle {
    width: 200px;
    peak: 200px;
    object-fit: cowl;
    clip-path: circle(50%);
    }
    Image of a girl clipped into the shape of a circle
    Clipped round picture of a lady(Picture by thesilvafocus on unsplash.com)

    Spice issues up: Creating completely different polygons

    As soon as we’ve mastered circles, we are able to create extra attention-grabbing polygons like triangles, diamonds, trapeziums utilizing clip-path() and polygon().


    Triangle



    "Diamond

    Diamond



    "Trapezium

    Trapezium


    physique {
    font-family: sans-serif;
    background: #fafafa;
    padding: 2rem;
    text-align: middle;
    }

    .gallery {
    show: flex;
    hole: 2rem;
    justify-content: middle;
    flex-wrap: wrap;
    }

    .merchandise {
    show: flex;
    flex-direction: column;
    align-items: middle;
    width: 200px;
    }

    img {
    width: 200px;
    peak: 200px;
    object-fit: cowl;
    border: 3px strong #ccc;
    transition: clip-path 0.3s ease;
    }

    /* Shapes utilizing clip-path */

    .triangle {
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    }

    .diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }

    .trapezium {
    clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
    }

    Image of nature clipped into the shape of triangle, diamond and trapezium
    Picture of nature by robertlukeman on unsplash.com clipped into completely different shapes

    Word: When making use of clip-path to pictures, utilizing object-fit: cowl ensures they fill the form correctly with out distortion.

    Need to create your personal shapes?

    Attempt clippy- CSS clip-path maker. It helps create visually artful shapes, from easy triangles to extra intricate polygons.

    Stage up: Including interactivity

    Up to now we’ve used clip-path to statically crop photos into completely different shapes. However CSS lets us go one step additional — we are able to animate shapes utilizing transitions!

    Instance: Hovering over a round picture that morphs right into a diamond This could be a delicate however participating visible cue, nice for issues like testimonials, profile photos and many others.



    src="https://photos.unsplash.com/photo-1541515929569-1771522cbaa9?w=500&auto=format&match=crop&q=60&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8N3x8Z2lybCUyMHdpdGglMjBjYW1lcmF8ZW58MHx8MHx8fDApercent3D"
    alt="Morphing Picture"
    class="clip-circle-to-diamond" />

    .clip-animate-container {
    text-align: middle;
    margin: 2rem 0;
    }

    .image-wrapper{
    place: relative;
    width:219px;
    peak:219px;
    }

    .clip-circle-to-diamond {
    width: 200px;
    peak: 200px;
    object-fit: cowl;
    transition: clip-path 0.5s ease-in-out;
    clip-path: circle(50%);
    border: 4px strong #ccc;
    border-radius: 12px;
    pointer-events: none;
    }

    /* Morph right into a diamond on hover */
    .image-wrapper:hover .clip-circle-to-diamond {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    }

    The .image-wrapper CSS class is added to stop flickering brought on by form adjustments — an essential consideration for accessibility and for customers delicate to speedy visible shifts.

    You possibly can take a look on the output and the code right here — Hover demo.

    I’ve additionally created a extra superior animation instance. You could possibly use this –animation demo — clip-path() to view and mess around.

    Journal-style layouts with shape-outside

    For the longest time, net content material has lived inside inflexible rectangles. Due to fashionable CSS, we now have a device that brings editorial magnificence and fluidity to net layouts. Meet shape-outside!

    Let’s see how we might float a round picture and have the paragraph naturally stream round it — making a format you’d often count on from {a magazine} or a publication.



    These photos float aspect by aspect, and the textual content wraps round each to simulate a multi-column format of headshots in an editorial characteristic. These photos float aspect by aspect, and the textual content wraps round each to simulate a multi-column format of headshots in an editorial characteristic. How wonderful is the potential to simply use CSS to create such fluid layouts. The net is not only a rectangle anymore. And nope, we dont want simply figma or different design instruments to do any of those fancy stuff! These photos float aspect by aspect, and the textual content wraps round each to simulate a multi-column format of headshots in an editorial characteristic. These photos float aspect by aspect, and the textual content wraps round each to simulate a multi-column format of headshots in an editorial characteristic. How wonderful is the potential to simply use CSS to create such fluid layouts. The net is not only a rectangle anymore. And nope, we dont want simply figma or different design instruments to do any of those fancy stuff. The net is not only a rectangle anymore. And nope, we dont want simply figma or different design instruments to do any of those fancy stuff.
    The net is not only a rectangle anymore. And nope, we dont want simply figma or different design instruments to do any of those fancy stuff.

    .circle-small {
    float: left;
    width: 120px;
    peak: 120px;
    shape-outside: circle(50%);
    clip-path: circle(50%);
    object-fit: cowl;
    margin: 0 1rem 1rem 0;
    }

    /* Media question for smaller screens (e.g., cellular) */
    @media (max-width: 768px) {
    .circle-small {
    width: 30%;
    margin: 0 0.5rem 0.5rem 0;
    }
    p {
    font-size: 14px;
    }
    }

    Demo of how text wraps around an image in a circular fashion
    Demo of how textual content wraps round a picture

    Browser Assist

    Each shape-outside (besides ) and clip-path are broadly supported throughout all of the browsers.

    Conclusion

    We learnt how we might break the grid and make the net look attention-grabbing with simply easy CSS. I hope this text conjures up you to check out new stuff and make fancy-looking UIs exterior of the common field!

    Share this
    Tags

    Must-read

    PNY Launches CS3250 Gen 5 NVMe SSD with Speeds As much as 14,900 MB/s

    PNY has introduced the launch of its newest high-performance solid-state drivethe CS3250 M.2 NVMe PCIe Gen 5 x4 SSD. The brand new mannequin builds...
    spot_img

    Recent articles

    More like this

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here