New feature: Material UI Chip Input with floating input label

I installed material-ui-chip-input to implement tags in an input field. I wanted a label alongside it, so I utilized the default Material UI label for consistency with other inputs. However, the input doesn't shrink as expected when clicked on by the user.

Below is my code snippet and a screenshot of the design. Any assistance would be greatly appreciated. Thank you in advance!

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

<div className={`${styles.input_range} form_design`}>
    <label className={styles.character_limit}>(13/30)</label>
    <label class="MuiFormLabel-root MuiInputLabel-root MuiInputLabel-formControl MuiInputLabel-animated" data-shrink="false" for="standard-basic" id="standard-basic-label">Title</label>
    <ChipInput
    defaultValue={['Science', 'Arts']}
    // onChange={(chips) => handleChange(chips)}
    />
</div>

Answer №1

Make sure to replace your custom label with the ChipInput property label="Title" for the desired outcome.

Additionally, I have included a helperText property for the second label. By assigning a className, you can further customize the component using CSS.

<div className={`${styles.input_range} form_design`}>
    <ChipInput
    className="customChipInput"
    label="Title"
    helperText="(13/30)"
    defaultValue={['Science', 'Arts']}
    // onChange={(chips) => handleChange(chips)}
    />
</div>

You can enhance the appearance by adding the following CSS:

.customChipInput p {
  width: fit-content;
  position: absolute;
  bottom: 30px;
  right: 0;
}

Feel free to view the code snippet here

To explore more about the component properties, visit the link here

https://i.stack.imgur.com/2NN2p.png

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

The React component designed to consistently render video frames onto a canvas is unfortunately incompatible with iOS devices

I'm facing an issue with my code snippet that is supposed to draw video frames on a canvas every 42 milliseconds. It's working perfectly on all platforms and browsers except for iOS. The video frames seem unable to be drawn on canvas in any brows ...

React Native Elements Overlay: Troubleshooting Webview Functionality

I've implemented react-native-element for the components in my app and I'm using Overlay to display modals. However, I encountered an issue with displaying a WebView within one of the modals. export const Modal = ({ visible, showCrossBtn, se ...

In React Js, I have noticed that when I incorporate a Select field, it only works when the value is an integer and not a string. It seems

Library version "material-ui": "^1.0.0-beta.35" react version: "react": "^16.2.0" Currently Functional: <MenuItem value={1}>Text</MenuItem> <MenuItem value={2}>Integer</MenuItem> <MenuItem value={3}>Inline</MenuItem> N ...

What is the best way to immediately update react useState?

Whenever I invoke the fetchProducts function, I require the productPage state to be updated before proceeding to the next line of code as it's needed for subsequent operations. The issue lies in the fact that the state is only updated after the funct ...

Reveal Visual Content upon Hovering

Is there a way to show an image only when the mouse hovers over it? Additionally, can we underline the adjacent text at the same time? If the mouse moves away from the image, I'd like it to hide again and revert the text back to its original state. T ...

Ways to decrease the height of accordion summary in Material-UI and React

I've been working on creating an accordion using the "@mui/material" library, but I'm encountering difficulties in fixing the height of AccordionSummary. I have tried various solutions listed below, but none of them seem to work for me: Setting ...

Switching from single to multiSelect in Material UI Autocomplete depending on a certain condition

Encountering an issue with Material UI Autocomplete where changing from single select to multiple select based on a condition throws the error Cannot read property 'length' of null Check out this CodeSandbox example: https://codesandbox.io/s/mat ...

Can the recently introduced renderToNodeStream be utilized?

Recently, I upgraded my project to use server side rendering with React 16. The current technology stack includes: Node 8.4 Express React 16 Redux Webpack Pug for static content (such as header and footer) I am curious if it is possible to implement the ...

Eliminate borders surrounding WordPress text widgets

Looking for some help with removing the border around the widgets on my home page. Despite my theme's CSS removing borders universally, I thought targeting specific Div text widgets (such as text-7, text-6) would do the trick. While I can control the ...

I noticed that the useEffect hook is running three times in my basic NextJS app (version 13.4 or higher) with the app router. What could be causing this

My NextJS app in version 13.4+ seems to be running the useEffect hook three times, even though it is supposed to only run once with an empty dependency array. I was under the impression that it should behave like componentDidMount and execute only once wh ...

The use of "next/font" necessitates the presence of SWC, even when Babel is incorporated, as a result of a customized Babel

Encountering an error while attempting to run my Nextjs project with styled components. This is my .babelrc file: { "plugins": [ [ "babel-plugin-styled-components", { "ssr": true, "displ ...

Stagnation in the progress of React installation

I've tried installing npx create-react-app project and npm init react-app project multiple times, but each time the installation process gets stuck at a certain point and does not progress further. This seems to be an issue with the installation that ...

Tips for rearranging a span following an image?

Looking for a solution to rearrange a span element after an image within automatically generated HTML. Sample HTML: <span>closed</span> <img alt="Click to reset" src="xxx" class=""> Currently, the span appears before the img in the cod ...

Tips on aligning a v-btn alongside v-expansion-panels on the same row

Struggling with aligning my layout. Trying to get a single set of v-expansion-panels and a v-btn in the same row, both visually centered within a card. I managed to almost achieve it in this codepen: https://codepen.io/anzuj/pen/PoPPbdw with the following ...

Set up Amplify to utilize a pre-existing Cognito token for authentication

I have a project where I am utilizing Amplify (JS) Storage to upload files to an S3 bucket. The setup is already completed and working smoothly, but now I need to add an extra layer of security by implementing a policy that restricts file uploads to only ...

What could be causing the error that keeps popping up when I attempt to create a Next app?

Trying to master Next.js has been a bit of a challenge for me. Every time I attempt to create an app, a network error pops up saying the request to https registry.npmjs.org/create-react-app failed due to connect ETIMEDOUT. It suggests that I may have a p ...

How can the vertical scroll bar position be reset in Material-Table when pagination is activated?

Whenever I scroll up or down in my Material-Table, and then switch pages, the vertical scroll bar doesn't reset to the top of the table. Instead, it stays where it was before changing the page, causing confusion for users. The only mention of scroll ...

Upgrade from version 4 to version 5 causes issues with the appearance of standard Material-UI components

Transitioning from v4 to v5 has presented me with various issues that seem to be inconsistent. On the Login page, the <Button> component displays correctly. However, once logged in, the <Button> components appear without any MUI styling, such ...

problem encountered while attempting to transmit data to multer in React

I was attempting to upload an image to the backend using Multer. I have reviewed the backend code multiple times and it appears to be correct. Could there be an issue with my front-end code? Here is a POST code snippet: const response = await fetch(' ...

What crucial element is absent in my Express application that is preventing the successful rendering of React SSR?

I can't seem to crack this problem. I'm feeling a bit overwhelmed trying to figure out what's causing the issue. Here's how my project is structured: I have an Express server built with Express Generator A React app created using CRA ...