Develop a Vue component for a fixed sidebar navigation

I am in need of a vertical navigation bar positioned to the left of my app's layout, with the content extending across the right side. However, I am currently facing an issue where the navbar is pushing all the content downwards. How can I resolve this problem?

Below is the template code for my App.vue:

<template>
    <div id="app">
        <v-app>
            <navbar/>
            <v-main>
                <v-container class="main-container">
                    <router-view/>
                </v-container>
            </v-main>
        </v-app>
    </div>
</template>

The navbar component is using Vuetify, specifically the mini variant navbar. Here is how it currently appears:

<template>
    <v-navigation-drawer
        v-model="drawer"
        :mini-variant.sync="mini"
        permanent
    >
        <!-- Navbar content here -->
    </v-navigation-drawer>
</template>

<script lang="ts">
import { Component, Prop, Vue } from 'vue-property-decorator';

@Component<Navbar>({})
export default class Navbar extends Vue {
    private value: string = 'home';
    private drawer: boolean = true;
    private items: Array<Object> = [
        { title: 'Home', icon: 'mdi-home-city' },
        { title: 'My Account', icon: 'mdi-account' },
        { title: 'Users', icon: 'mdi-account-group-outline' }
    ]
    private mini: boolean = true;
}
</script>

However, the current setup is causing the navbar to push down all content as shown in the image below:

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

I want the navbar to be vertical without affecting the positioning of the other content. Essentially, I am looking to implement a side navigation on the left side of my app.

Answer ā„–1

Enclose the navbar and main content within a <v-row>:

<template>
  <div id="app">
    <v-app>
      <v-row>
        <navbar/>
        <v-main>
          <v-container class="main-container">
            <router-view/>
          </v-container>
        </v-main>
      </v-row>
    </v-app>
  </div>
</template>

The v-app component normally has an inner wrapper with CSS property flex-direction: column, which arranges its children vertically. By placing these two child elements within a v-row, you change their layout to be arranged horizontally using flex-direction: row.

Answer ā„–2

It seems there may be some confusion with the concepts here. Placing a v-navigation-drawer inside a navbar component is not quite correct.

In the world of Vuetify, the v-navigation-drawer component is specifically designed for creating Sidebars, which explains why your content appears vertically oriented.

Instead, consider using the v-app-bar component for this purpose. You can refer to the documentation provided here: https://vuetifyjs.com/en/components/app-bars/

Update 1

To set up an app sidebar or navbar correctly, you can utilize the app option within the component as shown below:

  <v-navigation-drawer
    app
  >
  ...
  </v-navigation-drawer>

By following this pattern outlined in the official documentation, you can ensure proper functionality without any issues like content displacement.

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

excess margin running along the left side of each page

When visiting http://tadris3.ir/, one may notice a peculiar space on the left side of all pages. Can anyone assist in resolving this bothersome issue? https://i.sstatic.net/MsX1a.png ...

Error: Authorization requires both data and salt arguments

As a novice in NodeJS, I attempted to create an authentication form using NodeJS + express. The issue I am facing is regarding password validation - specifically, when "confirmpassword" does not match "password", it should return nothing. Despite my effo ...

Using jQuery to assign a specific value to all select boxes

I am facing a challenge where I need to change the values of all select boxes on my page to a specific number. Here is the HTML structure: <select> <option value="-1" <option value="55">ENABLE</option> <option value= ...

Simply interested in extracting the JSON Class specifically, not all of the data

Looking for a way to extract only text from a specific class using $.getJSON and YQL. Currently, it retrieves all data and removes tags. Is there a method to achieve this? function filterData(data){ // remove unwanted elements // no body tags ...

Ensuring button is inactive when API value is zero in Vue

Presented here are a set of buttons that provide live probability odds for a particular event, allowing users to make selections based on the updated data fetched from an API every minute. https://i.stack.imgur.com/uGdld.png If the probability displayed ...

Issue with Sequential Drop Down List Functionality in ASP.Net MVC View Page

I am currently in the process of migrating code from one project to another. Although the code works fine in the original project, it is not functioning properly in the new one. Iā€™m uncertain if something was overlooked on my end. Within this code, ther ...

Top method for creating integration tests in React using Redux and Enzyme

Currently, I am working on setting up integration tests within my application. There are a few API calls that occur both when the component mounts and upon a button click. The response from these API calls is stored in the app's store, which then upd ...

Is the concept of client fanout truly beneficial?

I'm in the process of constructing a community platform on firebase that features timelines and posts similar to those found on Facebook. When a user creates a post, it should automatically appear on the timelines of their followers. Google proposes ...

Tips on how to include a unique style sheet for IE8 in WordPress

Struggling with responsive behavior in IE8, some parts of my Wordpress website at are not displaying correctly due to issues with the @import query. To tackle this problem, I am considering creating a separate style sheet for IE6, 7, and 8 using the follo ...

Styling the file input type in AngularLearn how to customize the

I've come across numerous queries on how to style an input type file, but I'm struggling to implement it in an angular context. So, what is the best way to customize the appearance of an input type file within an angular application? Below is t ...

Using useRef with Typescript/Formik - a practical guide

Encountering Typescript errors while passing a ref property into my custom FieldInput for Formik validation. Specifically, in the function: const handleSubmitForm = ( values: FormValues, helpers: FormikHelpers<FormValues>, ) => { ...

My local requests are being blocked by both Chrome and Firefox

Recently, I've been experimenting with local flash development and trying to inject my swf file into a website served by my test server. To enable loading of local resources in Chrome, I set --disable-web-security. In FireFox, I made the following a ...

Enhance the aesthetic appeal of the imported React component with added style

I need assistance with applying different styles to an imported 'notification' component within my header component. The notification component has its own CSS style, but I want to display it in the header component with unique styling. How can I ...

Is it possible to utilize the package.json "resolutions" field to replace lodash with lodash-es?

Is it possible to use resolutions in a similar manner as dependencies, but with a different package? I'm specifically curious if this can be done with NPM or Yarn. "resolutions": { "lodash": "npm:lodash-es@^14.7.x" ...

Using (javascript:) within Href attributes

Recently, I've noticed some people including "javascript:" in the href attribute of an a tag. My question is: what is the purpose of this? Does it guarantee that clicking on the a tag directs the function of the click to JavaScript for handling, rathe ...

Alternative way to search for child elements within an element without the use of jQuery

I am in the process of creating a universal set of functions to verify the existence of children with specific attributes within a particular element. Unfortunately, I do not have access to jQuery for this task. Here is an example function call: has_chil ...

Having Trouble Scooting Down the Page on Mobile?

Hello there! I'm having a bit of trouble trying to figure out why the scrolling functionality isn't working on my small web app when it reaches the media breakpoint for mobile devices. If you'd like to take a look, here's the link to ...

Upon logging in to the first HTML page, the user will be automatically redirected to the second HTML page while passing values

Is there a way to automatically redirect users to Login2.html when selecting "TEAM" in the dropdown on Login1.html, using the values entered in Login1.html? Similarly, can we redirect them to the Premium page when they select "Premium"? I need a solution u ...

Leveraging Leaflet or any JavaScript library alongside Typescript and webpack for enhanced functionality

Important: Despite extensive searching, I have been unable to find a resolution to my issue. My current endeavor involves developing a map library through the extension of leaflet. However, it appears that I am encountering difficulties with utilizing js ...

Getting the error message "t is not a function. (In 't(i,c)', 't' is an instance of Object)" while attempting to switch from using createStore to configureStore with React Redux Toolkit

I am attempting to switch from react-redux to its alternative react-redux toolkit but I kept encountering this issue t is not a function. (In 't(i,c)', 't' is an instance of Object) and I am unsure of its meaning. Here is the c ...