Button.Input
View Source
Transforms a button into an input. Composes and forwards props to Button.
Add Person
Copy
Edit
render(<Box padding={2} backgroundColor="primary"><Button.Inputtitle="Add Person"theme="light"iconLeft={{name: 'person',color: 'light-6',}}><Input width={24} /></Button.Input></Box>)
Link 1
Link 2
Link 3
Copy
Edit
const people = [{first: 'Charlie',last: 'Brown',twitter: 'dancounsell',},{first: 'Charlotte',last: 'White',twitter: 'mtnmissy',},{first: 'Chloe',last: 'Jones',twitter: 'ladylexy',},{first: 'Cooper',last: 'King',twitter: 'steveodom',},{first: 'James',last: 'Miller',twitter: 'bensie',},{first: 'John',last: 'James',twitter: 'miller',},{first: 'Travis',last: 'Arnold',twitter: 'souporserious',},]function ButtonCombobox({ buttonProps, comboboxProps, children }) {const comboboxRef = React.useRef(null)return (<Button.Input {...buttonProps}>{({ inputProps, close }) => (<Combobox.Popoverref={comboboxRef}openOnFocuscloseButton={{onClick: () => {close()comboboxRef.current.closePopover()},}}onClear={() => {close()comboboxRef.current.closePopover()}}{...inputProps}{...comboboxProps}>{children}</Combobox.Popover>)}</Button.Input>)}render(() => {const [value, setValue] = React.useState('')const [open, setOpen] = React.useState(false)const containerRef = React.useRef(null)return (<StackViewaxis="horizontal"alignment="center"distribution="space-between"minWidth="80%"padding={2}spacing={2}backgroundColor="primary"><StackView axis="horizontal" spacing={2}><Link color="white">Link 1</Link><Link color="white">Link 2</Link><Link color="white">Link 3</Link></StackView><ButtonComboboxbuttonProps={{innerRef: containerRef,title: 'search',icon: { name: 'topbar-search', color: 'light-9' },theme: 'light',onClose: () => setValue(''),}}comboboxProps={{value,onChange: (event) => setValue(event.target.value),onSelect: (person) => setValue(person.first + ' ' + person.last),placeholder: 'Search by name, email, or phone number',width: 40,stroke: 'primary-light',radius: 'pill',placement: 'bottom-end',popoverProps: {width: 40,matchWidths: false,relativeTo: containerRef,},}}><Combobox.Itemsvalue={value}filter={{ keys: [(person) => person.first + ' ' + person.last] }}items={people}renderItem={(person, index) => (<Combobox.Itemkey={person.first + ' ' + person.last}value={person}index={index}spacing={1}><Avatarsource={'https://api.adorable.io/avatars/' + index}size="sm"/><Highlightquery={value}text={person.first + ' ' + person.last}/><Text inline italic fontSize={5} marginLeft="auto" color="grey-6">{person.twitter}</Text></Combobox.Item>)}renderEmpty={[<Menu.Item>No results for<Text as="span" inline color="grey-7">"{value}"</Text></Menu.Item>,]}/></ButtonCombobox></StackView>)})
Props
children
(inputProps: InputProps) => React.ReactNode | ReactReactElement
Clones immediate child with input specific props. Use a function to access props and pass them yourself.
onClose
() => void
Callback when the input reverts back to a button.
onOpen
() => void
Callback when button is pressed to reveal the input.