1e41f4b71Sopenharmony_ci# svg 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **\<svg>** component is a basic container. It can be used as the root node of an SVG document or be used to nest an SVG fragment into an SVG document. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci> **NOTE** 7e41f4b71Sopenharmony_ci> - This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci> 9e41f4b71Sopenharmony_ci> - The width and height must be defined for the **\<svg>** parent component or **\<svg>** component. Otherwise, the component is not drawn. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## Required Permissions 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciNone 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## Child Components 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ciThe following are supported: [\<svg>](js-components-svg.md), [\<rect>](js-components-svg-rect.md), [\<circle>](js-components-svg-circle.md), [\<ellipse>](js-components-svg-ellipse.md), [\<path>](js-components-svg-path.md), [\<line](js-components-svg-line.md), [\<polygon>](js-components-svg-polygon.md), [\<polyline>](js-components-svg-polyline.md), [\<text>](js-components-svg-text.md), [\<animate>](js-components-svg-animate.md), and [\<animateTransform>](js-components-svg-animatetransform.md). 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci## Attributes 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ciThe [universal attributes](js-components-svg-common-attributes.md) and the attributes listed below are supported. The configured universal attributes are passed to the child components. 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci| Name | Type | Default Value | Mandatory | Description | 26e41f4b71Sopenharmony_ci| ------- | ---------------------------------- | ------------- | --------- | ---------------------------------------- | 27e41f4b71Sopenharmony_ci| id | string | - | No | Unique ID of the component. | 28e41f4b71Sopenharmony_ci| width | <length>\|<percentage> | - | No | Component width. | 29e41f4b71Sopenharmony_ci| height | <length>\|<percentage> | - | No | Component height. | 30e41f4b71Sopenharmony_ci| x | <length>\|<percentage> | - | No | X-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. | 31e41f4b71Sopenharmony_ci| y | <length>\|<percentage> | | No | Y-coordinate of the current **\<svg>** component. The settings do not work for the root **\<svg>** node. | 32e41f4b71Sopenharmony_ci| viewBox | string | - | No | View box of the current **\<svg>** component. The supported format is \<number number number number>. The four parameters indicate **min-x**, **min-y**, **width**, and **height**, respectively. The width and height of the view box are different from those of the **\<svg>** component. The view box is scaled in center-aligned mode. | 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci## Example 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci```html 38e41f4b71Sopenharmony_ci<!-- xxx.hml --> 39e41f4b71Sopenharmony_ci<div class="container"> 40e41f4b71Sopenharmony_ci <svg width="400" height="400"> 41e41f4b71Sopenharmony_ci <svg width="200" height="200" viewBox="0 0 100 100"> 42e41f4b71Sopenharmony_ci <rect x="10" y="10" width="80" height="80" fill="#00FF00"></rect> 43e41f4b71Sopenharmony_ci </svg> 44e41f4b71Sopenharmony_ci <rect x="10" y="10" width="80" height="80" fill="red" ></rect> 45e41f4b71Sopenharmony_ci <svg x="0" y="0" width="200" height="200" viewBox="0 0 200 200"> 46e41f4b71Sopenharmony_ci <rect x="10" y="10" width="80" height="80" fill="red"></rect> 47e41f4b71Sopenharmony_ci </svg> 48e41f4b71Sopenharmony_ci <svg x="0" y="0" width="200" height="200" viewBox="0 0 400 400"> 49e41f4b71Sopenharmony_ci <rect x="10" y="10" width="80" height="80" fill="blue"></rect> 50e41f4b71Sopenharmony_ci </svg> 51e41f4b71Sopenharmony_ci </svg> 52e41f4b71Sopenharmony_ci</div> 53e41f4b71Sopenharmony_ci``` 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci 57