Vuetify: Utilizing condition-based breakpoints

Here is the layout that I am working with:

https://i.stack.imgur.com/qlm60.png

This is the code snippet that I have implemented:

<template>
    <v-card>
        <v-card-text>
            <v-container grid-list-xl fluid class="py-0 mb-5">
                <v-layout row wrap>
                    <v-flex xs12 lg8>
                        <v-container class="pa-0 mb-5">
                            <v-layout>
                                <v-flex xs12 class="py-0">
                                    <v-subheader class="pa-0 mb-3">
                                        Title 1
                                    </v-subheader>
                                </v-flex>
                            </v-layout>
                            <v-layout wrap>
                                <v-flex xs12 md4 lg6>
                                    Content 1
                                </v-flex>
                                <v-flex xs12 md8 lg6>
                                    Content 2
                                </v-flex>
                            </v-layout>
                        </v-container>
                    </v-flex>
                    <v-flex xs12 lg4>
                        <v-container class="pa-0">
                            <v-layout row>
                                <v-flex xs12 class="py-0">
                                    <v-subheader class="pa-0 mb-3">
                                        Title 2
                                    </v-subheader>
                                </v-flex>
                            </v-layout>
                            <v-layout row>
                                <v-flex xs12>
                                    Content 3
                                </v-flex>
                            </v-layout>
                        </v-container>
                    </v-flex>
                </v-layout>
            </v-container>
        </v-card-text>
    </v-card>
</template>

The current setup works well for my needs. However, I encountered an issue where "Content 2" might not always exist. When it doesn't exist, this undesired outcome occurs:

https://i.stack.imgur.com/60HgH.png

What I actually want to achieve is depicted in this image:

https://i.stack.imgur.com/9Kjlv.png

Is there a way to control the breakpoints so that I can switch between lg4 and lg8 based on the presence of "Content 2"? One solution I thought of was to create two v-flex sections, one with lg4 and one with lg8, and display only one depending on the existence of "Content 2". However, I want to avoid repeating code, and creating a new component is not feasible for me.

My ideal scenario would involve something like this:

<v-flex v-if="content2Exists" xs12 lg8>
<v-flex v-else xs12 lg4>
    Blabla...
</v-flex>

Answer №1

In my opinion, it might be beneficial to experiment with incorporating a condition within the lg(x) property like so:

  <v-flex  xs12 :lg4="!content2Exists" :lg8="content2Exists">

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

What is the process for building a JSON-formatted dictionary?

My intention is to structure my data in a way that can be accessed using a specific key. The current arrangement looks like this: const dict = []; dict.push({"student": "Brian", "id":"01", "grade":& ...

Need help setting up a time-based query in Laravel? Here's how to schedule it!

I am currently using the following query to update a status value. public function updateStatus(Request $request) { $customer = Customer::findOrFail($request->user_id); $customer->status = $request->status; $customer->new_customer_s ...

Basic Vue application displays only empty screens (using webpack-dev-server)

I recently started developing my first Vue app, and everything was going smoothly until I added some routes. Now, I'm facing an issue where no output is displayed in the browser. Previously, I could see a simple static string before implementing routi ...

Vue custom directive - encountering undefined object properties

I have a unique Vue directive that I created to display or hide an element based on a specific role. Vue.directive('role', (el, binding, vnode ) => { const modifiers = binding.modifiers const roles = vnode.context.$store.state.roles; if ...

React Apollo Error - When using refetchQueries, data does not re-render in one component but does so in another. Surprisingly, it works when the refetchQueries is in the same

Within my application, there is a Main Component that displays a list of todos. Additionally, the Sidebar Component showcases various products as illustrated below ...

Unexpected behavior encountered in Rails app with unobtrusive JavaScript

I'm facing an issue with my link_to setup. Here's what I have: <%= link_to "Load More", comments_feed_path(@post.id), :id => 'my-link', :remote => true %> In my application.js file, I have the following code: $( document ...

"How to Develop an Eraser Tool Using EaselJs - Exploring Further Possibilities

Currently, I am working on creating a Bitmap eraser on easelJS. I feel like I've made significant progress towards achieving this goal, but I'm still a bit unsure of the next steps... Here is a demo of my progress so far: http://jsfiddle.net/bor ...

Trouble selecting options in hierarchical data

I've been attempting to run this sample code for selecting an option from a select element with hierarchical data, but it seems to be having some issues. $scope.options = [ { id: 1, info: { label: "Item 1" } }, { id: 2, info: { label: ...

Creating an executable JAR for your Next.js application: A step-by-step guide

Is there a way to ensure that my Next.js file can run seamlessly on any computer without the need for reinstallation of all modules? In my folder, nextjs-node, I have the following subfolders: components lib public node_modules page style package.json I ...

What is the best way to navigate to the bottom of a page when new data is added?

I've created a chat feature in my Ionic app, but the issue is that when a user receives a new message while being on the chat screen, the view doesn't automatically scroll down to show the new message. The user has to manually scroll down to see ...

In Javascript, check if an item exists by comparing it to null

I am working with a dropdown list that can be used for various types of data. Some of the data includes an isActive flag (a BOOLEAN) while others do not. When the flag is absent, I would like to display the dropdown item in black. However, if the flag exis ...

Emphasize the selected page number

My React application contains page numbers, but currently when a page number is clicked, it does not get highlighted or displayed in a different color. The className "text-success" can be added to make the text green. How can I dynamically add this class t ...

Is there a necessity for me to utilize the nodejs https module if my hosting service offers TLS Certificates?

As a first-time application deployer for real-life use, I am utilizing the Stripe API for payment handling. My plan is to deploy the Node.js application on Render host, which promises fully managed and free TLS certificates for all hosted applications an ...

Ways to enable a user to edit a calculated property in VueJS?

I am currently working on collecting data that the user can download, and I am facing a challenge in determining the best way to handle the filename. To ensure the default filename is dynamic and based on the current date, I believe creating a computed pro ...

Resolved plugin issue through CSS adjustments

Take a look at this template 1) After referring to the above template, I developed a fixed plugin using JavaScript. 2) Clicking the icon will trigger the opening of a card. 3) Within the card, I designed a form using mdb bootstrap. Everything seems to ...

Tips for effectively managing loading and partial states during the execution of a GraphQL query with ApolloClient

I am currently developing a backend application that collects data from GraphQL endpoints using ApolloClient: const client = new ApolloClient({ uri: uri, link: new HttpLink({ uri: uri, fetch }), cache: new InMemoryCache({ addTypename: f ...

Issue Encountered During Eclipse Vue.js Codemix Installation

When attempting to install Vue.js :: CodeMix from the "Eclipse Marketplace," an error occurred: Cannot complete the installation process because one or more required items could not be found. Software being installed: Vue.js Pack :: CodeMix 1.1.0 (com.ge ...

Is it possible to automatically access the most recent Beta build through package.json and npm?

We are currently working on a project that has a specific dependency requirement for the latest beta build from an npm library. However, there are also -dev builds within the library. For instance, in the "x-library" there might be versions like: "1.2.3- ...

I'm having trouble pinpointing the cause of the never-ending loop in this React code that is using Material UI grid

There seems to be an issue with infinite looping in this code, and I can't figure out the cause, import React, { useEffect, useState } from 'react'; import VideoCardComponent from './VideoCard'; import Grid from '@mui/material ...

Issue in Next.js 13: Byte index exceeds limits when running 'npm run dev' command

When attempting to install Next.js 13.4.12, I utilized the command npx <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="385b4a5d594c5d15565d404c1559484878090b160c1609">[email protected]</a>. The installation process ...