Importing to the Table

Learn how to import files in Svelte using the FileReader API.

If you’ve reached this far, congratulations! You're one step away from finishing this application. In this lesson, we're going to implement the import functionality for our application. With this, users will be available to import and use existing data saved to their local machine. First, we need to add a new “Import” button to our Table component. Take a look at the example below:

@tailwind base;
@tailwind components;
@tailwind utilities;
Add the "Import" button to our table

First, we need to import a new component called Import in our Table.svelte. This component is already available in the components folder, but it's currently empty. We then use this component from line 146. We want to display it alongside the Export component, so we've placed them in a flex container. Open Import.svelte in the example above, and try to create a primary button with an empty onClick event ...