How can I change my formgroup so it looks similar as seen on the picture?

This is the FormGroup code:
<UFormGroup required class="p-4 border-b" label="Title" description="Enter Article Title">
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-full"/>
</UFormGroup>
<UFormGroup required class="p-4 border-b" label="Title" description="Enter Article Title">
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-full"/>
</UFormGroup>
And this is the desired look
<UFormGroup class="px-4 pb-4 border-b">
<div id="wrapper" class="w-full flex flex-row">
<div id="label" class="w-2/4">
<h1 class="text-xl text-gray-800 font-bold">Description</h1>
<p class="text-sm text-gray-500">Enter Article Description</p>
</div>
<UTextarea placeholder="Enter Article Description" size="md" v-model="formData.description" class="w-2/4"/>
</div>
</UFormGroup>
<UFormGroup class="px-4 pb-4 border-b">
<div id="wrapper" class="w-full flex flex-row">
<div id="label" class="w-2/4">
<h1 class="text-xl text-gray-800 font-bold">Description</h1>
<p class="text-sm text-gray-500">Enter Article Description</p>
</div>
<UTextarea placeholder="Enter Article Description" size="md" v-model="formData.description" class="w-2/4"/>
</div>
</UFormGroup>
No description
8 Replies
kapa.ai
kapa.ai3w ago
Hi @Just Simeon. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To modify your FormGroup to look similar to the desired layout, you can make use of the slots provided by the UFormGroup component and customize its appearance. Here's how you can adjust your code:
<UFormGroup required class="px-4 pb-4 border-b">
<template #label>
<div class="w-2/4">
<h1 class="text-xl text-gray-800 font-bold">Title</h1>
<p class="text-sm text-gray-500">Enter Article Title</p>
</div>
</template>
<div class="w-full flex flex-row">
<div class="w-2/4"></div>
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-2/4"/>
</div>
</UFormGroup>
<UFormGroup required class="px-4 pb-4 border-b">
<template #label>
<div class="w-2/4">
<h1 class="text-xl text-gray-800 font-bold">Title</h1>
<p class="text-sm text-gray-500">Enter Article Title</p>
</div>
</template>
<div class="w-full flex flex-row">
<div class="w-2/4"></div>
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-2/4"/>
</div>
</UFormGroup>
Let's break down the changes: 1. We've adjusted the classes on the UFormGroup to match the desired layout: class="px-4 pb-4 border-b". 2. We're using the #label slot to customize the label area FormGroup Slots (https://ui.nuxt.com/components/form-group#slots). This allows us to create the left side of the layout with the title and description. 3. We've wrapped the input in a flex container to align it with the label area. 4. The input now has a class="w-2/4" to make it take up half the width, matching the label area. 5. We've removed the label and description props from the UFormGroup as we're now handling those manually in the #label slot. This structure should give you a layout very similar to the desired look you provided. The label and description will be on the left side, taking up half the width, and the input field will be on the right side, also taking up half the width. Remember, you can further customize the appearance using the ui prop or by adjusting the classes to fine-tune the layout and styling UI Prop (https://ui.nuxt.com/getting-started/theming#ui-prop). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@294593079812292609> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Just Simeon
Just SimeonOP3w ago
@kapa.ai yea no, it looks worse now
No description
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I apologize for the unsatisfactory result. Without seeing the actual output or knowing more specifics about what aspects look worse, it's challenging to provide a precise solution. However, I understand that the previous suggestion didn't meet your expectations. Let's try a different approach. Could you please provide more details about what specific aspects of the layout or styling are not working as you'd like? For example: 1. Is the alignment off? 2. Are the sizes of the elements not what you expected? 3. Is there an issue with the spacing or padding? 4. Are the colors or font styles not matching your desired look? With more specific information about what's not working, I can offer a more tailored solution to help you achieve the layout you're aiming for. Additionally, if you have any screenshots or more detailed descriptions of what you're trying to achieve, that would be very helpful in guiding the solution. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@294593079812292609> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Just Simeon
Just SimeonOP3w ago
@kapa.ai the description is not properly displayed, its 1 word per row. The actual input is now stuck at the bottom right of the formgroup as supposed to the right center. the required * is not next to the title but rather below the description, that looks weird.
kapa.ai
kapa.ai3w ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I understand the issues you're facing with the FormGroup layout. Let's address each problem one by one: 1. Description display issue: To fix the description text wrapping, we need to ensure it has enough width and proper text wrapping. 2. Input positioning: We'll adjust the flexbox properties to center the input vertically. 3. Required asterisk placement: We'll move the required indicator next to the title. Here's an updated version of the code that should address these issues:
<UFormGroup required class="px-4 pb-4 border-b">
<div class="flex items-center">
<div class="w-1/2 pr-4">
<div class="flex items-center">
<h1 class="text-xl text-gray-800 font-bold">Title</h1>
<span class="text-red-500 ml-1">*</span>
</div>
<p class="text-sm text-gray-500 mt-1 whitespace-normal">Enter Article Title</p>
</div>
<div class="w-1/2">
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-full"/>
</div>
</div>
</UFormGroup>
<UFormGroup required class="px-4 pb-4 border-b">
<div class="flex items-center">
<div class="w-1/2 pr-4">
<div class="flex items-center">
<h1 class="text-xl text-gray-800 font-bold">Title</h1>
<span class="text-red-500 ml-1">*</span>
</div>
<p class="text-sm text-gray-500 mt-1 whitespace-normal">Enter Article Title</p>
</div>
<div class="w-1/2">
<UInput placeholder="Enter Article Title" size="md" v-model="formData.title" class="w-full"/>
</div>
</div>
</UFormGroup>
Let's break down the changes: 1. We've wrapped the entire content in a flex container with items-center to vertically align the left and right sides. 2. The left side (label and description) now has w-1/2 pr-4 to give it half the width and some right padding. 3. We've added whitespace-normal to the description paragraph to ensure proper text wrapping. 4. The required asterisk is now placed next to the title using a span element. 5. The input is wrapped in a div with w-1/2 to take up the right half of the container. This layout should address the issues you mentioned: - The description should now wrap properly and not display one word per row. - The input should be vertically centered on the right side of the FormGroup. - The required asterisk (*) should appear next to the title. If you're still experiencing issues or if this doesn't quite match your desired layout, please provide more details or a screenshot of what you're aiming for, and I'll be happy to refine the solution further. FormGroup Documentation (https://ui.nuxt.com/components/form-group) ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3w ago
<@294593079812292609> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
Want results from more Discord servers?
Add your server