Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@foundationui/smart-input
Advanced tools
Smart input/textarea component for React. Learns to provide inline, tab-completeable suggestions.
<SmartInput>
Drop-in <input>
and <textarea>
replacement that that provides inline, tab-completable suggestions similar to GitHub Copilot.
The component automatically learns user inputs and makes better suggestions over time. We don't call it smart for nothing!
import { SmartInput } from '@foundationui/smart-input'
function MySmartInput() {
const [value, setValue] = useState('')
return (
<SmartInput
modelId="<add yours here>"
placeholder="Type something..."
renderText={props => <span {...props} />}
renderSuggestion={props => <span style={{ opacity: 0.4 }} {...props} />}
value={value}
onChange={setValue}
multiline={false}
/>
)
}
Check out more examples or try the online editor.
npm install --save @foundationui/smart-input
yarn add @foundationui/smart-input
modelId: String
The identifier of your model. Can be shared across different inputs, or unique per input.
value: String
The controlled text value of the content.
onChange: Function
Arguments: newValue: String
Invoked whenever the text value of the content changes. Use this to update the value for the controlled component.
renderText: Function
Arguments: props: Any
Invoked to display normal text, returns a React element. You should use an inline display element (e.g. span
) and spread props, like so:
renderText={props => <span {...props} />}
You may add whatever styling you like like via style
, className
, etc.
renderSuggestion: Function
Arguments: props: Any
Invoked to display completion text, returns a React element. You should use an inline display element (e.g. span
) and spread props, like so:
renderSuggestion={props => <span {...props} />}
You may add whatever styling you like like via style
, className
, etc.
className: string
(optional)Class name for the SmartInput wrapper div.
multiline: Boolean
(optional)Whether or not to allow multiline text.
onBlur: React.FocusEventHandler<HTMLDivElement>
(optional)Standard onBlur handler, analogous to that provided by <input>
and <textarea>
elements.
onFocus: React.FocusEventHandler<HTMLDivElement>
(optional)Standard onFocus handler, analogous to that provided by <input>
and <textarea>
elements.
onKeyDown: React.KeyboardEventHandler<HTMLDivElement>
(optional)Standard onKeyDown handler, analogous to that provided by <input>
and <textarea>
elements. Note that this handler is called after any keyboard events captured by <SmartInput>
(e.g. Tab
to accept a suggestion).
placeholder: String
(optional)The text to display when value is empty.
style: React.CSSProperties
(optional)Standard React CSS style property, applied to SmartInput wrapper div.
FAQs
Smart input/textarea component for React. Learns to provide inline, tab-completeable suggestions.
The npm package @foundationui/smart-input receives a total of 80 weekly downloads. As such, @foundationui/smart-input popularity was classified as not popular.
We found that @foundationui/smart-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.