Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ant design: modify border-radius for Input component

I have the following ant design search input component:

 <Search
  size="large"
  placeholder="Search..."
  className="dashboardSearch"
  />

I am trying to modify the border radius to give it a circular shape but everything i try in my css file doesnt work.

css file:

.dashboardSearch {
    width: 300px;
    border-radius: 25px;

}

.ant-input-search {
    width: 300px;
    border-radius: 25px;
}

is there anyway to modify the border radius of the search input component? usually when I modify the ant design class name directly it works. but in this case it doesn't. Is there another way that I am missing?

like image 901
john Avatar asked Aug 04 '19 03:08

john


People also ask

How do you add styles to antd components?

If you import styles by specifying the style option of babel-plugin-import, change it from 'css' to true , which will import the less version of antd. If you import styles from 'antd/dist/antd. css' , change it to antd/dist/antd.

How do you use the grid in ant design?

From the stack to the horizontal arrangement. You can create a basic grid system by using a single set of Row and Col grid assembly, all of the columns (Col) must be placed in Row . You can use the gutter property of Row as grid spacing, we recommend set it to (16 + 8n) px ( n stands for natural number).


Video Answer


1 Answers

You need to target .antd-input class inside the Input.Search.

For example with CSS-in-JS:

const RoundSearch = styled(Input.Search)`
  .ant-input {
    border-radius: 25px;
  }
`;

export default function App() {
  return (
    <FlexBox>
      <RoundSearch />
    </FlexBox>
  );
}

Or in your case:

.dashboardSearch {
  .ant-input {
    border-radius: 25px;
  }
}

Edit Q-57343486-StyleInputSearch

like image 146
Dennis Vash Avatar answered Oct 22 '22 05:10

Dennis Vash