question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SVG width is not set to screen width

See original GitHub issue

hello guys. i want to set screen width for my svg width. this is my simple svg code: <Svg width={width} height={100} viewBox="0 0 400 800"> <Path d="M 800 300 Q 400 350 0 300 L 0 0 L 800 0 L 800 300 Z"/> </Svg> but width is not work correctly. i also try width='100%' but it is not work too.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

5reactions
msandcommented, Oct 13, 2019

Perhaps you want scale to fit? https://www.w3.org/TR/SVG11/coords.html#ViewBoxAttribute And a bit different viewBox value, seems you flipped x and y.

import * as React from 'react';
import { Svg, Path } from 'react-native-svg';

export default () => (
  <Svg
    width="100%"
    height={100}
    viewBox="0 0 800 400"
    preserveAspectRatio="none">
    <Path
      d="M 800 300 Q 400 350 0 300 L 0 0 L 800 0 L 800 300 Z"
      fill="blue"
      stroke="red"
    />
  </Svg>
);

0reactions
AlirezaAzizi145commented, Oct 14, 2019

@msand Thank you very much. it is work

Read more comments on GitHub >

github_iconTop Results From Across the Web

SVG not scaling to screen width - WordPress.org
If I create a large SVG image (large as it width is wider than my screen), upload it and insert it to a...
Read more >
SVG width is not set to screen width · Issue #1145 - GitHub
hello guys. i want to set screen width for my svg width. this is my simple svg code: <Svg width={width} height={100} viewBox="0 0...
Read more >
Width of SVG isn't correct when viewBox is defined
Solution. -For your problem you need to reduce size of viewbox width an height property. But as your image size is ...
Read more >
SVG:Sizing - MozillaWiki
The way SVG requires the 'width' and 'height' attributes to be overridden by xxx does not fit well with mapping into style where...
Read more >
Intrinsic Sizing - SVG
Issue 1: Allow graphics to scale even with fixed size. Tools often output: <svg width="300px" height="723px">...</svg>. Such an SVG won't scale which is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found