Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

215
Views
How do I change my InputBase's placeholder font/color in React?

I tried to do it with useStyles. I have the following code:

// imports above here

const useStyles = makeStyles((theme) => ({
  placeholder: {
    color: 'black',
    fontSize: 'large',
  },
}));


export default function Chatbox() {
  const classes = useStyles;
  const {currentChannel} = React.useContext(globalContext);

  const [placeholder, setPlaceholder] =
    React.useState('Message ' + Object.values({currentChannel})[0]);

  useEffect(() => {
    setPlaceholder('Message ' + Object.values({currentChannel})[0]);
  }, [currentChannel]);


  return (
    <Paper
      component="form"
      sx={{
        p: '4px 8px', display: 'flex', alignItems: 'center',
        flexShrink: 1, width: 1670}}>
      <InputBase
        sx={{ml: 4, flex: 1}}
        placeholder={placeholder}
        inputProps={{'aria-label': 'chatbox'}}
        className= {classes.placeholder}
      />
      <Divider sx={{height: 48, m: 0.5}} orientation="vertical" />
      <IconButton sx={{p: '25px'}} aria-label="send">
        <SendIcon />
      </IconButton>
    </Paper>
  );
}

However, my placeholder size and color never change even after changing the values in useStyles.. It stays grey and the same size.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You forgot to call the function.

// imports above here

const useStyles = makeStyles((theme) => ({
  placeholder: {
    color: 'black',
    fontSize: 'large',
  },
}));


export default function Chatbox() {
  const classes = useStyles();      // <--------- Here 
  const {currentChannel} = React.useContext(globalContext);

  const [placeholder, setPlaceholder] =
    React.useState('Message ' + Object.values({currentChannel})[0]);

  useEffect(() => {
    setPlaceholder('Message ' + Object.values({currentChannel})[0]);
  }, [currentChannel]);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!