React Navigation Item Toolbar Misplacement

I've been trying to align the navigation item with the logo on the same line within the toolbar, but I'm facing an issue where they keep appearing in different rows. To see the error for yourself, check out the code sandbox here.

This is how I structured my code for the Navigation "Item":

import React from "react";
import styled from "styled-components";

const NavigationItemList = styled.div`
  margin: 0;
  box-sizing: border-box;
  display: flex;
  height: 100%;
  align-items: center;
`;

const NavigationItemA = styled.div`
  color: white;
  text-decoration: none;
  height: 100%;
  padding: 16px 10px;
  border-bottom: 4px solid transparent;
  box-sizing: border-box;
  display: block;

  :hover,
  :active {
    background-color: #8f5C2;
    border-bottom: 4px solid #40a4c8;
    color: white;
  }
`;

const NavigationItem = (props) => {
  return (
    <NavigationItemList active={props.active}>
      <NavigationItemA href={props.link}>{props.children}</NavigationItemA>
    </NavigationItemList>
  );
};

export default NavigationItem;

This is where I defined my "Items":

const NavigationItemsStyled = styled.div`
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  align-items: center;
  height: 100%;
`;

const NavigationItems = (props) => {
  return (
    <NavigationItemsStyled>
      <ul>
        <NavigationItem>Burger Builder</NavigationItem>
        <NavigationItem>Checkout</NavigationItem>
      </ul>
    </NavigationItemsStyled>
  );
};

The toolbar is where I place my Items:

import React from "react";
import styled from "styled-components";
import NavigationItems from "../NavigationItems/NavigationItems";

const ToolbarStyled = styled.div`
  height: 56px;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  margin: 0;
  background-color: #da291c;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  box-sizing: border-box;
  z-index: 90;
  color: white;
`;
const Toolbar = (props) => {
  return (
    <ToolbarStyled>
      <p>Logo</p>
      <nav>
        <NavigationItems />
      </nav>
    </ToolbarStyled>
  );
};

export default Toolbar;

Any assistance on resolving this issue would be greatly appreciated :)

Answer №1

To customize the appearance of the ul list, you can apply styling. For instance:

const CustomStyledUl = styled.ul`
   display: flex;
`;

Then, make use of CustomStyledUl instead of ul

image - https://example.com/image123

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

Creating a dynamic image binding feature in Angular 8

I am working with an object array that requires me to dynamically add an image icon based on the type of credit card. Typescript file icon: any; savedCreditCard = [ { cardExpiryDateFormat: "05/xx", cardNumberLast: "00xx", cardId: "x ...

The HTML content retrieved through an ajax service call may appear distorted momentarily until the JavaScript and CSS styles are fully applied

When making a service call using ajax and loading an HTML content on my page, the content includes text, external script calls, and CSS. However, upon loading, the HTML appears distorted for a few seconds before the JS and CSS are applied. Is there a sol ...

Locate each document in MongoDB that pertains to a time period of

I have been trying to fetch data for the past n days. For instance, I am interested in retrieving data from the last 3 days. However, after following a solution I found on StackOverflow, I am only able to retrieve one document instead of all the documents. ...

A guide on utilizing AngularJS to extract data from a webpage

I'm attempting to transfer the information from a specific page on my website and paste it into a file. I know how to post a sample text stored in a variable from Angular and save it in a file in the backend using Node Express, so writing a file isn&a ...

Why is my Feed2JS RSS feed functional locally but not operational after deployment on GitHub Pages?

I've been using feedtojs.org to display my Medium blog posts on my GitHub Pages website. Strangely enough, it works perfectly fine on my local server but not on the actual domain. The RSS feed is valid. Here's how it appears on my local server: ...

The width and height properties in the element's style are not functioning as expected

let divElement = document.createElement("div"); divElement.style.width = 400; divElement.style.height = 400; divElement.style.backgroundColor = "red"; // num : 1 divElement.innerText = "Hello World "; // num : 2 document.body.append(divElement); // Af ...

Could you please display the Material UI Menu as a <nav> element, and render its children as <a> tags?

My Material UI Menu is currently rendered as a default structure of <div> > <ul> <li>. I am trying to customize it to be structured as <div> <nav> <a>. I have successfully changed the MenuItem components to <a> ...

React documentation - GitHub markdown documents that utilize a unique table format

When examining a React docs markdown file (used to generate the corresponding docs html pages), you will notice a table of values at the top in the .md file. The markdown syntax used to create this table is non-standard: --- id: hello-world title: Hello W ...

A guide on displaying containers with jQuery and CSS

Looking to create a smiley survey using only Front-End technologies. Once a radio button is selected, the associated content should appear for comments. Currently, I have set up my CSS with display: none. I attempted to implement this functionality using ...

Setting references to child components with VueRouter in Vue

I've written the following code snippet in my main.js file for my Vue web application: const routes = { name: "Main", path: "/main", redirect: "/main/home", component: MainComponent, children: [ { path: &quo ...

Angular's scope allows for the application of CSS classes exclusively to the first div element

Every 2 seconds, a JavaScript function is being called that updates a specific div on the view when a certain condition is met. <div id="ball_{{ballIndex}}">{{ball}}</div> This is controlled by the ng controller. var myCounter = 0; ...

What sets apart a post API call from form submission using the post method?

Is it possible to call the payment gateway from Node.js using a POST API call? I understand that traditionally the payment gateway is called through form submission with the method set as post, which redirects to a new page. However, if I use a POST API ...

I am facing difficulties when trying to map the data using react js/axios

After removing the map function from the code, I encountered an error stating that map is not a function. Can someone please assist me with this issue? Here is the updated code: const [text, setText] = useState([]); const axios = require('axios&ap ...

Arranging data structures in JavaScript: Associative arrays

I'm facing a major issue. My task is to organize an array structured like this: '0' ... '0' ... 'id' => "XXXXX" 'from' ... 'name' => "XXXX" ...

What causes the slight shifting of on-screen elements when the doctype is removed from an HTML document?

During the process of converting from HTML4 to HTML5, I compared my html4 and html5 pages and noticed that removing deprecated elements after the doctype declaration was causing slight movements in on-screen elements. For example, in the code snippet below ...

Updating React component when a property in an array of objects changes by utilizing the useEffect() hook

In my current project, I am creating a React application that resembles Craigslist. In this app, logged-in users can browse through items for sale or services offered. When a user clicks on an item, they are able to view more details and even leave a comm ...

Adjusting the size of div content without changing its dimensions

I'm in search of a solution for resizing the contents within a fixed width and height div. Currently, my div looks like this: <div id="editor_preview" style="width:360px !important; color:gray; ...

Contrast between using " and '

Similar Inquiry: When to Utilize Double or Single Quotes in JavaScript Comparison of single quotes and double quotes in JS As I delve into creating a Node.js Express web application, I've noticed that the tutorial consistently uses ' ins ...

I must pause for a specified period before initializing the subsequent component in React Native

Due to restrictions on my API key, I can only make one request every 5 seconds. Therefore, I need to wait for 5 seconds before making another request for NearbyJobs (with the first request being made for PopularJobs). <ScrollView showsVerticalScrollIndi ...

Utilizing ng-model to bind object values from radio inputs

Dealing with a JSON file: $scope.favoriteThings = [ {nr: 1, text: "Raindrops on roses"}, {nr: 2, text: "Whiskers on kittens"}, {nr: 3, text: "Bright copper kettles"}, {nr: 4, text: "Warm woolen mittens"}, {nr: 5, text: "Brown paper pac ...