SVG filters
Keep the same Svg.Filter graph on Web and Native. The renderer depends on
which filter elements the graph needs.
| Graph | Web | React Native |
|---|---|---|
| Core: blur, colour matrix, offset, flood, composite, blend, merge, drop shadow | Browser SVG | react-native-svg; no Skia required |
| Extended: morphology, displacement, convolution, channel transfers, noise, tiles, image inputs, lighting | Browser SVG | Hozo’s Skia filter path; install @shopify/react-native-skia |
Build and attach a graph
Section titled “Build and attach a graph”Put the filter in Svg.Defs, name intermediate outputs with result, and
refer to them with in or in2. Apply the filter using url(#id).
Give each filter a distinct ID when multiple instances share a Web page.
import { Svg } from '@hozo/svg'export function SoftBadge({ filterId }: { filterId: string }) { return ( <Svg width={80} height={80} viewBox="0 0 80 80" accessibilityLabel="Blurred badge"> <Svg.Defs> <Svg.Filter id={filterId} x="-25%" y="-25%" width="150%" height="150%"> <Svg.FeColorMatrix in="SourceGraphic" type="saturate" values="0" result="gray" /> <Svg.FeGaussianBlur in="gray" stdDeviation="2" /> </Svg.Filter> </Svg.Defs> <Svg.Circle cx={40} cy={40} r={20} fill="#2563eb" filter={`url(#${filterId})`} /> </Svg> )}The region bounds limit the area available to the effect. If an edge of the blur or shadow is cut off, enlarge the filter’s region before changing its strength. A larger region can cost more to render, so expand it only as far as the effect needs.
Use an extended filter on Native
Section titled “Use an extended filter on Native”For example, replacing the two effects above with a morphology operation expands the coloured pixels rather than blurring them:
<Svg.FeMorphology in="SourceGraphic" operator="dilate" radius="2" />The browser handles this directly. For React Native, keep react-native-svg
installed and add Skia to the app (Expo):
npx expo install @shopify/react-native-skiaHozo chooses the Skia path automatically for SVGs with extended elements.
Without Skia, the SVG falls back to react-native-svg and Hozo warns.
Do not rely on the extended effect in that fallback. If it must work without
Skia, use a core-filter approximation or a pre-rendered asset.
Check platform differences
Section titled “Check platform differences”- On the core Native path,
FeBlendsupportsnormal,multiply,screen,darken, andlighten. KeepFeGaussianBlur.edgeModeat the defaultnone; the other values are not implemented in that path. - Hozo corrects Android core blur for density and root
viewBoxscaling. Android still uses a single radius for both axes and caps that radius at 25 bitmap pixels. This is not exact browser raster parity. - The Conformance Matrix checks the exposed API and routing or compilation of the graph. It does not establish pixel equivalence. Compare the actual effect on your target platforms when the rendering matters.
Try the SVG filter studio for working specimens. For the full core/extended inventory, see the package reference.