Debian Codegraph @

node/@patternfly/react-core/src/components/SearchInput/examples/SearchInputWithExpandable.tsx

raw
1 import { useState } from 'react';
2 import { SearchInput } from '@patternfly/react-core';
3
4 export const SearchInputWithExpandable: React.FunctionComponent = () => {
5 const [value, setValue] = useState('');
6 const [isExpanded, setIsExpanded] = useState(false);
7
8 const onChange = (value: string) => {
9 setValue(value);
10 };
11
12 const onToggleExpand = (_event: React.SyntheticEvent<HTMLButtonElement>, isExpanded: boolean) => {
13 setIsExpanded(!isExpanded);
14 };
15
16 return (
17 <SearchInput
18 aria-label="Search with expandable button example"
19 placeholder="Find by name"
20 value={value}
21 onChange={(_event, value) => onChange(value)}
22 onClear={() => onChange('')}
23 expandableInput={{
24 isExpanded,
25 onToggleExpand,
26 toggleAriaLabel: 'Expandable search input toggle',
27 hasAnimations: true
28 }}
29 />
30 );
31 };