File tree Expand file tree Collapse file tree 1 file changed +17
-16
lines changed
docs/src/examples/elements/Input/Variations Expand file tree Collapse file tree 1 file changed +17
-16
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react'
2
- import { Icon , Input } from 'semantic-ui-react'
1
+ import React from 'react' ;
2
+ import { Icon , Input } from 'semantic-ui-react' ;
3
3
4
+ const CustomInput = ( { icon, iconPosition = 'right' , placeholder } ) => (
5
+ < Input icon = { ! ! icon } iconPosition = { iconPosition } placeholder = { placeholder } aria-label = { placeholder } >
6
+ { iconPosition === 'left' && < Icon name = { icon } /> }
7
+ < input />
8
+ { iconPosition !== 'left' && < Icon name = { icon } /> }
9
+ </ Input >
10
+ ) ;
11
+ // Better Spacing Handling – Removed unnecessary <br />, spacing can be handled via CSS.
12
+ // More Readable & Scalable – Cleaner structure with props controlling the component
4
13
const InputExampleIconChild = ( ) => (
5
- < div >
6
- < Input icon placeholder = 'Search...' >
7
- < input />
8
- < Icon name = 'search' />
9
- </ Input >
10
- < br />
11
- < br />
12
- < Input iconPosition = 'left' placeholder = 'Email' >
13
- < Icon name = 'at' />
14
- < input />
15
- </ Input >
16
- </ div >
17
- )
14
+ < >
15
+ < CustomInput icon = "search" placeholder = "Search..." />
16
+ < CustomInput icon = "at" iconPosition = "left" placeholder = "Email" />
17
+ </ >
18
+ ) ;
18
19
19
- export default InputExampleIconChild
20
+ export default InputExampleIconChild ;
You can’t perform that action at this time.
0 commit comments