Search code examples
htmlreactjstypescriptblueprintjs

In blueprintjs, how to set `accept` attribute in a FileInput


Could not figure out how to set the accept attribute when using react-blueprintjs. For reference, in HTML this would just be

<input type='file' accept='.txt,.csv,...' />

I tried using inputProps={accept: '...'} but this results in a "Cannot find name..." error.

Sorry if this is a n00b question, this is sitting right at React/blueprint/HTML/typescript blind spot for me.


Solution

  • This is actually a react question. See the docs on specifying attributes with JSX. Namely, expressions need to be wrapped in curly braces:

    <FileInput inputProps={{accept: "..."}} />