| 1 |
import { useState } from 'react'; |
| 2 |
import { Checkbox, TextInput } from '@patternfly/react-core'; |
| 3 |
|
| 4 |
export const TextInputReadOnly: React.FunctionComponent = () => { |
| 5 |
const [isPlainChecked, setIsPlainChecked] = useState(false); |
| 6 |
return ( |
| 7 |
<> |
| 8 |
<div style={{ marginBottom: '12px' }}> |
| 9 |
<Checkbox |
| 10 |
id="isPlain" |
| 11 |
key="isPlain" |
| 12 |
label="Plain read only variant" |
| 13 |
isChecked={isPlainChecked} |
| 14 |
onChange={(_event, checked) => setIsPlainChecked(checked)} |
| 15 |
/> |
| 16 |
</div> |
| 17 |
<TextInput |
| 18 |
value="read only text input example" |
| 19 |
type="text" |
| 20 |
readOnlyVariant={isPlainChecked ? 'plain' : 'default'} |
| 21 |
aria-label="readonly input example" |
| 22 |
/> |
| 23 |
</> |
| 24 |
); |
| 25 |
}; |