Qu'est-ce que Generateur de fonction CSS shape() ?
The CSS shape() function is a new shape primitive that unifies and extends the legacy shape functions (polygon(), circle(), ellipse(), path(), inset(), rect()). Unlike earlier shape functions, shape() supports percentage coordinates that are relative to the element's own dimensions, not just pixel coordinates. It also supports reference box keywords (margin-box, padding-box, content-box, border-box) that define the coordinate system, and shapes created with shape() can be interpolated for smooth CSS transitions and animations between different shape types.
Réponse rapide
CSS shape() creates non-rectangular shapes for clip-path and shape-outside with percentage coordinates relative to element size, reference box support, and animatable transitions between polygon, circle, ellipse, path, and rect types. Chrome 139+, Safari 18.2+ (Baseline 2026). Always include a fallback shape function for unsupported browsers.
Limites
- Browser support is limited to Chrome 139+, Edge 139+, and Safari 18.2+ as of mid-2026. Firefox does not support shape() yet, and older browsers ignore the entire declaration. A fallback shape function is required for broad compatibility.
- shape() polygon requires explicit units (px or %) on each coordinate value, unlike the legacy polygon() function which accepts bare numbers. This makes the syntax more verbose and error-prone when migrating from existing polygon() declarations.
- Not all shape types interpolate cleanly with each other. While shape() supports cross-type animation, transitions between vastly different geometries (for example, rect to a complex path) may produce unexpected intermediate shapes. Test animations visually before deploying.
Comment utiliser cet outil
- Select the shape type: polygon (list of coordinate pairs), circle (center and radius), ellipse (center plus x-radius and y-radius), path (SVG path data), or rect (top, right, bottom, left with optional rounding).
- Choose the reference box: margin-box, padding-box, content-box, or border-box. The reference box determines the coordinate system for percentage-based coordinates.
- Configure the shape coordinates. For polygons, add coordinate point pairs. For circles and ellipses, set the center position and radius values. Enable animation-friendly mode to ensure shape values use compatible syntax for CSS transitions.
- Copy the generated shape() CSS and apply it to the clip-path or shape-outside property. Add a fallback using the legacy shape functions for browsers that do not support shape() yet.
A quoi il sert
- Create non-rectangular image masks for hero sections and featured content cards using clip-path with shape() polygon and percentage coordinates.
- Wrap text around circular or elliptical images using shape-outside with shape() circle and padding-box reference for consistent spacing.
- Animate between a polygon and a circle shape on hover or scroll using CSS transitions, since shape() supports interpolation between different shape types.