8 Replies
Hi @mabuse9922. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To define the width of the modal component in Nuxt UI, you can customize the modal's appearance using the theme configuration. Specifically, you can override the modal's slot classes for the content area, which controls its width.
By default, the modal uses classes like
w-[calc(100vw-2rem)] max-w-lg
for the content slot, which sets a maximum width. You can adjust these classes in your Nuxt UI theme configuration to set your desired width. For example:
This will set the modal width to 600px. You can use any valid Tailwind CSS width classes or custom CSS as needed. For more details, see the theme section for the modal component in the documentation: Modal Theme.
If you want to control the width per instance, you can also pass custom classes via the ui
prop on the modal component:
This approach allows you to set the width for a specific modal instance without changing the global theme configuration.
Reference: Modal Theme
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1097891465797050469> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai i have a form with an input field in a modal. How can i move the focus to this input field when the modal opens?
Let me check the knowledge base for you again. One moment! :books:
----------------------
To move the focus to an input field when a modal opens in Nuxt UI, you can use the autofocus feature provided by the input components. For example, the
Reference: UInput Props ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
UInput
component supports the autofocus
prop. When you set autofocus
to true
, the input will automatically receive focus when it is rendered, such as when the modal opens.
Example:
If you need to delay the autofocus (for example, to wait for the modal animation), you can use the autofocusDelay
prop to specify a delay in milliseconds:
This ensures the input field is focused after the modal is fully visible.Reference: UInput Props ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@1097891465797050469> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@kapa.ai How can I pass parameter to a modal, that is open with 'overlay.create(modalComponent)'?
Let me check the knowledge base for you again. One moment! :books:
----------------------
You can pass parameters (props) to a modal that is opened with overlay.create(modalComponent) by using the props option when creating the overlay, or by passing them when calling the open method.
Example 1: Pass props when creating the overlay
Example 2: Pass props when opening the modal
Both approaches will make the prop available in your modal component as a regular prop.
For more details, see the official documentation: useOverlay composable and Migration guide. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
For more details, see the official documentation: useOverlay composable and Migration guide. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
<@1097891465797050469> Kapa.ai is still learning and improving, please let me know how I did by reacting below.