Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change v-text-field width in Vuetify?

I placed v-text-field component inside a toolbar however it takes almost all available space. How can I change the width of this text-field to take less space?

<v-toolbar
    dense
  >
    <v-app-bar-nav-icon></v-app-bar-nav-icon>
    <v-toolbar-title>Title</v-toolbar-title>
    <v-text-field
      hide-details
      label="Filled"
      placeholder="Search"
      filled
      rounded
      dense
      single-line
      append-icon="mdi-magnify"
    ></v-text-field>
    <v-btn rounded>Button 1</v-btn>
    <v-btn icon>
      <v-icon></v-icon>
    </v-btn>
    <v-btn icon>
      <v-icon>mdi-dots-vertical</v-icon>
    </v-btn>
  </v-toolbar>
like image 442
Alex T Avatar asked Jan 24 '20 13:01

Alex T


People also ask

How do I change the width on Vuetify?

To make the v-container full width with Vuetify, we just add the fluid prop. to add the fluid prop to the v-container to make it fill the width of the v-content component.

What is V text Vue?

The v-text directive is a Vue. js directive used to update a element's textContent with our data. It is just a nice alternative to Mustache syntax. First, we will create a div element with id as app and let's apply the v-text directive to this element with data as a message.

Does Vuetify support Vue 3?

The current version of Vuetify does not support Vue 3. Support for Vue 3 will come with the release of Vuetify v3 . When creating a new project, please ensure you selected Vue 2 from the Vue CLI prompts, or that you are installing to an existing Vue 2 project.


2 Answers

Since the toolbar is display:flex you could use class="shrink"...

      <v-text-field 
            hide-details 
            label="Filled" 
            placeholder="Search" 
            filled 
            rounded 
            dense 
            single-line 
            append-icon="mdi-magnify" class="shrink">
      </v-text-field>

Demo: https://codeply.com/p/h3Y8u3nK7P

like image 162
Zim Avatar answered Oct 05 '22 03:10

Zim


You can do it by css in scoped style:

<style scoped>
/deep/ .v-text-field{
      width: 400px;
}
</style>

and for detailed information read Vuetify documentation.

like image 30
Sherzod Avatar answered Oct 05 '22 04:10

Sherzod