What is the best way to adjust the size of an SVG logo in a React Gatsby project

https://i.sstatic.net/m7Dek.png

I've been struggling to resize this logo without increasing the size of the container. I'm at a loss for what to do next. When I try to modify the logo svg file with inline styling

 <svg viewBox="0 0 493.19 493.19" width='400'height='400'>
, it gives me the result shown above. All I want is to enlarge the logo without affecting the other components positioned below it. If sharing the layout code would make it easier to assist me, please let me know. Thank you!

  const data: QueryResult = useStaticQuery(query)

  return (
    <ThemeProvider theme={theme}>
      <>
        <GlobalStyles />
        <Wrapper>
          <SideBarInner bg={color} as="aside" p={[6, 6, 8]}>
            <Flex
              flexWrap="nowrap"
              flexDirection={['row', 'row', 'row', 'column']}
              alignItems={['center', 'center', 'center', 'flex-start']}
              justifyContent="space-between"
            >
              <Box width={['3rem', '4rem', '5rem', '8rem']}>
                <Link to="/" aria-label="LekoArts, Back to Home">
                  <Logo />
                </Link>
              </Box>
              <Nav
                color={color}
                mt={[0, 0, 0, 10]}
                as="nav"
                flexWrap="nowrap"
                flexDirection={['row', 'row', 'row', 'column']}
                alignItems="flex-start"
              >
                {data.navigation.nodes.map((item) => (
                  <PartialNavLink to={item.link} key={item.name}>
                    {item.name}
                  </PartialNavLink>
                ))}
              </Nav>
            </Flex>
          </SideBarInner>
          <Main>{children}</Main>
          <Footer color={color}>
            <Box p={[6, 6, 8]} fontSize={0}>
              little things with love <a href="https://www.lekoarts.de/en">LekoArts</a>.<br />
              <a href="https://github.com/LekoArts/gatsby-starter-portfolio-jodie">Source</a>.
            </Box>
          </Footer>
        </Wrapper>
      </>
    </ThemeProvider>
  )
}

export default Layout

Answer №1

Adjusting the SVG viewBox dimensions does not alter the actual size of the paths within the SVG graphic; rather, it modifies the size of the overall SVG container that houses these paths, resulting in additional white space.

To address this issue, consider reverting the changes to the viewBox attribute and removing any inline width and height styles. By doing so, the SVG element should dynamically adjust its size to fit within the designated container.

Answer №2

To ensure the correct sizing of your SVG code, try setting the width to 100% within the svg code. Then, you can use CSS to control the size by adjusting the width of the container that holds the svg.

For example:

.custom-container {
    width: 5rem;
}

EDIT: If you need guidance on implementing the CSS, you can refer to a helpful explanation of various implementations here. Using inline styling is one of the simplest methods.

<Logo style="width: 5rem;" />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

When employing the map function to populate a table, ensure that 2 rows are returned

In my code, I have implemented a Semantic-UI-React Table in the following manner: <Table striped celled fixed textAlign="center"> <Table.Body>{activeLogList}</Table.Body> </Table> To populate this table with my Log List, I use ...

Inserting multiple rows in MySql using JavaScript through a URL pathUnique: "

Hello there! I am currently attempting to send an array of objects to my MySql Database via an API endpoint. Below is the code snippet from my API: app.get("/orderdetails/add", (req, res) => { const { item__, Qty_Ordered, Unit_Price, ...

How can I retrieve a child method in the Vue.js 3 Options API?

When working with Vue.js 3 using the Options API, I encountered a challenge in accessing a child component's method. Although there is a solution provided for Vue.js 2 and Vue.js 3 with Composition API on How to access to a child method from the paren ...

Exploring the focus() method of refs in Vue 3

I'm struggling to comprehend why my straightforward test case keeps failing. As I delve into the world of testing in Vue, I've created a simple test where the element.focus() is triggered onMount(() => /* see implementation ...

Is it possible to animate share buttons using Framer Motion but staggering siblings?

I have a Share Icon that looks like: I'm looking to display the first 5 icons, with the 5th icon being the share icon. The remaining icons should appear below the share icon and expand to the right when someone taps or hovers over it (either tap or h ...

Alignment Problem with Select Menu (HTML/CSS)

I have previously inquired about a similar issue, but this time I am using different code. My goal is to develop a dropdown menu. Within the main list, there are specific elements that contain dropdown lists (News and Team). These items seem to be shifted ...

Decoding JSON information within WordPress

I'm looking to retrieve Instagram user account information such as followers, following, and account name. The endpoint I have been using is: https://www.instagram.com/{username}/?__a=1 By including the specific username in the endpoint URL, I am a ...

If the modal PopUp is closed without canceling row editing in a gridview inside it, the PopUp will not reopen

In my project, I have a gridview that allows in-place editing and is placed within a modal popup extender. While everything works smoothly, the issue arises when I try to edit a row and input data that doesn't meet the validation rules set by RegularE ...

Having trouble getting the plugin to function properly in Webpack when using React JS

I recently developed a React JS application and decided to use the terser-webpack-plugin for code compression and removing console.log() statements. However, I am facing issues as it does not seem to be functioning as expected. Here is how I installed the ...

Conceal a certain element in development using CSS

Is there a way to hide the footer section from my webpage without affecting the rest of the content? For example, using something like: "div class="poweredby" display: none", but I'm unsure of the correct method... Here is the spe ...

Guide on integrating Mongoose/Mongodb with node.js for passport authentication

As I venture into building my initial full stack node.js application, I aim to implement passport for authentication. A tutorial I encountered for passport involved storing user information in a users array. Here's a snippet from the passport-config. ...

What is the best way to transfer information from a client to a server using Meteor?

I am currently developing an application and have encountered an issue. I have an HTML page located in the './public' folder. Within the './public/js' directory, there is a script that gathers data after a form is submitted on this page ...

Dealing with errors in external URLs with AngularJS: A guide to intercepting errors in $resource or $http services

I have set up a separate server for my angularjs app, which is different from my grunt server. This external server runs on Apache and uses PHP to serve JSON data. I want to be able to catch any potential server errors, ranging from "server down" to "404". ...

Utilizing the checked or clicked property of radio buttons for my specific scenario

Hello everyone, I am currently working on Rails 3.2.13 and have implemented the following script in my view file. Whenever a user selects 'Other' as their owner type, I need the div with id=group_user_id to open and save the operation at the end. ...

What is causing the disappearance of the images and animation when a class is added to the final column?

My goal is to create a continuous animation loop with 6 images. However, when I try to add the 6th image and include the "poster" class, none of the images appear on the screen. If I skip adding the "poster" class to the 6th image, the first 5 images disp ...

Sending selected checkboxes as part of a request to the server can automate the process of downloading a file

I am looking for a way to send checked checkboxes in a server request (for example, in Django) and then automatically download a file in response. Are there any common solutions, advice, or simple examples? I have heard that Ajax and JS (jQuery) do not off ...

Determining whether the user has a token stored in the localStorage is a crucial step in my

I have an app that calls a Login API and returns a token. I store the token in localStorage, but I'm unsure how to validate if the user has a token to log in. What steps can I take to solve this? Below is my login page where I store the token in loca ...

Display a div when two select elements contain particular values

I have a scenario where I am working with two dropdown menus: <select name="name_1" id="name_1"> <option value="Y" selected="selected">Option 1</option> <option value="N">Option 2</option> </select> <select ...

AngularJs is able to assess an expression in the presence of numerous conditions

Can a function be triggered only when two conditions are met simultaneously? <a id="Send" ng-click="(model.condition1 and model.condition2) || doSomething()"></a> ...

Netlify failing to build CRA due to inability to locate local module for method?

I encountered an issue with deploying my site on Netlify. The problem arises when it fails to locate local modules. Below is the log: 12:54:43 AM: Build ready to start 12:54:45 AM: build-image version: 09c2cdcdf242cf2f57c9ee0fcad9d298fad9ad41 12:54:45 AM: ...